Skip to content

Commit d88dc8c

Browse files
authored
Merge pull request #7 from DAndrewBox/develop
Release v1.1.0
2 parents 7bf2ab9 + c778155 commit d88dc8c

File tree

35 files changed

+997
-330
lines changed

35 files changed

+997
-330
lines changed

Docs/Documentation.md

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# 📚 Documentation
22

3-
This is the official and up-to-date documentation for the **GameMaker's Testing Library**. Here you will find all the information you need to start using the library in your projects.
3+
This is the offline version of the official and up-to-date documentation for the **GameMaker's Testing Library**. Here you will find all the information you need to start using the library in your projects.
44

55
---
66

77
## 📖 Table of Contents
88

9+
- [Definitions](#definitions)
910
- [Setup](#setup)
1011
- [suite](#suite)
1112
- [describe / section](#describe)
@@ -21,7 +22,7 @@ This is the official and up-to-date documentation for the **GameMaker's Testing
2122
- [afterAll](#afterall)
2223
- [Common Matchers](#common-matchers)
2324
- [toBe](#tobe)
24-
- [toEqual](#toequal)
25+
- [toBeEqual](#tobeequal)
2526
- [toContain](#tocontain)
2627
- [toHaveLength](#tohavelength)
2728
- [toHaveProperty](#tohaveproperty)
@@ -50,6 +51,24 @@ This is the official and up-to-date documentation for the **GameMaker's Testing
5051
- [simulateMousePosition](#simulatemouseposition)
5152
- [simulateFrameWait](#simulateframewait)
5253
- [simulateEvent](#simulateevent)
54+
- [simulateTimesource](#simulatetimesource)
55+
- [simulateCallLater](#simulatecalllater)
56+
57+
---
58+
59+
## Definitions ![](https://img.shields.io/badge/v1.1-00cbca?style=flat)
60+
61+
> [!NOTE]
62+
> Definitions were added in v1.1.0 to allow users to configure the library's behavior without modifying the library's code directly. Previous versions of the library do not have this feature so this section would not apply to them.
63+
64+
Here you will find some of the definitions that are user editable for the GameMaker's Testing Library. These are used to configure some of the library and its behavior.
65+
66+
You can find and change these definitions in the `Libraries/GMTL/Setup/GMTL_definitions` script file inside the library. Here's the table of definitions you can edit in that file:
67+
68+
| Name | Description | Default Value |
69+
| ----------------------------- | ------------------------------------------------ | ------------- |
70+
| gmtl_run_at_start | Run GMTL tests at game start. | true |
71+
| gmtl_wait_frames_before_start | Frames to wait before start running GMTL suites. | 10 |
5372

5473
---
5574

@@ -88,8 +107,7 @@ Sections are used to group tests together. They can contain tests but not other
88107
89108
`test(name, callback)` _or_ `it(name, callback)`
90109
91-
> [!IMPORTANT]
92-
> `test` and `it` are the same function. You can use either of them to create a new test. They are used to create a new test inside a section. You cannot nest tests inside other tests. Tests should always be inside a section.
110+
> [!IMPORTANT] > `test` and `it` are the same function. You can use either of them to create a new test. They are used to create a new test inside a section. You cannot nest tests inside other tests. Tests should always be inside a section.
93111
94112
Tests are used to test a specific piece of code. They should be small and focused on a single aspect of your code. You can put a test in any section and it is recommended to have multiple tests per section to test different parts of your code.
95113
@@ -260,13 +278,13 @@ Here you will find all the matchers you can use after the `expect` function to m
260278

261279
`toBe(expected)`
262280

263-
The `toBe` matcher is used to compare the actual value with the expected value using the `==` operator. This matcher will check if the actual value is the same as the expected value. It will throw an error if they are not the same. This matcher is used to compare primitive values like numbers, strings, ref index, and booleans, and can accept arrays, but not structs. For structs, you can use the `toEqual` matcher.
281+
The `toBe` matcher is used to compare the actual value with the expected value using the `==` operator. This matcher will check if the actual value is the same as the expected value. It will throw an error if they are not the same. This matcher is used to compare primitive values like numbers, strings, ref index, and booleans, and can accept arrays, but not structs. For structs, you can use the `toBeEqual` matcher.
264282

265-
### toEqual
283+
### toBeEqual
266284

267-
`toEqual(expected)`
285+
`toBeEqual(expected)`
268286

269-
The `toEqual` matcher is used to compare the actual value with the expected value using the `==` operator. This matcher will check if the actual value is the same as the expected value. It will throw an error if they are not the same. This matcher is used to compare primitive values like numbers, strings, ref index, and booleans, and can accept arrays and structs.
287+
The `toBeEqual` matcher is used to compare the actual value with the expected value using the `==` operator. This matcher will check if the actual value is the same as the expected value. It will throw an error if they are not the same. This matcher is used to compare primitive values like numbers, strings, ref index, and booleans, and can accept arrays and structs.
270288

271289
### toContain
272290

@@ -385,7 +403,7 @@ The `create` function is used to create an instance of an object at a specific p
385403
Example:
386404
387405
```gml
388-
suite("Mfunction() {
406+
suite(function() {
389407
section("My Section", function() {
390408
test("My Test", function() {
391409
var _obj = create(0, 0, obj_player);
@@ -461,7 +479,7 @@ The `simulateMousePosition` function is used to simulate a mouse position event.
461479
`simulateFrameWait([frames])`
462480

463481
> [!IMPORTANT]
464-
> This function simulates frames passing by executing the step events of the objects, the frames are not actually rendered by GameMaker.
482+
> This function simulates frames passing by executing timesources/call_later, the step events of the objects, the frames are not actually rendered by GameMaker.
465483
466484
The `simulateFrameWait` function is used to simulate a frame wait event. This function will wait for the specified number of virtual frames before continuing. You can pass an optional number of frames to the function to wait for a specific number of frames. If no frames are specified, it will wait for one frame.
467485

@@ -470,3 +488,24 @@ The `simulateFrameWait` function is used to simulate a frame wait event. This fu
470488
`simulateEvent(event_type, event_number, [instance_id])`
471489

472490
The `simulateEvent` function is used to simulate an event for an object. This function will simulate an event for the specified object. You can pass an object id, an event id, and an optional instance id to the function to simulate an event for the specified object. The event type and number should be theones described in the manual like `ev_create`, `ev_step`, etc. The instance id should be an instance id, if no instance id is specified, it will simulate the event for all instances currently active.
491+
492+
### simulateTimesource ![](https://img.shields.io/badge/v1.1-00cbca?style=flat)
493+
494+
`simulateTimesource(parent, period, unit, callback, [args], [repetitions], [expiry])`
495+
496+
The `simulateTimesource` function is used to simulate a [timesource](https://manual.gamemaker.io/lts/en/GameMaker_Language/GML_Reference/Time_Sources/Time_Sources.htm). This function takes the exact same parameters than a GameMaker native timesource, but it will not actually create a timesource, it will just virtually simulate the event. This is useful when you want to test pseudo-async events like a custom garbage collector or waiting some frames for an event to happen.
497+
498+
This function creates a constructor that will be used to simulate the timesource and has 2 methods to call for it to work: `.start()` that mimics the behaviour of [time_source_start()](https://manual.gamemaker.io/lts/en/GameMaker_Language/GML_Reference/Time_Sources/time_source_start.htm), and `.stop()` that mimics the behaviour of [time_source_stop()](https://manual.gamemaker.io/lts/en/GameMaker_Language/GML_Reference/Time_Sources/time_source_stop.htm).
499+
500+
**If you want to strictly call the GameMaker's built-in functions you can use `original_time_source_create()`, `original_time_source_start()`, etc**
501+
502+
### simulateCallLater ![](https://img.shields.io/badge/v1.1-00cbca?style=flat)
503+
504+
> [!NOTE]
505+
> Since the original GameMaker's `call_later()` function works behind the scenes with a timesource, this function is basically a wrapper for the `simulateTimesource` function too.
506+
507+
`simulateCallLater(callback, [args], [repetitions], [loop])`
508+
509+
The `simulateCallLater` function is used to simulate a [call_later()](https://manual.gamemaker.io/lts/en/GameMaker_Language/GML_Reference/Time_Sources/call_later.htm) event. This function will simulate a call later event for the specified callback. You can pass a callback, an optional array of arguments, an optional number of repetitions, and an optional loop flag to the function to simulate a call later event. The callback will be called after the specified number of frames.
510+
511+
**If you want to strictly call the GameMaker's built-in function you can use `original_call_later()` directly in your code.**

Docs/Home.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,23 @@
1717

1818
## 🔧 Versioning & Compatibility
1919

20-
The minimum version of GameMaker required to use this library is **GameMaker 2023.4**. This is because it uses the _string templates_ and _string functions_ introduced in that version and previous like `string_split()`. The library is fully compatible with the latest version of GameMaker 2024.x.
20+
The minimum version of GameMaker required to use this library is **GameMaker 2023.4**. This is because it uses the _string templates_ and _string functions_ introduced in that version like the `string_split()` function. The library should be fully compatible with the latest version of GameMaker 2024.x.
2121

2222
✅: Fully compatible. (\*: Recommended for this version.)
2323

2424
⚠️: Compatible but could have some issues with the new features of the version or built-in functions.
2525

2626
❌: Not compatible.
2727

28-
| GameMaker Version | GMTL v1.0.x |
29-
| ----------------: | :---------: |
30-
| Studio 1.4.x ||
31-
| Studio 2 - 2.2 ||
32-
| Studio 2.3.x ||
33-
| 2022.x & 2022 LTS ||
34-
| 2023.1 - 2023.3 | ⚠️ |
35-
| 2023.4 - 2023.11 ||
36-
| 2023 LTS ||
37-
| 2024.x |\* |
38-
39-
> [!NOTE]
40-
> **Author's comment:** Depending if anyone is interested in using this library with older versions of GameMaker, I could make a version compatible up to **GameMaker Studio 2.3.7** as I did with the compatibility update in the [**GML-Extended**](https://github.com/DAndrewBox/GML-Extended/) library.
28+
| GameMaker Version | GMTL v1.0.x | GMTL v1.1.x |
29+
| ----------------: | :---------: | :---------: |
30+
| Studio 1.4.x |||
31+
| Studio 2 - 2.2 |||
32+
| Studio 2.3.x |||
33+
| 2022.x & 2022 LTS |||
34+
| 2023.1 - 2023.3 | ⚠️ ||
35+
| 2023.4 - 2023.11 |||
36+
| 2023 LTS |||
37+
| 2024.x / 2024 LTS |\* |\* |
38+
39+
> [!NOTE] > **Author's comment:** Depending if anyone is interested in using this library with older versions of GameMaker, I could make a version compatible up to **GameMaker Studio 2.3.7** as I did with the compatibility update in the [**GML-Extended**](https://github.com/DAndrewBox/GML-Extended/) library.

Docs/Troubleshooting.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ This issue can be caused by the library's scripts not being found in the project
2727
This error is caused by the library not being found in the project. To fix this, you need to add the library to the project. You can do this by following the installation instructions in the [**Getting Started**](./Getting-Started) section.
2828

2929
---
30+
31+
### GMTL_Definitions script file empty after importing in blank project
32+
33+
This issue should be solved since v1.1.0, but if you still encounter it, you can manually copy the contents of the `GMTL_Definitions` script file from the [library's repository](https://github.com/DAndrewBox/GM-Testing-Library/blob/main/GM-Testing-Library/scripts/GMTL_definitions/GMTL_definitions.gml) into your project. This file contains the definitions for the library's functions and is essential for the library to work correctly.
34+
35+
I'm not really sure what causes this issue, but it seems to be related to the import process of the library that GameMaker does. If you encounter this issue, please [create an issue](https://github.com/DAndrewBox/GM-Testing-Library/issues) so I can investigate it further.
36+
37+
---

GM-Testing-Library/GM-Testing-Library.resource_order

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@
2525
{"name":"o_gmtl_demo_draw","order":3,"path":"objects/o_gmtl_demo_draw/o_gmtl_demo_draw.yy",},
2626
{"name":"o_gmtl_demo_timer","order":1,"path":"objects/o_gmtl_demo_timer/o_gmtl_demo_timer.yy",},
2727
{"name":"r_gmtl_demo","order":5,"path":"rooms/r_gmtl_demo/r_gmtl_demo.yy",},
28+
{"name":"GMTL_core_MouseState","order":5,"path":"scripts/GMTL_core_MouseState/GMTL_core_MouseState.yy",},
2829
{"name":"GMTL_core_test_setup","order":1,"path":"scripts/GMTL_core_test_setup/GMTL_core_test_setup.yy",},
30+
{"name":"GMTL_core_test_simulations","order":4,"path":"scripts/GMTL_core_test_simulations/GMTL_core_test_simulations.yy",},
2931
{"name":"GMTL_core_TestCase","order":2,"path":"scripts/GMTL_core_TestCase/GMTL_core_TestCase.yy",},
32+
{"name":"GMTL_core_TimeSource","order":3,"path":"scripts/GMTL_core_TimeSource/GMTL_core_TimeSource.yy",},
3033
{"name":"GMTL_dependencies","order":1,"path":"scripts/GMTL_dependencies/GMTL_dependencies.yy",},
34+
{"name":"GMTL_enums","order":5,"path":"scripts/GMTL_enums/GMTL_enums.yy",},
3135
{"name":"GMTL_init","order":2,"path":"scripts/GMTL_init/GMTL_init.yy",},
3236
{"name":"GMTL_internal","order":3,"path":"scripts/GMTL_internal/GMTL_internal.yy",},
3337
{"name":"GMTL_remove_unused_msg","order":4,"path":"scripts/GMTL_remove_unused_msg/GMTL_remove_unused_msg.yy",},

GM-Testing-Library/GM-Testing-Library.yyp

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GM-Testing-Library/fonts/fnt_gmtl_demo/fnt_gmtl_demo.old.yy

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GM-Testing-Library/fonts/fnt_gmtl_demo/fnt_gmtl_demo.yy

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
log = "";
2+
log_lines = [];

GM-Testing-Library/objects/o_gmtl_demo_draw/Draw_64.gml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ draw_set_halign(fa_left);
66
draw_set_valign(fa_top);
77
draw_set_font(fnt_gmtl_demo);
88

9-
if (gmtl_log != "") {
10-
var _log = string_replace_all(gmtl_log, "\t", " ");
11-
draw_text(8, 8, _log);
12-
}
9+
if (log != "") {
10+
var _log_lines_len = array_length(log_lines);
11+
var _yoff = 0;
12+
for (var i = 0; i < _log_lines_len; i++) {
13+
draw_set_color(log_lines[i].color);
14+
draw_text(8, 8 + _yoff, log_lines[i].text);
15+
_yoff += 18;
16+
}
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
if (gmtl_has_finished && !gmtl_internal.initializing && log == "") {
2+
log = string_replace_all(gmtl_log, "\t", " ");
3+
log_lines = string_split(log, "\n", false);
4+
5+
var _log_lines_len = array_length(log_lines);
6+
for (var i = 0; i < _log_lines_len; i++) {
7+
var _line_color = c_white;
8+
9+
if (string_pos("", log_lines[i])) _line_color = c_lime else
10+
if (string_pos("", log_lines[i])) _line_color = c_red else
11+
if (string_pos("", log_lines[i])) _line_color = c_orange else
12+
if (string_pos("", log_lines[i])) _line_color = c_ltgrey else
13+
if (string_pos("", log_lines[i])) _line_color = c_ltgrey;
14+
15+
log_lines[i] = {
16+
text: log_lines[i],
17+
color: _line_color
18+
};
19+
}
20+
}

0 commit comments

Comments
 (0)