• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Asset - Extension GMAssert: Easy assertion checking for GMS 2.x and 1.4

FrostyCat

Redemption Seeker
GMAssert
Easy assertion checking for GMS 2.x and 1.4


Overview
GMAssert is a library containing useful assertions for debugging and automated unit testing. You can use it to alert you to undesirable runtime conditions, pause the debugger at that point for further inspection, or quickly test code for expected behaviour.

Downloads
GMS 2.x: YoYo Marketplace | GitHub | Documentation
GMS 1.4: Download | GitHub | Documentation

Examples

Successful Assertion:
Code:
var name = "Alice";
assert_equal(name, "Alice", "Name isn't Alice!");
This proceeds silently without error messages.
Failed Assertion:
Code:
var name = "Bob";
assert_equal(name, "Alice", "Name isn't Alice!");
This shows the following error message by default:
Code:
___________________________________________
############################################################################################
FATAL ERROR in Room Creation Code for room rm_test

Name is wrong!

Expected: (string)
"Alice"

Got: (string)
"Bob"


 at gml_Script___gma_assert_error__ (line 11) -       show_error(msg, true);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script___gma_assert_error__ (line 11)
called from - gml_Script_assert_equal (line 23) -     __gma_assert_error__(msg, argument[1], argument[0]);
called from - gml_Room_rm_test_Create (line 3) -        assert_equal(name, "Alice", "Name is wrong!");

Feedback Welcome!
If you have any suggestions for new constructors/use cases or bug reports, please open an issue or contribute on GitHub.
 
Last edited:

FrostyCat

Redemption Seeker
Update: v2.0.1 has been pushed to the YoYo Marketplace. This release is for resolving a Marketplace-side issue, and contains no new changes. If you downloaded the v2.0.0 extension and it came with only the __GMA_BREAKPOINT__ script but no extensions, please retry with v2.0.1 and verify that the main extension is present.
 
Top