diff --git a/GMXorWow.yyp b/GMXorWow.yyp new file mode 100644 index 0000000..51934db --- /dev/null +++ b/GMXorWow.yyp @@ -0,0 +1,59 @@ +{ + "resources": [ + {"id":{"name":"__xorwow_test_values__","path":"scripts/__xorwow_test_values__/__xorwow_test_values__.yy",},"order":5,}, + {"id":{"name":"__GMA_SETTINGS__","path":"scripts/__GMA_SETTINGS__/__GMA_SETTINGS__.yy",},"order":1,}, + {"id":{"name":"xorwow_test_sequencing","path":"scripts/xorwow_test_sequencing/xorwow_test_sequencing.yy",},"order":3,}, + {"id":{"name":"xorwow_test_values","path":"scripts/xorwow_test_values/xorwow_test_values.yy",},"order":4,}, + {"id":{"name":"GMAssert","path":"extensions/GMAssert/GMAssert.yy",},"order":0,}, + {"id":{"name":"xorwow_test_all","path":"scripts/xorwow_test_all/xorwow_test_all.yy",},"order":1,}, + {"id":{"name":"XorWow_classes","path":"scripts/XorWow_classes/XorWow_classes.yy",},"order":0,}, + {"id":{"name":"xorwow_test_seeding","path":"scripts/xorwow_test_seeding/xorwow_test_seeding.yy",},"order":2,}, + {"id":{"name":"__GMA_BREAKPOINT__","path":"scripts/__GMA_BREAKPOINT__/__GMA_BREAKPOINT__.yy",},"order":0,}, + {"id":{"name":"rm_xorwow_test","path":"rooms/rm_xorwow_test/rm_xorwow_test.yy",},"order":0,}, + ], + "Options": [ + {"name":"HTML5","path":"options/html5/options_html5.yy",}, + {"name":"Windows UWP","path":"options/windowsuap/options_windowsuap.yy",}, + {"name":"iOS","path":"options/ios/options_ios.yy",}, + {"name":"tvOS","path":"options/tvos/options_tvos.yy",}, + {"name":"macOS","path":"options/mac/options_mac.yy",}, + {"name":"Linux","path":"options/linux/options_linux.yy",}, + {"name":"Android","path":"options/android/options_android.yy",}, + {"name":"Windows","path":"options/windows/options_windows.yy",}, + {"name":"Main","path":"options/main/options_main.yy",}, + {"name":"Amazon Fire","path":"options/amazonfire/options_amazonfire.yy",}, + ], + "isDnDProject": false, + "isEcma": false, + "tutorialPath": "", + "configs": { + "name": "Default", + "children": [], + }, + "RoomOrderNodes": [ + {"roomId":{"name":"rm_xorwow_test","path":"rooms/rm_xorwow_test/rm_xorwow_test.yy",},}, + ], + "Folders": [ + {"folderPath":"folders/Libraries.yy","order":16,"resourceVersion":"1.0","name":"Libraries","tags":[],"resourceType":"GMFolder",}, + {"folderPath":"folders/Libraries/GMAssert.yy","order":1,"resourceVersion":"1.0","name":"GMAssert","tags":[],"resourceType":"GMFolder",}, + {"folderPath":"folders/Libraries_config.yy","order":17,"resourceVersion":"1.0","name":"Libraries_config","tags":[],"resourceType":"GMFolder",}, + {"folderPath":"folders/Libraries_config/GMAssert.yy","order":1,"resourceVersion":"1.0","name":"GMAssert","tags":[],"resourceType":"GMFolder",}, + {"folderPath":"folders/Libraries_test.yy","order":18,"resourceVersion":"1.0","name":"Libraries_test","tags":[],"resourceType":"GMFolder",}, + {"folderPath":"folders/Libraries_test/GMXorWow_test.yy","order":1,"resourceVersion":"1.0","name":"GMXorWow_test","tags":[],"resourceType":"GMFolder",}, + {"folderPath":"folders/Libraries/GMXorWow.yy","order":2,"resourceVersion":"1.0","name":"GMXorWow","tags":[],"resourceType":"GMFolder",}, + ], + "AudioGroups": [ + {"targets":-1,"resourceVersion":"1.3","name":"audiogroup_default","resourceType":"GMAudioGroup",}, + ], + "TextureGroups": [ + {"isScaled":true,"autocrop":true,"border":2,"mipsToGenerate":0,"groupParent":null,"targets":-1,"resourceVersion":"1.3","name":"Default","resourceType":"GMTextureGroup",}, + ], + "IncludedFiles": [], + "MetaData": { + "IDEVersion": "2.3.1.542", + }, + "resourceVersion": "1.4", + "name": "GMXorWow", + "tags": [], + "resourceType": "GMProject", +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0c2cf75 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Dickson Law + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LICENSE_ALGORITHM b/LICENSE_ALGORITHM new file mode 100644 index 0000000..d27c5a9 --- /dev/null +++ b/LICENSE_ALGORITHM @@ -0,0 +1,322 @@ +Creative Commons Legal Code + +Attribution 3.0 Unported + +Copyright (c) 2003 George Marsaglia +https://www.jstatsoft.org/article/view/v008i14 + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR + DAMAGES RESULTING FROM ITS USE. + +License + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE +COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY +COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS +AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE +TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY +BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS +CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND +CONDITIONS. + +1. Definitions + + a. "Adaptation" means a work based upon the Work, or upon the Work and + other pre-existing works, such as a translation, adaptation, + derivative work, arrangement of music or other alterations of a + literary or artistic work, or phonogram or performance and includes + cinematographic adaptations or any other form in which the Work may be + recast, transformed, or adapted including in any form recognizably + derived from the original, except that a work that constitutes a + Collection will not be considered an Adaptation for the purpose of + this License. For the avoidance of doubt, where the Work is a musical + work, performance or phonogram, the synchronization of the Work in + timed-relation with a moving image ("synching") will be considered an + Adaptation for the purpose of this License. + b. "Collection" means a collection of literary or artistic works, such as + encyclopedias and anthologies, or performances, phonograms or + broadcasts, or other works or subject matter other than works listed + in Section 1(f) below, which, by reason of the selection and + arrangement of their contents, constitute intellectual creations, in + which the Work is included in its entirety in unmodified form along + with one or more other contributions, each constituting separate and + independent works in themselves, which together are assembled into a + collective whole. A work that constitutes a Collection will not be + considered an Adaptation (as defined above) for the purposes of this + License. + c. "Distribute" means to make available to the public the original and + copies of the Work or Adaptation, as appropriate, through sale or + other transfer of ownership. + d. "Licensor" means the individual, individuals, entity or entities that + offer(s) the Work under the terms of this License. + e. "Original Author" means, in the case of a literary or artistic work, + the individual, individuals, entity or entities who created the Work + or if no individual or entity can be identified, the publisher; and in + addition (i) in the case of a performance the actors, singers, + musicians, dancers, and other persons who act, sing, deliver, declaim, + play in, interpret or otherwise perform literary or artistic works or + expressions of folklore; (ii) in the case of a phonogram the producer + being the person or legal entity who first fixes the sounds of a + performance or other sounds; and, (iii) in the case of broadcasts, the + organization that transmits the broadcast. + f. "Work" means the literary and/or artistic work offered under the terms + of this License including without limitation any production in the + literary, scientific and artistic domain, whatever may be the mode or + form of its expression including digital form, such as a book, + pamphlet and other writing; a lecture, address, sermon or other work + of the same nature; a dramatic or dramatico-musical work; a + choreographic work or entertainment in dumb show; a musical + composition with or without words; a cinematographic work to which are + assimilated works expressed by a process analogous to cinematography; + a work of drawing, painting, architecture, sculpture, engraving or + lithography; a photographic work to which are assimilated works + expressed by a process analogous to photography; a work of applied + art; an illustration, map, plan, sketch or three-dimensional work + relative to geography, topography, architecture or science; a + performance; a broadcast; a phonogram; a compilation of data to the + extent it is protected as a copyrightable work; or a work performed by + a variety or circus performer to the extent it is not otherwise + considered a literary or artistic work. + g. "You" means an individual or entity exercising rights under this + License who has not previously violated the terms of this License with + respect to the Work, or who has received express permission from the + Licensor to exercise rights under this License despite a previous + violation. + h. "Publicly Perform" means to perform public recitations of the Work and + to communicate to the public those public recitations, by any means or + process, including by wire or wireless means or public digital + performances; to make available to the public Works in such a way that + members of the public may access these Works from a place and at a + place individually chosen by them; to perform the Work to the public + by any means or process and the communication to the public of the + performances of the Work, including by public digital performance; to + broadcast and rebroadcast the Work by any means including signs, + sounds or images. + i. "Reproduce" means to make copies of the Work by any means including + without limitation by sound or visual recordings and the right of + fixation and reproducing fixations of the Work, including storage of a + protected performance or phonogram in digital form or other electronic + medium. + +2. Fair Dealing Rights. Nothing in this License is intended to reduce, +limit, or restrict any uses free from copyright or rights arising from +limitations or exceptions that are provided for in connection with the +copyright protection under copyright law or other applicable laws. + +3. License Grant. Subject to the terms and conditions of this License, +Licensor hereby grants You a worldwide, royalty-free, non-exclusive, +perpetual (for the duration of the applicable copyright) license to +exercise the rights in the Work as stated below: + + a. to Reproduce the Work, to incorporate the Work into one or more + Collections, and to Reproduce the Work as incorporated in the + Collections; + b. to create and Reproduce Adaptations provided that any such Adaptation, + including any translation in any medium, takes reasonable steps to + clearly label, demarcate or otherwise identify that changes were made + to the original Work. For example, a translation could be marked "The + original work was translated from English to Spanish," or a + modification could indicate "The original work has been modified."; + c. to Distribute and Publicly Perform the Work including as incorporated + in Collections; and, + d. to Distribute and Publicly Perform Adaptations. + e. For the avoidance of doubt: + + i. Non-waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme cannot be waived, the Licensor + reserves the exclusive right to collect such royalties for any + exercise by You of the rights granted under this License; + ii. Waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme can be waived, the Licensor waives the + exclusive right to collect such royalties for any exercise by You + of the rights granted under this License; and, + iii. Voluntary License Schemes. The Licensor waives the right to + collect royalties, whether individually or, in the event that the + Licensor is a member of a collecting society that administers + voluntary licensing schemes, via that society, from any exercise + by You of the rights granted under this License. + +The above rights may be exercised in all media and formats whether now +known or hereafter devised. The above rights include the right to make +such modifications as are technically necessary to exercise the rights in +other media and formats. Subject to Section 8(f), all rights not expressly +granted by Licensor are hereby reserved. + +4. Restrictions. The license granted in Section 3 above is expressly made +subject to and limited by the following restrictions: + + a. You may Distribute or Publicly Perform the Work only under the terms + of this License. You must include a copy of, or the Uniform Resource + Identifier (URI) for, this License with every copy of the Work You + Distribute or Publicly Perform. You may not offer or impose any terms + on the Work that restrict the terms of this License or the ability of + the recipient of the Work to exercise the rights granted to that + recipient under the terms of the License. You may not sublicense the + Work. You must keep intact all notices that refer to this License and + to the disclaimer of warranties with every copy of the Work You + Distribute or Publicly Perform. When You Distribute or Publicly + Perform the Work, You may not impose any effective technological + measures on the Work that restrict the ability of a recipient of the + Work from You to exercise the rights granted to that recipient under + the terms of the License. This Section 4(a) applies to the Work as + incorporated in a Collection, but this does not require the Collection + apart from the Work itself to be made subject to the terms of this + License. If You create a Collection, upon notice from any Licensor You + must, to the extent practicable, remove from the Collection any credit + as required by Section 4(b), as requested. If You create an + Adaptation, upon notice from any Licensor You must, to the extent + practicable, remove from the Adaptation any credit as required by + Section 4(b), as requested. + b. If You Distribute, or Publicly Perform the Work or any Adaptations or + Collections, You must, unless a request has been made pursuant to + Section 4(a), keep intact all copyright notices for the Work and + provide, reasonable to the medium or means You are utilizing: (i) the + name of the Original Author (or pseudonym, if applicable) if supplied, + and/or if the Original Author and/or Licensor designate another party + or parties (e.g., a sponsor institute, publishing entity, journal) for + attribution ("Attribution Parties") in Licensor's copyright notice, + terms of service or by other reasonable means, the name of such party + or parties; (ii) the title of the Work if supplied; (iii) to the + extent reasonably practicable, the URI, if any, that Licensor + specifies to be associated with the Work, unless such URI does not + refer to the copyright notice or licensing information for the Work; + and (iv) , consistent with Section 3(b), in the case of an Adaptation, + a credit identifying the use of the Work in the Adaptation (e.g., + "French translation of the Work by Original Author," or "Screenplay + based on original Work by Original Author"). The credit required by + this Section 4 (b) may be implemented in any reasonable manner; + provided, however, that in the case of a Adaptation or Collection, at + a minimum such credit will appear, if a credit for all contributing + authors of the Adaptation or Collection appears, then as part of these + credits and in a manner at least as prominent as the credits for the + other contributing authors. For the avoidance of doubt, You may only + use the credit required by this Section for the purpose of attribution + in the manner set out above and, by exercising Your rights under this + License, You may not implicitly or explicitly assert or imply any + connection with, sponsorship or endorsement by the Original Author, + Licensor and/or Attribution Parties, as appropriate, of You or Your + use of the Work, without the separate, express prior written + permission of the Original Author, Licensor and/or Attribution + Parties. + c. Except as otherwise agreed in writing by the Licensor or as may be + otherwise permitted by applicable law, if You Reproduce, Distribute or + Publicly Perform the Work either by itself or as part of any + Adaptations or Collections, You must not distort, mutilate, modify or + take other derogatory action in relation to the Work which would be + prejudicial to the Original Author's honor or reputation. Licensor + agrees that in those jurisdictions (e.g. Japan), in which any exercise + of the right granted in Section 3(b) of this License (the right to + make Adaptations) would be deemed to be a distortion, mutilation, + modification or other derogatory action prejudicial to the Original + Author's honor and reputation, the Licensor will waive or not assert, + as appropriate, this Section, to the fullest extent permitted by the + applicable national law, to enable You to reasonably exercise Your + right under Section 3(b) of this License (right to make Adaptations) + but not otherwise. + +5. Representations, Warranties and Disclaimer + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR +OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY +KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, +INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, +FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF +LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, +WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. + +6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE +LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR +ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES +ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. Termination + + a. This License and the rights granted hereunder will terminate + automatically upon any breach by You of the terms of this License. + Individuals or entities who have received Adaptations or Collections + from You under this License, however, will not have their licenses + terminated provided such individuals or entities remain in full + compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will + survive any termination of this License. + b. Subject to the above terms and conditions, the license granted here is + perpetual (for the duration of the applicable copyright in the Work). + Notwithstanding the above, Licensor reserves the right to release the + Work under different license terms or to stop distributing the Work at + any time; provided, however that any such election will not serve to + withdraw this License (or any other license that has been, or is + required to be, granted under the terms of this License), and this + License will continue in full force and effect unless terminated as + stated above. + +8. Miscellaneous + + a. Each time You Distribute or Publicly Perform the Work or a Collection, + the Licensor offers to the recipient a license to the Work on the same + terms and conditions as the license granted to You under this License. + b. Each time You Distribute or Publicly Perform an Adaptation, Licensor + offers to the recipient a license to the original Work on the same + terms and conditions as the license granted to You under this License. + c. If any provision of this License is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability of + the remainder of the terms of this License, and without further action + by the parties to this agreement, such provision shall be reformed to + the minimum extent necessary to make such provision valid and + enforceable. + d. No term or provision of this License shall be deemed waived and no + breach consented to unless such waiver or consent shall be in writing + and signed by the party to be charged with such waiver or consent. + e. This License constitutes the entire agreement between the parties with + respect to the Work licensed here. There are no understandings, + agreements or representations with respect to the Work not specified + here. Licensor shall not be bound by any additional provisions that + may appear in any communication from You. This License may not be + modified without the mutual written agreement of the Licensor and You. + f. The rights granted under, and the subject matter referenced, in this + License were drafted utilizing the terminology of the Berne Convention + for the Protection of Literary and Artistic Works (as amended on + September 28, 1979), the Rome Convention of 1961, the WIPO Copyright + Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 + and the Universal Copyright Convention (as revised on July 24, 1971). + These rights and subject matter take effect in the relevant + jurisdiction in which the License terms are sought to be enforced + according to the corresponding provisions of the implementation of + those treaty provisions in the applicable national law. If the + standard suite of rights granted under applicable copyright law + includes additional rights not granted under this License, such + additional rights are deemed to be included in the License; this + License is not intended to restrict the license of any rights under + applicable law. + + +Creative Commons Notice + + Creative Commons is not a party to this License, and makes no warranty + whatsoever in connection with the Work. Creative Commons will not be + liable to You or any party on any legal theory for any damages + whatsoever, including without limitation any general, special, + incidental or consequential damages arising in connection to this + license. Notwithstanding the foregoing two (2) sentences, if Creative + Commons has expressly identified itself as the Licensor hereunder, it + shall have all rights and obligations of Licensor. + + Except for the limited purpose of indicating to the public that the + Work is licensed under the CCPL, Creative Commons does not authorize + the use by either party of the trademark "Creative Commons" or any + related trademark or logo of Creative Commons without the prior + written consent of Creative Commons. Any permitted use will be in + compliance with Creative Commons' then-current trademark usage + guidelines, as may be published on its website or otherwise made + available upon request from time to time. For the avoidance of doubt, + this trademark restriction does not form part of this License. + + Creative Commons may be contacted at https://creativecommons.org/. diff --git a/README.md b/README.md new file mode 100644 index 0000000..467b9b4 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# GMXorWow + +This is a GameMaker Studio 2.3 implementation of [George Marsaglia's XorWow, XorShift32 and XorShift128 algorithms](https://www.jstatsoft.org/article/view/v008i14). Using only 32-bit unsigned integer operations at its core, this library lets you generate pseudorandom numbers consistently across all exports given the same starting seed. It also adds the ability to create seeds using strings and set up many independent generators in parallel. + +## Requirements + +GameMaker Studio 2.3.0 or above. + +## Installation + +Get the installation packages [here](https://www.github.com/dicksonlaw583/GMXorWow/releases). + +## How to Use + +### Global-Level Seed + +GMXorWow sets up a randomized global-level seed for you by default. To use it for randomization, simply prepend `x` to any of the following random-related functions. + +| Standard GML | GMXorWow Global Seed | +| --- | --- | +| `random(n)` | `xrandom(n)` | +| `irandom(n)` | `xirandom(n)` | +| `random_range(m, n)` | `xrandom_range(m, n)` | +| `irandom_range(m, n)` | `xirandom_range(m, n)` | +| `ds_list_shuffle(list)` | `xds_list_shuffle(list)` | +| `ds_grid_shuffle(grid)` | `xds_grid_shuffle(grid)` | +| `array_shuffle(array)` | `xarray_shuffle(array)` | + +### Independent Seeds + +Independent seeds can be created using any of the three constructors: + +- `XorWow` +- `XorShift32` +- `XorShift128` + +Simply prepend `s` to the random-related function's name and call it as a method of the seed. + +``` +var seed = new XorWow("foo"); +x = seed.sirandom(room_width); +y = seed.sirandom(room_height); +``` + +| Standard GML | GMXorWow Independent Seed | +| --- | --- | +| `random(n)` | `seed.srandom(n)` | +| `irandom(n)` | `seed.sirandom(n)` | +| `random_range(m, n)` | `seed.srandom_range(m, n)` | +| `irandom_range(m, n)` | `seed.sirandom_range(m, n)` | +| `ds_list_shuffle(list)` | `seed.sds_list_shuffle(list)` | +| `ds_grid_shuffle(grid)` | `seed.sds_grid_shuffle(grid)` | +| `array_shuffle(array)` | `seed.sarray_shuffle(array)` | + diff --git a/extensions/GMAssert/GMAssert.gml b/extensions/GMAssert/GMAssert.gml new file mode 100644 index 0000000..36ce85f --- /dev/null +++ b/extensions/GMAssert/GMAssert.gml @@ -0,0 +1,2533 @@ +#define __gma_assert_error__ +/// @function __gma_assert_error__(message, expected, got) +/// @param message The message to display to the user +/// @param expected The value expected for the assertion +/// @param got The actual received value for the assertion +{ + var gtbp = asset_get_index("__GMA_TEST_BREAKPOINT__"), + gbp = asset_get_index("__GMA_BREAKPOINT__"); + if (GMASSERT_ENABLED && ((gtbp != -1 && !script_execute(gtbp, argument0, argument2, argument1)) || (gbp != -1 && gtbp == -1 && !script_execute(gbp, argument0, argument2, argument1)) || gbp == -1)) { + var msg = argument0 + chr(13)+chr(10) + chr(13)+chr(10) + "Expected: " + __gma_debug_value__(argument1) + chr(13)+chr(10) + chr(13)+chr(10) + "Got: " + __gma_debug_value__(argument2) + chr(13)+chr(10) + chr(13)+chr(10); + if (os_browser == browser_not_a_browser) { + show_error(msg, true); + } + else { + show_message(msg); + } + } +} + +#define __gma_assert_error_simple__ +/// @function __gma_assert_error_simple__(message, got) +/// @param message The message to display to the user +/// @param got The actual received value for the assertion +{ + var gtbp = asset_get_index("__GMA_TEST_BREAKPOINT__"), + gbp = asset_get_index("__GMA_BREAKPOINT__"); + if (GMASSERT_ENABLED && ((gtbp != -1 && !script_execute(gtbp, argument0, argument1, "")) || (gbp != -1 && gtbp == -1 && !script_execute(gbp, argument0, argument1, "")) || gbp == -1)) { + var msg = argument0 + chr(13) + chr(13); + if (os_browser == browser_not_a_browser) { + show_error(msg, true); + } + else { + show_message(msg); + } + } +} + +#define __gma_assert_error_raw__ +/// @function __gma_assert_error_raw__(message, expected, got) +/// @param message The message to display to the user +/// @param expected The value expected for the assertion +/// @param got The actual received value for the assertion +{ + var gtbp = asset_get_index("__GMA_TEST_BREAKPOINT__"), + gbp = asset_get_index("__GMA_BREAKPOINT__"); + if (GMASSERT_ENABLED && ((gtbp != -1 && !script_execute(gtbp, argument0, argument2, argument1)) || (gbp != -1 && gtbp == -1 && !script_execute(gbp, argument0, argument2, argument1)) || gbp == -1)) { + var msg = argument0 + chr(13) + chr(13) + "Expected: " + argument1 + chr(13) + chr(13) + "Got: " + argument2 + chr(13) + chr(13); + if (os_browser == browser_not_a_browser) { + show_error(msg, true); + } + else { + show_message(msg); + } + } +} + +#define __gma_debug_value__ +/// @function __gma_debug_value__(val, [noprefix]) +/// @param val The value to derive a debug-friendly value from +/// @param [noprefix] Whether to skip the "(type)" header (defaults to false) +{ + var type = typeof(argument[0]); + var dv; + switch (type) { + case "number": + //Return integers as-is + if (is_infinity(argument[0])) { + dv = (argument[0] < 0) ? "-infinity" : "infinity"; + } + else if (is_nan(argument[0])) { + dv = "NaN"; + } + else if (frac(argument[0]) == 0) { + dv = string(argument[0]); + } + //Get mantissa and exponent + else { + var mantissa, exponent; + exponent = floor(log10(abs(argument[0]))); + mantissa = string_replace_all(string_format(argument[0]/power(10,exponent), 15, 14), " ", ""); + //Trim trailing zeros off mantissa + var i, ca; + i = string_length(mantissa); + do { + ca = string_char_at(mantissa, i); + i -= 1; + } until (ca != "0") + if (ca != ".") { + mantissa = string_copy(mantissa, 1, i+1); + } + else { + mantissa = string_copy(mantissa, 1, i); + } + //Add exponent except if it is zero + if (exponent != 0) { + dv = mantissa + "e" + string(exponent); + } + else { + dv = mantissa; + } + } + break; + case "string": + var str = string_replace_all(argument[0], "\\", "\\\\"); + str = string_replace_all(str, "\"", "\\\""); + str = string_replace_all(str, "\n", "\\n"); + str = string_replace_all(str, "\r", "\\r"); + str = string_replace_all(str, "\t", "\\t"); + str = string_replace_all(str, "\f", "\\f"); + str = string_replace_all(str, "\b", "\\b"); + str = string_replace_all(str, "\v", "\\v"); + str = string_replace_all(str, "\a", "\\a"); + dv = "\"" + str + "\""; + break; + case "array": + var result = "", + arr = argument[0], + size = array_length(arr); + for (var i = 0; i < size; i++) { + result += __gma_debug_value__(arr[i], true); + if (i < size-1) { + result += ", "; + } + } + dv = "[" + result + "]"; + break; + case "struct": + var strc = argument[0]; + var structType = instanceof(strc); + var __q = structType + ""; //DIRTY WORKAROUND: For squelching structType string leak in 23.1.1.118 Mac Runtime + var result = ""; + var properties = variable_struct_get_names(strc); + var size = array_length(properties); + var gotFirst = false; + for (var i = 0; i < size; i++) { + var propertyValue = variable_struct_get(strc, properties[i]); + if (is_method(propertyValue)) continue; + if (gotFirst) { + result += ", "; + } else { + gotFirst = true; + } + result += properties[i] + ": " + __gma_debug_value__(propertyValue, true); + } + if (structType == "struct") { + dv = "{" + result + "}"; + } else { + dv = structType + "({" + result + "})"; + } + break; + case "bool": + if (argument[0]) { + dv = "bool(true)"; + } else { + dv = "bool(false)"; + } + break; + case "int32": + case "int64": + dv = type + "(" + string(argument[0]) + ")"; + break; + case "ptr": + var hexchars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]; + var hex = ""; + var ptrval = int64(argument[0]); + do { + hex = hexchars[ptrval & $F] + hex; + ptrval = ptrval >> 4; + } until (ptrval == 0); + dv = "ptr($" + hex + ")"; + break; + case "undefined": + dv = "undefined"; + break; + case "method": + dv = "function(){...}"; + break; + case "null": + dv = "null"; + break; + case "unknown": + dv = "???"; + break; + case "vec3": + dv = "vec3(" + string(argument[0]) + ")"; + break; + case "vec4": + dv = "vec4(" + string(argument[0]) + ")"; + break; + } + if (argument_count > 1 && argument[1]) { + return dv; + } + return "(" + type + ")" + chr(13)+chr(10) + dv; +} + +#define __gma_debug_list_value__ +/// @function __gma_debug_list_value__(val) +/// @param val The value to derive a debug-friendly value from +{ + //Return list() if it does not exist + if (!(is_real(argument0) || is_int32(argument0) || is_int64(argument0)) || !ds_exists(argument0, ds_type_list)) { + return "list()"; + } + //Return list(entry1, entry2, ..., entry n) if it exists + var content = "", + siz = ds_list_size(argument0); + for (var i = 0; i < siz; i++) { + content += __gma_debug_value__(argument0[| i], true); + if (i < siz-1) { + content += ", "; + } + } + return "list(" + content + ")"; +} + +#define __gma_debug_grid_value__ +/// @function __gma_debug_grid_value__(val) +/// @param val The value to derive a debug-friendly value from +{ + //Return grid() if it does not exist + if (!(is_real(argument0) || is_int32(argument0) || is_int64(argument0)) || !ds_exists(argument0, ds_type_grid)) { + return "grid()"; + } + //Return grid(a, b, c; d, e, f; ...) + var content = ""; + var width = ds_grid_width(argument0); + var height = ds_grid_height(argument0); + for (var yy = 0; yy < height; ++yy) { + if (yy > 0) content += "; "; + for (var xx = 0; xx < width; ++xx) { + if (xx > 0) content += ", "; + content += __gma_debug_value__(argument0[# xx, yy], true); + } + } + return "grid(" + content + ")"; +} + +#define __gma_debug_map_value__ +/// @function __gma_debug_map_value__(val) +/// @param val The value to derive a debug-friendly value from +{ + //Return map() if it does not exist + if (!(is_real(argument0) || is_int32(argument0) || is_int64(argument0)) || !ds_exists(argument0, ds_type_map)) { + return "map()"; + } + //Return map(key0: value0, key1: value1, ..., keyN: valueN) if it exists + var content = ""; + var firstEntry = true; + for (var k = ds_map_find_first(argument0); !is_undefined(k); k = ds_map_find_next(argument0, k)) { + if (firstEntry) { + firstEntry = false; + } else { + content += ", "; + } + content += __gma_debug_value__(k, true) + ": " + __gma_debug_value__(argument0[? k], true); + } + return "map(" + content + ")"; +} + +#define __gma_debug_struct_value__ +/// @function __gma_debug_struct_value__(val) +/// @param val The value to derive a debug-friendly value from +/// @description Return a detailed debug value of the given struct, including methods (which __gma_debug_value__ omits) +{ + //Fall back to __gma_debug_value__ if not a struct + if (!is_struct(argument0)) return __gma_debug_value__(argument0, true); + //Determine correct opening and closing + var strc = argument[0]; + var structType = instanceof(strc); + var __q = structType + ""; //DIRTY WORKAROUND: For squelching structType string leak in 23.1.1.118 Mac Runtime + //Grab properties + var properties = variable_struct_get_names(strc); + var size = array_length(properties); + var result = ""; + for (var i = 0; i < size; i++) { + if (i > 0) { + result += ", "; + } + result += properties[i] + ": " + __gma_debug_value__(variable_struct_get(strc, properties[i]), true); + } + //Return combined result + if (structType == "struct") { + return "{" + result + "}"; + } + return structType + "({" + result + "})"; +} + +#define __gma_equal__ +/// @function __gma_equal__(got, expected) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +{ + var type = typeof(argument0); + if (type == typeof(argument1)) { + switch (type) { + case "array": + var size = array_length(argument0); + if (size != array_length(argument1)) return false; + for (var i = 0; i < size; i++) { + if (!__gma_equal__(argument0[@ i], argument1[@ i])) return false; + } + return true; + break; + case "struct": + var size = variable_struct_names_count(argument0); + if (size != variable_struct_names_count(argument1)) return false; + var kn = variable_struct_get_names(argument0); + for (var i = 0; i < size; ++i) { + var k = kn[i]; + if (!variable_struct_exists(argument1, k) || !__gma_equal__(variable_struct_get(argument0, k), variable_struct_get(argument1, k))) return false; + } + return true; + break; + default: + return argument0 == argument1; + break; + } + } + else { + return false; + } +} + +#define __gma_equalish__ +/// @function __gma_equalish__(got, expected) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +{ + var type = typeof(argument0); + if (type == typeof(argument1)) { + switch (type) { + case "array": + var size = array_length(argument0); + if (size != array_length(argument1)) return false; + for (var i = 0; i < size; i++) { + if (!__gma_equalish__(argument0[@ i], argument1[@ i])) return false; + } + return true; + break; + case "struct": + var size = variable_struct_names_count(argument0); + if (size != variable_struct_names_count(argument1)) return false; + var kn = variable_struct_get_names(argument0); + for (var i = 0; i < size; ++i) { + var k = kn[i]; + if (!variable_struct_exists(argument1, k) || !__gma_equalish__(variable_struct_get(argument0, k), variable_struct_get(argument1, k))) return false; + } + return true; + break; + case "number": + return argument0 == argument1 || abs(argument0-argument1) <= GMASSERT_TOLERANCE; + break; + default: + return argument0 == argument1; + break; + } + } + else { + return false; + } +} + +#define __gma_greater_than__ +/// @function __gma_greater_than__(got, expected) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +{ + var type = typeof(argument0); + if (type == typeof(argument1)) { + switch (type) { + case "number": + return argument0 > argument1; + break; + case "string": + if (argument0 == argument1) return false; + var len0 = string_length(argument0), + len1 = string_length(argument1), + len = min(len0, len1); + var c0, c1; + for (var i = 1; i <= len; i++) { + c0 = ord(string_char_at(argument0, i)); + c1 = ord(string_char_at(argument1, i)); + if (c0 != c1) { + return c0 > c1; + } + } + return len0 > len1; + break; + case "array": + var size = array_length(argument0); + if (size != array_length(argument1)) return false; + for (var i = 0; i < size; i++) { + if (!__gma_greater_than__(argument0[@ i], argument1[@ i])) return false; + } + return true; + break; + case "struct": + var size = variable_struct_names_count(argument0); + if (size != variable_struct_names_count(argument1)) return false; + var kn = variable_struct_get_names(argument0); + for (var i = 0; i < size; ++i) { + var k = kn[i]; + if (!variable_struct_exists(argument1, k) || !__gma_greater_than__(variable_struct_get(argument0, k), variable_struct_get(argument1, k))) return false; + } + return true; + break; + default: + return false; + break; + } + } + else { + return false; + } +} + +#define __gma_less_than__ +/// @function __gma_less_than__(got, expected) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +{ + var type = typeof(argument0); + if (type == typeof(argument1)) { + switch (type) { + case "number": + return argument0 < argument1; + break; + case "string": + if (argument0 == argument1) return false; + var len0 = string_length(argument0), + len1 = string_length(argument1), + len = min(len0, len1); + var c0, c1; + for (var i = 1; i <= len; i++) { + c0 = ord(string_char_at(argument0, i)); + c1 = ord(string_char_at(argument1, i)); + if (c0 != c1) { + return c0 < c1; + } + } + return len0 < len1; + break; + case "array": + var size = array_length(argument0); + if (size != array_length(argument1)) return false; + for (var i = 0; i < size; i++) { + if (!__gma_less_than__(argument0[@ i], argument1[@ i])) return false; + } + return true; + break; + case "struct": + var size = variable_struct_names_count(argument0); + if (size != variable_struct_names_count(argument1)) return false; + var kn = variable_struct_get_names(argument0); + for (var i = 0; i < size; ++i) { + var k = kn[i]; + if (!variable_struct_exists(argument1, k) || !__gma_less_than__(variable_struct_get(argument0, k), variable_struct_get(argument1, k))) return false; + } + return true; + break; + default: + return false; + break; + } + } + else { + return false; + } +} + +#define __gma_greater_than_or_equal__ +/// @function __gma_greater_than_or_equal__(got, expected) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +{ + var type = typeof(argument0); + if (type == typeof(argument1)) { + switch (type) { + case "number": + return argument0 >= argument1; + break; + case "string": + if (argument0 == argument1) return true; + var len0 = string_length(argument0), + len1 = string_length(argument1), + len = min(len0, len1); + var c0, c1; + for (var i = 1; i <= len; i++) { + c0 = ord(string_char_at(argument0, i)); + c1 = ord(string_char_at(argument1, i)); + if (c0 != c1) { + return c0 > c1; + } + } + return len0 > len1; + break; + case "array": + var size = array_length(argument0); + if (size != array_length(argument1)) return false; + for (var i = 0; i < size; i++) { + if (!__gma_greater_than_or_equal__(argument0[@ i], argument1[@ i])) return false; + } + return true; + break; + case "struct": + var size = variable_struct_names_count(argument0); + if (size != variable_struct_names_count(argument1)) return false; + var kn = variable_struct_get_names(argument0); + for (var i = 0; i < size; ++i) { + var k = kn[i]; + if (!variable_struct_exists(argument1, k) || !__gma_greater_than_or_equal__(variable_struct_get(argument0, k), variable_struct_get(argument1, k))) return false; + } + return true; + break; + default: + return false; + break; + } + } + else { + return false; + } +} + +#define __gma_less_than_or_equal__ +/// @function __gma_less_than_or_equal__(got, expected) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +{ + var type = typeof(argument0); + if (type == typeof(argument1)) { + switch (type) { + case "number": + return argument0 <= argument1; + break; + case "string": + if (argument0 == argument1) return true; + var len0 = string_length(argument0), + len1 = string_length(argument1), + len = min(len0, len1); + var c0, c1; + for (var i = 1; i <= len; i++) { + c0 = ord(string_char_at(argument0, i)); + c1 = ord(string_char_at(argument1, i)); + if (c0 != c1) { + return c0 < c1; + } + } + return len0 < len1; + break; + case "array": + var size = array_length(argument0); + if (size != array_length(argument1)) return false; + for (var i = 0; i < size; i++) { + if (!__gma_less_than_or_equal__(argument0[@ i], argument1[@ i])) return false; + } + return true; + break; + case "struct": + var size = variable_struct_names_count(argument0); + if (size != variable_struct_names_count(argument1)) return false; + var kn = variable_struct_get_names(argument0); + for (var i = 0; i < size; ++i) { + var k = kn[i]; + if (!variable_struct_exists(argument1, k) || !__gma_less_than_or_equal__(variable_struct_get(argument0, k), variable_struct_get(argument1, k))) return false; + } + return true; + break; + default: + return false; + break; + } + } + else { + return false; + } +} + +#define assert +/// @function assert(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is true. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!argument[0]) { + __gma_assert_error_simple__(msg, argument[0]); + } +} + +#define assert_fail +/// @function assert_fail(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is false. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Assertion didn't fail!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (argument[0]) { + __gma_assert_error_simple__(msg, argument[0]); + } +} + +#define assert_operation +/// @function assert_operation(got, expected, op, invert, [msg], [debug_got], [debug_expected]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param op A script taking the gotten value and the expected as arguments and returning true/false +/// @param invert Whether to invert the result returned by op +/// @param [msg] (optional) +/// @param [debug_got] (optional) +/// @param [debug_expected] (optional) +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg = "Assertion Failed!", + debug_got = undefined, + debug_expected = undefined; + switch (argument_count) { + case 7: + debug_expected = argument[6]; + case 6: + debug_got = argument[5]; + case 5: + msg = argument[4]; + case 4: + break; + default: + show_error("Expected 4-7 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!(argument[3] ^^ script_execute(argument[2], argument[0], argument[1]))) { + // + var debug_value_expected, debug_value_got; + if (is_undefined(debug_expected)) { + debug_value_expected = __gma_debug_value__(argument[1]); + } else if (is_string(debug_expected)) { + debug_value_expected = debug_expected; + } else { + debug_value_expected = script_execute(debug_expected, argument[1]) + } + if (is_undefined(debug_got)) { + debug_value_got = __gma_debug_value__(argument[0]); + } else { + debug_value_got = script_execute(debug_got, argument[0]); + } + __gma_assert_error_raw__(msg, debug_value_expected, debug_value_got); + } +} + +#define assert_equal +/// @function assert_equal(got, expected, [msg]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is equal to the expected expression. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Equal assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!__gma_equal__(argument[0], argument[1])) { + __gma_assert_error__(msg, argument[1], argument[0]); + } +} + +#define assert_equalish +/// @function assert_equalish(got, expected, [msg]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is approximately equal to the expected expression. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Equalish assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!__gma_equalish__(argument[0], argument[1])) { + __gma_assert_error__(msg, argument[1], argument[0]); + } +} + +#define assert_is +/// @function assert_is(got, expected, [msg]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is exactly equal to the expected expression (as compared using ==). +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Equal assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (typeof(argument[0]) != typeof(argument[1]) || argument[0] != argument[1]) { + __gma_assert_error__(msg, argument[1], argument[0]); + } +} + +#define assert_not_equal +/// @function assert_not_equal(got, expected, [msg]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is not equal to the expected expression. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Not equal assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (__gma_equal__(argument[0], argument[1])) { + __gma_assert_error__(msg, argument[1], argument[0]); + } +} + +#define assert_not_equalish +/// @function assert_not_equalish(got, expected, [msg]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is not approximately equal to the expected expression. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Not equalish assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (__gma_equalish__(argument[0], argument[1])) { + __gma_assert_error__(msg, argument[1], argument[0]); + } +} + +#define assert_isnt +/// @function assert_isnt(got, expected, [msg]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is not exactly equal to the expected expression (as compared using ==). +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Not equal assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (typeof(argument[0]) == typeof(argument[1]) && argument[0] == argument[1]) { + __gma_assert_error__(msg, argument[1], argument[0]); + } +} + +#define assert_greater_than +/// @function assert_greater_than(got, expected, [msg]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is greater than the expected expression. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Greater than assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!__gma_greater_than__(argument[0], argument[1])) { + switch (typeof(argument[1])) { + case "number": + __gma_assert_error_raw__(msg, "A real value greater than " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + case "string": + __gma_assert_error_raw__(msg, "A string that comes after " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + case "array": + __gma_assert_error_raw__(msg, "An array with pairwise values all greater than " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + default: + __gma_assert_error__(msg + " (unsupported type)", argument[1], argument[0]); + break; + } + } +} + +#define assert_less_than +/// @function assert_less_than(got, expected, [msg]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is less than the expected expression. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Less than assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!__gma_less_than__(argument[0], argument[1])) { + switch (typeof(argument[1])) { + case "number": + __gma_assert_error_raw__(msg, "A real value less than " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + case "string": + __gma_assert_error_raw__(msg, "A string that comes before " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + case "array": + __gma_assert_error_raw__(msg, "An array with pairwise values all less than " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + default: + __gma_assert_error__(msg + " (unsupported type)", argument[1], argument[0]); + break; + } + } +} + +#define assert_greater_than_or_equal +/// @function assert_greater_than_or_equal(got, expected, [msg]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is greater than or equal to the expected expression. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Greater than or equal assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!__gma_greater_than_or_equal__(argument[0], argument[1])) { + switch (typeof(argument[1])) { + case "number": + __gma_assert_error_raw__(msg, "A real value greater than or equal to " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + case "string": + __gma_assert_error_raw__(msg, "A string that comes after or is " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + case "array": + __gma_assert_error_raw__(msg, "An array with pairwise values all greater than or equal to " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + default: + __gma_assert_error__(msg + " (unsupported type)", argument[1], argument[0]); + break; + } + } +} + +#define assert_less_than_or_equal +/// @function assert_less_than_or_equal(got, expected, [msg]) +/// @param got The actual received value for the assertion +/// @param expected The value expected for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is less than or equal to the expected expression. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Less than or equal assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!__gma_less_than_or_equal__(argument[0], argument[1])) { + switch (typeof(argument[1])) { + case "number": + __gma_assert_error_raw__(msg, "A real value less than or equal to " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + case "string": + __gma_assert_error_raw__(msg, "A string that comes before or is " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + case "array": + __gma_assert_error_raw__(msg, "An array with pairwise values all less than or equal " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + break; + default: + __gma_assert_error__(msg + " (unsupported type)", argument[1], argument[0]); + break; + } + } +} + +#define assert_is_string +/// @function assert_is_string(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is a string. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "String type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!is_string(argument[0])) { + __gma_assert_error_raw__(msg, "Any string", __gma_debug_value__(argument[0])); + } +} + +#define assert_is_real +/// @function assert_is_real(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is a real number. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Real type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!is_real(argument[0])) { + __gma_assert_error_raw__(msg, "Any real value", __gma_debug_value__(argument[0])); + } +} + +#define assert_is_array +/// @function assert_is_array(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is an array. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Array type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!is_array(argument[0])) { + __gma_assert_error_raw__(msg, "Any array", __gma_debug_value__(argument[0])); + } +} + +#define assert_is_defined +/// @function assert_is_defined(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is not undefined. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Defined type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (is_undefined(argument[0])) { + __gma_assert_error_raw__(msg, "Anything but undefined", __gma_debug_value__(argument[0])); + } +} + +#define assert_is_undefined +/// @function assert_is_undefined(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is undefined. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Undefined type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!is_undefined(argument[0])) { + __gma_assert_error_raw__(msg, "undefined", __gma_debug_value__(argument[0])); + } +} + +#define assert_isnt_string +/// @function assert_isnt_string(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is not a string. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Non-string type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (is_string(argument[0])) { + __gma_assert_error_raw__(msg, "Anything but a string", __gma_debug_value__(argument[0])); + } +} + +#define assert_isnt_real +/// @function assert_isnt_real(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is not a real number. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Non-real type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (is_real(argument[0])) { + __gma_assert_error_raw__(msg, "Anything but a real value", __gma_debug_value__(argument[0])); + } +} + +#define assert_isnt_array +/// @function assert_isnt_array(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is not an array. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Non-array type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (is_array(argument[0])) { + __gma_assert_error_raw__(msg, "Anything but an array", __gma_debug_value__(argument[0])); + } +} + +#define assert_isnt_defined +/// @function assert_isnt_defined(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is undefined. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Undefined type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!is_undefined(argument[0])) { + __gma_assert_error_raw__(msg, "undefined", __gma_debug_value__(argument[0])); + } +} + +#define assert_isnt_undefined +/// @function assert_isnt_undefined(got, [msg]) +/// @param got The actual received value for the assertion +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is not undefined. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Defined type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (is_undefined(argument[0])) { + __gma_assert_error_raw__(msg, "Anything but undefined", __gma_debug_value__(argument[0])); + } +} + +#define assert_in_range +/// @function assert_in_range(got, lower, upper, [msg]) +/// @param got The actual received value for the assertion +/// @param lower The lower bound of the range (inclusive) +/// @param upper The upper bound of the range (inclusive) +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is within the inclusive range between lower and upper. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 3: + msg = "In-range assertion failed!"; + break; + case 4: + msg = argument[3]; + break; + default: + show_error("Expected 3 or 4 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check types + switch (typeof(argument[1])) { + case "number": + case "string": + case "array": + break; + default: + msg += " (invalid lower bound type)"; + __gma_assert_error_raw__(msg, "A real value, string or array", __gma_debug_value__(argument[1])); + exit; + } + if (typeof(argument[1]) != typeof(argument[2])) { + switch (typeof(argument[1])) { + case "number": + __gma_assert_error__(msg + " (mismatched range types)", "A real value for the upper bound", __gma_debug_value__(argument[2])); + break; + case "string": + __gma_assert_error__(msg + " (mismatched range types)", "A string for the upper bound", __gma_debug_value__(argument[2])); + break; + case "array": + __gma_assert_error__(msg + " (mismatched range types)", "An array for the upper bound", __gma_debug_value__(argument[2])); + break; + default: + msg += " (invalid lower bound type)"; + __gma_assert_error_raw__(msg, "A real value, string or array", __gma_debug_value__(argument[1])); + break; + } + exit; + } + //Check assertion + if (!(__gma_less_than_or_equal__(argument[0], argument[2]) && __gma_less_than_or_equal__(argument[1], argument[0]))) { + switch (typeof(argument[1])) { + case "number": + __gma_assert_error_raw__(msg, "A real value between " + __gma_debug_value__(argument[1]) + " and " + __gma_debug_value__(argument[2]), __gma_debug_value__(argument[0])); + break; + case "string": + __gma_assert_error_raw__(msg, "A string that lies between " + __gma_debug_value__(argument[1]) + " and " + __gma_debug_value__(argument[2]), __gma_debug_value__(argument[0])); + break; + case "array": + __gma_assert_error_raw__(msg, "An array with pairwise values all between " + __gma_debug_value__(argument[1]) + " and " + __gma_debug_value__(argument[2]), __gma_debug_value__(argument[0])); + break; + default: + __gma_assert_error_raw__(msg + " (unsupported type)", "A value comparable to " + __gma_debug_value__(argument[1]) + " and " + __gma_debug_value__(argument[2]), __gma_debug_value__(argument[0])); + break; + } + } +} + +#define assert_not_in_range +/// @function assert_not_in_range(got, lower, upper, [msg]) +/// @param got The actual received value for the assertion +/// @param lower The lower bound of the range (inclusive) +/// @param upper The upper bound of the range (inclusive) +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten expression is not within the inclusive range between lower and upper. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 3: + msg = "Out-of-range assertion failed!"; + break; + case 4: + msg = argument[3]; + break; + default: + show_error("Expected 3 or 4 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check types + switch (typeof(argument[1])) { + case "number": + case "string": + case "array": + break; + default: + msg += " (invalid lower bound type)"; + __gma_assert_error_raw__(msg, "A real value, string or array", __gma_debug_value__(argument[1])); + exit; + } + if (typeof(argument[1]) != typeof(argument[2])) { + switch (typeof(argument[1])) { + case "number": + __gma_assert_error__(msg + " (mismatched range types)", "A real value for the upper bound", __gma_debug_value__(argument[2])); + break; + case "string": + __gma_assert_error__(msg + " (mismatched range types)", "A string for the upper bound", __gma_debug_value__(argument[2])); + break; + case "array": + __gma_assert_error__(msg + " (mismatched range types)", "An array for the upper bound", __gma_debug_value__(argument[2])); + break; + default: + msg += " (invalid lower bound type)"; + __gma_assert_error_raw__(msg, "A real value, string or array", __gma_debug_value__(argument[1])); + break; + } + exit; + } + //Check assertion + if (__gma_less_than_or_equal__(argument[0], argument[2]) && __gma_less_than_or_equal__(argument[1], argument[0])) { + switch (typeof(argument[1])) { + case "number": + __gma_assert_error_raw__(msg, "A real value not between " + __gma_debug_value__(argument[1]) + " and " + __gma_debug_value__(argument[2]), __gma_debug_value__(argument[0])); + break; + case "string": + __gma_assert_error_raw__(msg, "A string that does not lie between " + __gma_debug_value__(argument[1]) + " and " + __gma_debug_value__(argument[2]), __gma_debug_value__(argument[0])); + break; + case "array": + __gma_assert_error_raw__(msg, "An array with pairwise values all not between " + __gma_debug_value__(argument[1]) + " and " + __gma_debug_value__(argument[2]), __gma_debug_value__(argument[0])); + break; + default: + __gma_assert_error_raw__(msg + " (unsupported type)", "A value comparable to " + __gma_debug_value__(argument[1]) + " and " + __gma_debug_value__(argument[2]), __gma_debug_value__(argument[0])); + break; + } + } +} + +#define assert_contains +/// @function assert_contains(got, content, [msg]); +/// @param got The actual received value for the assertion +/// @param content A value to look for in the received value +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten string, list or array contains a value equal to content. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Inclusion assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check types and assertion + var found = false; + switch (typeof(argument[0])) { + case "string": + if (typeof(argument[1]) == "string") { + if (string_pos(argument[1], argument[0]) == 0) { + __gma_assert_error_raw__(msg, "A string that contains " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + } + else { + msg += " (invalid content type)"; + __gma_assert_error_raw__(msg, "A string", __gma_debug_value__(argument[1])); + } + break; + case "array": + var arr = argument[0]; + var size = array_length(arr); + for (var i = 0; i < size; i++) { + if (__gma_equal__(argument[1], arr[i])) { + found = true; + break; + } + } + if (!found) { + __gma_assert_error_raw__(msg, "An array that contains " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + break; + case "number": case "int32": case "int64": + if (ds_exists(argument[0], ds_type_list)) { + var list = argument[0], + size = ds_list_size(list); + for (var i = 0; i < size; i++) { + if (__gma_equal__(argument[1], list[| i])) { + found = true; + break; + } + } + if (!found) { + __gma_assert_error_raw__(msg, "A list that contains " + __gma_debug_value__(argument[1]), __gma_debug_list_value__(argument[0])); + } + } + else { + msg += " (list ID does not exist)"; + __gma_assert_error_raw__(msg, "An existent list ID", __gma_debug_value__(argument[0])); + } + break; + default: + msg += " (invalid container type)"; + __gma_assert_error_raw__(msg, "A string, array or list", __gma_debug_value__(argument[0])); + break; + } +} + +#define assert_contains_exact +/// @function assert_contains_exact(got, content, [msg]); +/// @param got The actual received value for the assertion +/// @param content A value to look for in the received value +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten string, list or array contains a value exactly equal to content (as compared using ==). +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Exact inclusion assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check types and assertion + var found = false; + switch (typeof(argument[0])) { + case "string": + if (typeof(argument[1]) == "string") { + if (string_pos(argument[1], argument[0]) == 0) { + __gma_assert_error_raw__(msg, "A string that contains exactly " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + } + else { + msg += " (invalid content type)"; + __gma_assert_error_raw__(msg, "A string", __gma_debug_value__(argument[1])); + } + break; + case "array": + var arr = argument[0]; + var size = array_length(arr); + for (var i = 0; i < size; i++) { + if (typeof(argument[1]) == typeof(arr[i]) && argument[1] == arr[i]) { + found = true; + break; + } + } + if (!found) { + __gma_assert_error_raw__(msg, "An array that contains exactly " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + break; + case "number": case "int32": case "int64": + if (ds_exists(argument[0], ds_type_list)) { + var list = argument[0], + size = ds_list_size(list); + for (var i = 0; i < size; i++) { + if (typeof(argument[1]) == typeof(list[| i]) && argument[1] == list[| i]) { + found = true; + break; + } + } + if (!found) { + __gma_assert_error_raw__(msg, "A list that contains exactly " + __gma_debug_value__(argument[1]), __gma_debug_list_value__(argument[0])); + } + } + else { + msg += " (list ID does not exist)"; + __gma_assert_error_raw__(msg, "An existent list ID", __gma_debug_value__(argument[0])); + } + break; + default: + msg += " (invalid container type)"; + __gma_assert_error_raw__(msg, "A string, array or list", __gma_debug_value__(argument[0])); + break; + } +} + +#define assert_doesnt_contain +/// @function assert_doesnt_contain(got, content, [msg]); +/// @param got The actual received value for the assertion +/// @param content A value to look for in the received value +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten string, list or array does not contain a value equal to content. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Exclusion assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check types and assertion + var found = false; + switch (typeof(argument[0])) { + case "string": + if (typeof(argument[1]) == "string") { + if (string_pos(argument[1], argument[0]) > 0) { + __gma_assert_error_raw__(msg, "A string that does not contain " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + } + else { + msg += " (invalid content type)"; + __gma_assert_error_raw__(msg, "A string", __gma_debug_value__(argument[1])); + } + break; + case "array": + var arr = argument[0]; + var size = array_length(arr); + for (var i = 0; i < size; i++) { + if (__gma_equal__(argument[1], arr[i])) { + found = true; + break; + } + } + if (found) { + __gma_assert_error_raw__(msg, "An array that does not contain " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + break; + case "number": case "int32": case "int64": + if (ds_exists(argument[0], ds_type_list)) { + var list = argument[0], + size = ds_list_size(list); + for (var i = 0; i < size; i++) { + if (__gma_equal__(argument[1], list[| i])) { + found = true; + break; + } + } + if (found) { + __gma_assert_error_raw__(msg, "A list that does not contain " + __gma_debug_value__(argument[1]), __gma_debug_list_value__(argument[0])); + } + } + else { + msg += " (list ID does not exist)"; + __gma_assert_error_raw__(msg, "An existent list ID", __gma_debug_value__(argument[0])); + } + break; + default: + msg += " (invalid container type)"; + __gma_assert_error_raw__(msg, "A string, array or list", __gma_debug_value__(argument[0])); + break; + } +} + +#define assert_doesnt_contain_exact +/// @function assert_doesnt_contain_exact(got, content, [msg]); +/// @param got The actual received value for the assertion +/// @param content A value to look for in the received value +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten string, list or array does not contain a value exactly equal to content (as compared using ==). +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Exact exclusion assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check types and assertion + var found = false; + switch (typeof(argument[0])) { + case "string": + if (typeof(argument[1]) == "string") { + if (string_pos(argument[1], argument[0]) > 0) { + __gma_assert_error_raw__(msg, "A string that does not contain exactly " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + } + else { + msg += " (invalid content type)"; + __gma_assert_error_raw__(msg, "A string", __gma_debug_value__(argument[1])); + } + break; + case "array": + var arr = argument[0]; + var size = array_length(arr); + for (var i = 0; i < size; i++) { + if (typeof(argument[1]) == typeof(arr[i]) && argument[1] == arr[i]) { + found = true; + break; + } + } + if (found) { + __gma_assert_error_raw__(msg, "An array that eoes not contain exactly " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + break; + case "number": case "int32": case "int64": + if (ds_exists(argument[0], ds_type_list)) { + var list = argument[0], + size = ds_list_size(list); + for (var i = 0; i < size; i++) { + if (typeof(argument[1]) == typeof(list[| i]) && argument[1] == list[| i]) { + found = true; + break; + } + } + if (found) { + __gma_assert_error_raw__(msg, "A list that does not contain exactly " + __gma_debug_value__(argument[1]), __gma_debug_list_value__(argument[0])); + } + } + else { + msg += " (list ID does not exist)"; + __gma_assert_error_raw__(msg, "An existent list ID", __gma_debug_value__(argument[0])); + } + break; + default: + msg += " (invalid container type)"; + __gma_assert_error_raw__(msg, "A string, array or list", __gma_debug_value__(argument[0])); + break; + } +} + +#define assert_contains_2d +/// @function assert_contains_2d(got, content, [msg]); +/// @param got The actual received value for the assertion +/// @param content A value to look for in the received value +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten grid or 2D array contains a value equal to content. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "2D inclusion assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check types and assertion + var found = false; + switch (typeof(argument[0])) { + case "array": + var arr = argument[0]; + var size_i = array_length(arr); + for (var i = 0; i < size_i && !found; i++) { + var size_j = array_length(arr[i]); + for (var j = 0; j < size_j; j++) { + if (__gma_equal__(argument[1], arr[i][j])) { + found = true; + break; + } + } + } + if (!found) { + __gma_assert_error_raw__(msg, "A 2D array that contains " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + break; + case "number": case "int32": case "int64": + if (ds_exists(argument[0], ds_type_grid)) { + var grid = argument[0], + size_i = ds_grid_width(grid), + size_j = ds_grid_height(grid); + for (var i = 0; i < size_i && !found; i++) { + for (var j = 0; j < size_j; j++) { + if (__gma_equal__(argument[1], grid[# i, j])) { + found = true; + break; + } + } + } + if (!found) { + __gma_assert_error_raw__(msg, "A grid that contains " + __gma_debug_value__(argument[1]), __gma_debug_grid_value__(argument[0])); + } + } + else { + msg += " (grid ID does not exist)"; + __gma_assert_error_raw__(msg, "An existent grid ID", __gma_debug_value__(argument[0])); + } + break; + default: + msg += " (invalid container type)"; + __gma_assert_error_raw__(msg, "A grid or 2D array", __gma_debug_value__(argument[0])); + break; + } +} + +#define assert_contains_exact_2d +/// @function assert_contains_exact_2d(got, content, [msg]); +/// @param got The actual received value for the assertion +/// @param content A value to look for in the received value +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten grid or 2D array contains a value equal to content, as compared using ==. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Exact 2D inclusion assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check types and assertion + var found = false; + switch (typeof(argument[0])) { + case "array": + var arr = argument[0]; + var size_i = array_length(arr); + for (var i = 0; i < size_i && !found; i++) { + var size_j = array_length(arr[i]); + for (var j = 0; j < size_j; j++) { + if (argument[1] == arr[i][j]) { + found = true; + break; + } + } + } + if (!found) { + __gma_assert_error_raw__(msg, "A 2D array that contains " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + break; + case "number": case "int32": case "int64": + if (ds_exists(argument[0], ds_type_grid)) { + var grid = argument[0], + size_i = ds_grid_width(grid), + size_j = ds_grid_height(grid); + for (var i = 0; i < size_i && !found; i++) { + for (var j = 0; j < size_j; j++) { + if (argument[1] == grid[# i, j]) { + found = true; + break; + } + } + } + if (!found) { + __gma_assert_error_raw__(msg, "A grid that contains " + __gma_debug_value__(argument[1]), __gma_debug_grid_value__(argument[0])); + } + } + else { + msg += " (grid ID does not exist)"; + __gma_assert_error_raw__(msg, "An existent grid ID", __gma_debug_value__(argument[0])); + } + break; + default: + msg += " (invalid container type)"; + __gma_assert_error_raw__(msg, "A grid or 2D array", __gma_debug_value__(argument[0])); + break; + } +} + +#define assert_doesnt_contain_2d +/// @function assert_doesnt_contain_2d(got, content, [msg]); +/// @param got The actual received value for the assertion +/// @param content A value to look for in the received value +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten grid or 2D array doesn't contain a value equal to content. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "2D non-inclusion assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check types and assertion + var found = false; + switch (typeof(argument[0])) { + case "array": + var arr = argument[0]; + var size_i = array_length(arr); + for (var i = 0; i < size_i && !found; i++) { + var size_j = array_length(arr[i]); + for (var j = 0; j < size_j; j++) { + if (__gma_equal__(argument[1], arr[i][j])) { + found = true; + break; + } + } + } + if (found) { + __gma_assert_error_raw__(msg, "A 2D array that doesn't contain " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + break; + case "number": case "int32": case "int64": + if (ds_exists(argument[0], ds_type_grid)) { + var grid = argument[0], + size_i = ds_grid_width(grid), + size_j = ds_grid_height(grid); + for (var i = 0; i < size_i && !found; i++) { + for (var j = 0; j < size_j; j++) { + if (__gma_equal__(argument[1], grid[# i, j])) { + found = true; + break; + } + } + } + if (found) { + __gma_assert_error_raw__(msg, "A grid that doesn't contain " + __gma_debug_value__(argument[1]), __gma_debug_grid_value__(argument[0])); + } + } + else { + msg += " (grid ID does not exist)"; + __gma_assert_error_raw__(msg, "An existent grid ID", __gma_debug_value__(argument[0])); + } + break; + default: + msg += " (invalid container type)"; + __gma_assert_error_raw__(msg, "A grid or 2D array", __gma_debug_value__(argument[0])); + break; + } +} + +#define assert_doesnt_contain_exact_2d +/// @function assert_doesnt_contain_exact_2d(got, content, [msg]); +/// @param got The actual received value for the assertion +/// @param content A value to look for in the received value +/// @param [msg] (optional) A custom message to display when the assertion fails +/// @description Assert that the gotten grid or 2D array doesn't contain a value equal to content, as compared using ==. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Exact 2D non-inclusion assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check types and assertion + var found = false; + switch (typeof(argument[0])) { + case "array": + var arr = argument[0]; + var size_i = array_length(arr); + for (var i = 0; i < size_i && !found; i++) { + var size_j = array_length(arr[i]); + for (var j = 0; j < size_j; j++) { + if (argument[1] == arr[i][j]) { + found = true; + break; + } + } + } + if (found) { + __gma_assert_error_raw__(msg, "A 2D array that doesn't contain " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } + break; + case "number": case "int32": case "int64": + if (ds_exists(argument[0], ds_type_grid)) { + var grid = argument[0], + size_i = ds_grid_width(grid), + size_j = ds_grid_height(grid); + for (var i = 0; i < size_i && !found; i++) { + for (var j = 0; j < size_j; j++) { + if (argument[1] == grid[# i, j]) { + found = true; + break; + } + } + } + if (found) { + __gma_assert_error_raw__(msg, "A grid that doesn't contain " + __gma_debug_value__(argument[1]), __gma_debug_grid_value__(argument[0])); + } + } + else { + msg += " (grid ID does not exist)"; + __gma_assert_error_raw__(msg, "An existent grid ID", __gma_debug_value__(argument[0])); + } + break; + default: + msg += " (invalid container type)"; + __gma_assert_error_raw__(msg, "A grid or 2D array", __gma_debug_value__(argument[0])); + break; + } +} + +#define assert_doesnt_have_key +///@func assert_doesnt_have_key(got, key, [msg]) +///@param got The actual received value for the assertion +///@param key The key got should not have +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the given struct or map does not have the given key. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "No-key assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion (struct form) + if (is_struct(argument[0])) { + if (variable_struct_exists(argument[0], argument[1])) { + __gma_assert_error_raw__(msg, "A map or struct without key " + __gma_debug_value__(argument[1]), __gma_debug_struct_value__(argument[0])); + } + } + //Check assertion (map form) + else if (is_real(argument[0]) || is_int32(argument[0]) || is_int64(argument[0])) { + if (!ds_exists(argument[0], ds_type_map) || ds_map_exists(argument[0], argument[1])) { + __gma_assert_error_raw__(msg, "A map or struct without key " + __gma_debug_value__(argument[1]), __gma_debug_map_value__(argument[0])); + } + } + //Invalid + else { + __gma_assert_error_raw__(msg, "A map or struct without key " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } +} + +#define assert_doesnt_have_method +///@func assert_doesnt_have_method(got, methodName, [msg]) +///@param got The actual received value for the assertion +///@param methodName The method name got should not have +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the given value does not have a method of the given name. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "No-method assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!is_struct(argument[0]) || (variable_struct_exists(argument[0], argument[1]) && is_method(variable_struct_get(argument[0], argument[1])))) { + __gma_assert_error_raw__(msg, "A struct without a method named " + argument[1], __gma_debug_struct_value__(argument[0])); + } +} + +#define assert_doesnt_throw +///@func assert_doesnt_throw(func, thrown, [msg]) +///@param func The function to run (can be function or 2-array of a function plus its argument) +///@param thrown The thing that func should not throw +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the given function throws nothing or something other than the given thing. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "No-throw assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + var _func, _arg, _arg0; + var _noarg = false; + if (is_array(argument[0])) { + _arg0 = argument[0]; + _func = _arg0[0]; + _arg = _arg0[1]; + } else { + _func = argument[0]; + _noarg = true; + } + //Check assertion + try { + if (_noarg) { + _func(); + } else { + _func(_arg); + } + } catch (exc) { + if (__gma_equal__(exc, argument[1])) { + __gma_assert_error_raw__(msg, "No throw " + __gma_debug_value__(argument[1]), "throw " + __gma_debug_value__(exc)); + } + exit; + } +} + +#define assert_doesnt_throw_instance_of +///@func assert_doesnt_throw_instance_of(func, typeName, [msg]) +///@param func The function to run (can be function or 2-array of a function plus its argument) +///@param typeName The type of the thing func should not throw +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the given function doesn't throw the given type of thing. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Not-throw-type assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + var _func, _arg, _arg0; + var _noarg = false; + if (is_array(argument[0])) { + _arg0 = argument[0]; + _func = _arg0[0]; + _arg = _arg0[1]; + } else { + _func = argument[0]; + _noarg = true; + } + //Check assertion + try { + if (_noarg) { + _func(); + } else { + _func(_arg); + } + } catch (exc) { + if (typeof(exc) == argument[1] || (is_struct(exc) && instanceof(exc) == argument[1])) { + __gma_assert_error_raw__(msg, "throw type other than " + argument[1], "throw " + __gma_debug_value__(exc)); + } + exit; + } +} + +#define assert_has_key +///@func assert_has_key(got, key, [msg]) +///@param got The actual received value for the assertion +///@param key The key got should have +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the given struct or map has the given key. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Key assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion (struct form) + if (is_struct(argument[0])) { + if (!variable_struct_exists(argument[0], argument[1])) { + __gma_assert_error_raw__(msg, "A map or struct with key " + __gma_debug_value__(argument[1]), __gma_debug_struct_value__(argument[0])); + } + } + //Check assertion (map form) + else if (is_real(argument[0]) || is_int32(argument[0]) || is_int64(argument[0])) { + if (!ds_exists(argument[0], ds_type_map) || !ds_map_exists(argument[0], argument[1])) { + __gma_assert_error_raw__(msg, "A map or struct with key " + __gma_debug_value__(argument[1]), __gma_debug_map_value__(argument[0])); + } + } + //Invalid + else { + __gma_assert_error_raw__(msg, "A map or struct with key " + __gma_debug_value__(argument[1]), __gma_debug_value__(argument[0])); + } +} + +#define assert_has_method +///@func assert_has_method(got, methodName, [msg]) +///@param got The actual received value for the assertion +///@param methodName The method name got should have +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the given value has a method of the given name. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Method assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!is_struct(argument[0]) || !variable_struct_exists(argument[0], argument[1]) || !is_method(variable_struct_get(argument[0], argument[1]))) { + __gma_assert_error_raw__(msg, "A struct with a method named " + argument[1], __gma_debug_struct_value__(argument[0])); + } +} + +#define assert_is_instance_of +///@func assert_is_instance_of(got, typeName, [msg]) +///@param got The actual received value for the assertion +///@param typeName The type that the given value should have +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the given value has the given type. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Instance-of assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (typeof(argument[0]) != argument[1] && (!is_struct(argument[0]) || instanceof(argument[0]) != argument[1])) { + __gma_assert_error_raw__(msg, "Anything of type " + argument[1], __gma_debug_value__(argument[0])); + } +} + +#define assert_is_method +///@func assert_is_method(got, [msg]) +///@param got The actual received value for the assertion +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the gotten expression is a method. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Function type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!is_method(argument[0])) { + __gma_assert_error_raw__(msg, "Any method", __gma_debug_value__(argument[0])); + } +} + +#define assert_is_struct +///@func assert_is_struct(got, [msg]) +///@param got The actual received value for the assertion +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the gotten expression is a struct. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Struct type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (!is_struct(argument[0])) { + __gma_assert_error_raw__(msg, "Any struct", __gma_debug_value__(argument[0])); + } +} + +#define assert_isnt_instance_of +///@func assert_isnt_instance_of(got, typeName, [msg]) +///@param got The actual received value for the assertion +///@param typeName The type that the given value should not have +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the given value does not have the given type. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Not-instance-of assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (typeof(argument[0]) == argument[1] || (is_struct(argument[0]) && instanceof(argument[0]) == argument[1])) { + __gma_assert_error_raw__(msg, "Anything not of type " + argument[1], __gma_debug_value__(argument[0])); + } +} + +#define assert_isnt_method +///@func assert_isnt_method(got, [msg]) +///@param got The actual received value for the assertion +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the gotten expression is not a method. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Non-function type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (is_method(argument[0])) { + __gma_assert_error_raw__(msg, "Anything but a method", __gma_debug_value__(argument[0])); + } +} + +#define assert_isnt_struct +///@func assert_isnt_struct(got, [msg]) +///@param got The actual received value for the assertion +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the gotten expression is not a struct. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Non-struct type assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + //Check assertion + if (is_struct(argument[0])) { + __gma_assert_error_raw__(msg, "Anything but a struct", __gma_debug_value__(argument[0])); + } +} + +#define assert_not_throwless +///@func assert_not_throwless(func, [msg]) +///@param func The function to run (can be function or 2-array of a function plus its argument) +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the function run throws something +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Not-throwless assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + var _func, _arg, _arg0; + var _noarg = false; + if (is_array(argument[0])) { + _arg0 = argument[0]; + _func = _arg0[0]; + _arg = _arg0[1]; + } else { + _func = argument[0]; + _noarg = true; + } + //Check assertion + try { + if (_noarg) { + _func(); + } else { + _func(_arg); + } + } catch (exc) { + exit; + } + __gma_assert_error_raw__(msg, "throw something", "throw "); +} + +#define assert_throwless +///@func assert_throwless(func, [msg]) +///@param func The function to run (can be function or 2-array of a function plus its argument) +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the function run throws nothing +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 1: + msg = "Throwless assertion failed!"; + break; + case 2: + msg = argument[1]; + break; + default: + show_error("Expected 1 or 2 arguments, got " + string(argument_count) + ".", true); + break; + } + var _func, _arg, _arg0; + var _noarg = false; + if (is_array(argument[0])) { + _arg0 = argument[0]; + _func = _arg0[0]; + _arg = _arg0[1]; + } else { + _func = argument[0]; + _noarg = true; + } + //Check assertion + try { + if (_noarg) { + _func(); + } else { + _func(_arg); + } + } catch (exc) { + __gma_assert_error_raw__(msg, "throw ", "throw " + __gma_debug_value__(exc)); + } +} + +#define assert_throws +///@func assert_throws(func, thrown, [msg]) +///@param func The function to run (can be function or 2-array of a function plus its argument) +///@param thrown The thing that func should throw +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the given function throws the given thing. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Throw assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + var _func, _arg, _arg0; + var _noarg = false; + if (is_array(argument[0])) { + _arg0 = argument[0]; + _func = _arg0[0]; + _arg = _arg0[1]; + } else { + _func = argument[0]; + _noarg = true; + } + //Check assertion + try { + if (_noarg) { + _func(); + } else { + _func(_arg); + } + } catch (exc) { + if (!__gma_equal__(exc, argument[1])) { + __gma_assert_error_raw__(msg, "throw " + __gma_debug_value__(argument[1]), "throw " + __gma_debug_value__(exc)); + } + exit; + } + __gma_assert_error_raw__(msg, "throw " + __gma_debug_value__(argument[1]), "throw "); +} + +#define assert_throws_instance_of +///@func assert_throws_instance_of(func, typeName, [msg]) +///@param func The function to run (can be function or 2-array of a function plus its argument) +///@param typeName The type of the thing func should throw +///@param [msg] (optional) A custom message to display when the assertion fails +///@description Assert that the given function throws the given type of thing. +{ + if (!GMASSERT_ENABLED) exit; + //Capture message argument + var msg; + switch (argument_count) { + case 2: + msg = "Throw-type assertion failed!"; + break; + case 3: + msg = argument[2]; + break; + default: + show_error("Expected 2 or 3 arguments, got " + string(argument_count) + ".", true); + break; + } + var _func, _arg, _arg0; + var _noarg = false; + if (is_array(argument[0])) { + _arg0 = argument[0]; + _func = _arg0[0]; + _arg = _arg0[1]; + } else { + _func = argument[0]; + _noarg = true; + } + //Check assertion + try { + if (_noarg) { + _func(); + } else { + _func(_arg); + } + } catch (exc) { + if (typeof(exc) != argument[1] && (!is_struct(exc) || instanceof(exc) != argument[1])) { + __gma_assert_error_raw__(msg, "throw type " + argument[1], "throw " + __gma_debug_value__(exc)); + } + exit; + } + __gma_assert_error_raw__(msg, "throw type " + argument[1], "throw "); +} diff --git a/extensions/GMAssert/GMAssert.yy b/extensions/GMAssert/GMAssert.yy new file mode 100644 index 0000000..a2214eb --- /dev/null +++ b/extensions/GMAssert/GMAssert.yy @@ -0,0 +1,207 @@ +{ + "optionsFile": "options.json", + "options": [], + "exportToGame": true, + "supportedTargets": 144713361056071918, + "extensionVersion": "2.2.0", + "packageId": "", + "productId": "ACBD3CFF4E539AD869A0E8E3B4B022DD", + "author": "", + "date": "2019-04-18T01:48:08", + "license": "Free to use, also for commercial games.", + "description": "", + "helpfile": "", + "iosProps": true, + "tvosProps": true, + "androidProps": true, + "installdir": "", + "files": [ + {"filename":"GMAssert.gml","origname":"extensions\\GMAssert.gml","init":"","final":"","kind":2,"uncompress":false,"functions":[ + {"externalName":"__gma_assert_error__","kind":2,"help":"__gma_assert_error__(message, expected, got)","hidden":false,"returnType":2,"argCount":3,"args":[ + 1, + 2, + 2, + ],"resourceVersion":"1.0","name":"__gma_assert_error__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_assert_error_simple__","kind":2,"help":"__gma_assert_error_simple__(message, got)","hidden":false,"returnType":2,"argCount":2,"args":[ + 1, + 2, + ],"resourceVersion":"1.0","name":"__gma_assert_error_simple__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_assert_error_raw__","kind":2,"help":"__gma_assert_error_raw__(message, expected, got)","hidden":false,"returnType":2,"argCount":3,"args":[ + 1, + 2, + 2, + ],"resourceVersion":"1.0","name":"__gma_assert_error_raw__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_equal__","kind":2,"help":"__gma_equal__(got, expected)","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"__gma_equal__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_equalish__","kind":2,"help":"__gma_equalish__(got, expected)","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"__gma_equalish__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_greater_than__","kind":2,"help":"__gma_greater_than__(got, expected)","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"__gma_greater_than__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_less_than__","kind":2,"help":"__gma_less_than__(got, expected)","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"__gma_less_than__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_greater_than_or_equal__","kind":2,"help":"__gma_greater_than_or_equal__(got, expected)","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"__gma_greater_than_or_equal__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_less_than_or_equal__","kind":2,"help":"__gma_less_than_or_equal__(got, expected)","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"__gma_less_than_or_equal__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_debug_value__","kind":2,"help":"__gma_debug_value__(val, [noprefix])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"__gma_debug_value__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_debug_list_value__","kind":2,"help":"__gma_debug_list_value__(val)","hidden":false,"returnType":1,"argCount":1,"args":[ + 2, + ],"resourceVersion":"1.0","name":"__gma_debug_list_value__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert","kind":2,"help":"assert(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_fail","kind":2,"help":"assert_fail(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_fail","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_operation","kind":2,"help":"assert_operation(got, expected, op, invert, [msg], [debug_got], [debug_expected])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_operation","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_equal","kind":2,"help":"assert_equal(got, expected, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_equal","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_equalish","kind":2,"help":"assert_equalish(got, expected, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_equalish","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_is","kind":2,"help":"assert_is(got, expected, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_is","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_not_equal","kind":2,"help":"assert_not_equal(got, expected, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_not_equal","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_not_equalish","kind":2,"help":"assert_not_equalish(got, expected, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_not_equalish","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_isnt","kind":2,"help":"assert_isnt(got, expected, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_isnt","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_greater_than","kind":2,"help":"assert_greater_than(got, expected, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_greater_than","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_less_than","kind":2,"help":"assert_less_than(got, expected, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_less_than","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_greater_than_or_equal","kind":2,"help":"assert_greater_than_or_equal(got, expected, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_greater_than_or_equal","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_less_than_or_equal","kind":2,"help":"assert_less_than_or_equal(got, expected, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_less_than_or_equal","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_is_string","kind":2,"help":"assert_is_string(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_is_string","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_is_real","kind":2,"help":"assert_is_real(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_is_real","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_is_array","kind":2,"help":"assert_is_array(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_is_array","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_is_defined","kind":2,"help":"assert_is_defined(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_is_defined","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_isnt_string","kind":2,"help":"assert_isnt_string(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_isnt_string","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_isnt_real","kind":2,"help":"assert_isnt_real(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_isnt_real","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_isnt_array","kind":2,"help":"assert_isnt_array(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_isnt_array","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_isnt_defined","kind":2,"help":"assert_isnt_defined(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_isnt_defined","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_in_range","kind":2,"help":"assert_in_range(got, lower, upper, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_in_range","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_not_in_range","kind":2,"help":"assert_not_in_range(got, lower, upper, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_not_in_range","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_contains","kind":2,"help":"assert_contains(got, content, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_contains","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_contains_exact","kind":2,"help":"assert_contains_exact(got, content, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_contains_exact","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_doesnt_contain","kind":2,"help":"assert_doesnt_contain(got, content, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_doesnt_contain","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_doesnt_contain_exact","kind":2,"help":"assert_doesnt_contain_exact(got, content, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_doesnt_contain_exact","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_contains_2d","kind":2,"help":"assert_contains_2d(got, content, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_contains_2d","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_contains_exact_2d","kind":2,"help":"assert_contains_exact_2d(got, content, [msg]);","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_contains_exact_2d","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_doesnt_contain_2d","kind":2,"help":"assert_doesnt_contain_2d(got, content, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_doesnt_contain_2d","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_doesnt_contain_exact_2d","kind":2,"help":"assert_doesnt_contain_exact_2d(got, content, [msg])","hidden":false,"returnType":1,"argCount":0,"args":[],"resourceVersion":"1.0","name":"assert_doesnt_contain_exact_2d","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_is_undefined","kind":2,"help":"assert_is_undefined(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_is_undefined","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_isnt_undefined","kind":2,"help":"assert_isnt_undefined(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_isnt_undefined","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_doesnt_have_key","kind":2,"help":"assert_doesnt_have_key(got, key, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_doesnt_have_key","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_doesnt_have_method","kind":2,"help":"assert_doesnt_have_method(got, methodName, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_doesnt_have_method","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_doesnt_throw","kind":2,"help":"assert_doesnt_throw(func, thrown, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_doesnt_throw","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_doesnt_throw_instance_of","kind":2,"help":"assert_doesnt_throw_instance_of(func, typeName, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_doesnt_throw_instance_of","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_has_key","kind":2,"help":"assert_has_key(got, key, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_has_key","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_has_method","kind":2,"help":"assert_has_method(got, methodName, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_has_method","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_is_instance_of","kind":2,"help":"assert_is_instance_of(got, typeName, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_is_instance_of","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_is_method","kind":2,"help":"assert_is_method(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_is_method","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_is_struct","kind":2,"help":"assert_is_struct(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_is_struct","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_isnt_instance_of","kind":2,"help":"assert_isnt_instance_of(got, typeName, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_isnt_instance_of","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_isnt_method","kind":2,"help":"assert_isnt_method(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_isnt_method","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_isnt_struct","kind":2,"help":"assert_isnt_struct(got, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_isnt_struct","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_not_throwless","kind":2,"help":"assert_not_throwless(func, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_not_throwless","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_throwless","kind":2,"help":"assert_throwless(func, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_throwless","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_throws","kind":2,"help":"assert_throws(func, thrown, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_throws","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"assert_throws_instance_of","kind":2,"help":"assert_throws_instance_of(func, typeName, [msg])","hidden":false,"returnType":2,"argCount":-1,"args":[],"resourceVersion":"1.0","name":"assert_throws_instance_of","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_debug_grid_value__","kind":2,"help":"__gma_debug_grid_value__(val)","hidden":false,"returnType":1,"argCount":0,"args":[ + 2, + ],"resourceVersion":"1.0","name":"__gma_debug_grid_value__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_debug_map_value__","kind":2,"help":"__gma_debug_map_value__(val)","hidden":false,"returnType":1,"argCount":0,"args":[ + 2, + ],"resourceVersion":"1.0","name":"__gma_debug_map_value__","tags":[],"resourceType":"GMExtensionFunction",}, + {"externalName":"__gma_debug_struct_value__","kind":2,"help":"__gma_debug_struct_value__(val)","hidden":false,"returnType":1,"argCount":0,"args":[ + 2, + ],"resourceVersion":"1.0","name":"__gma_debug_struct_value__","tags":[],"resourceType":"GMExtensionFunction",}, + ],"constants":[],"ProxyFiles":[],"copyToTargets":9223372036854775807,"order":[ + {"name":"__gma_assert_error__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_assert_error_simple__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_assert_error_raw__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_equal__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_equalish__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_greater_than__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_less_than__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_greater_than_or_equal__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_less_than_or_equal__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_debug_value__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_debug_list_value__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_fail","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_operation","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_equal","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_equalish","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_is","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_not_equal","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_not_equalish","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_isnt","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_greater_than","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_less_than","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_greater_than_or_equal","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_less_than_or_equal","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_is_string","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_is_real","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_is_array","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_is_defined","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_isnt_string","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_isnt_real","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_isnt_array","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_isnt_defined","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_in_range","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_not_in_range","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_contains","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_contains_exact","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_doesnt_contain","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_doesnt_contain_exact","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_contains_2d","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_contains_exact_2d","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_doesnt_contain_2d","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_doesnt_contain_exact_2d","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_is_undefined","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_isnt_undefined","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_doesnt_have_key","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_doesnt_have_method","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_doesnt_throw","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_doesnt_throw_instance_of","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_has_key","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_has_method","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_is_instance_of","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_is_method","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_is_struct","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_isnt_instance_of","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_isnt_method","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_isnt_struct","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_not_throwless","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_throwless","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_throws","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"assert_throws_instance_of","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_debug_grid_value__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_debug_map_value__","path":"extensions/GMAssert/GMAssert.yy",}, + {"name":"__gma_debug_struct_value__","path":"extensions/GMAssert/GMAssert.yy",}, + ],"resourceVersion":"1.0","name":null,"tags":[],"resourceType":"GMExtensionFile",}, + ], + "classname": "", + "tvosclassname": "", + "tvosdelegatename": "", + "iosdelegatename": "", + "androidclassname": "", + "sourcedir": "", + "androidsourcedir": "", + "macsourcedir": "", + "maccompilerflags": "", + "tvosmaccompilerflags": "", + "maclinkerflags": "", + "tvosmaclinkerflags": "", + "iosplistinject": "", + "tvosplistinject": "", + "androidinject": "", + "androidmanifestinject": "", + "androidactivityinject": "", + "gradleinject": "", + "iosSystemFrameworkEntries": [], + "tvosSystemFrameworkEntries": [], + "iosThirdPartyFrameworkEntries": [], + "tvosThirdPartyFrameworkEntries": [], + "IncludedResources": [ + "Scripts\\GMAssert\\__GMA_BREAKPOINT__.gml", + ], + "androidPermissions": [], + "copyToTargets": 153720560310812910, + "iosCocoaPods": "", + "tvosCocoaPods": "", + "iosCocoaPodDependencies": "", + "tvosCocoaPodDependencies": "", + "parent": { + "name": "GMAssert", + "path": "folders/Libraries/GMAssert.yy", + }, + "resourceVersion": "1.2", + "name": "GMAssert", + "tags": [], + "resourceType": "GMExtension", +} \ No newline at end of file diff --git a/options/amazonfire/options_amazonfire.yy b/options/amazonfire/options_amazonfire.yy new file mode 100644 index 0000000..c4b6d7d --- /dev/null +++ b/options/amazonfire/options_amazonfire.yy @@ -0,0 +1,49 @@ +{ + "option_amazonfire_sync_android": false, + "option_amazonfire_display_name": "Created with GameMaker Studio 2", + "option_amazonfire_version": "1.0.0.0", + "option_amazonfire_tools_from_version": false, + "option_amazonfire_build_tools": "", + "option_amazonfire_support_lib": "", + "option_amazonfire_target_sdk": "", + "option_amazonfire_minimum_sdk": "", + "option_amazonfire_compile_sdk": "", + "option_amazonfire_package_domain": "com", + "option_amazonfire_package_company": "company", + "option_amazonfire_package_product": "game", + "option_amazonfire_orient_portrait": true, + "option_amazonfire_orient_portrait_flipped": true, + "option_amazonfire_orient_landscape": true, + "option_amazonfire_orient_landscape_flipped": true, + "option_amazonfire_gamepad_support": true, + "option_amazonfire_lint": false, + "option_amazonfire_install_location": 0, + "option_amazonfire_sleep_margin": 4, + "option_amazonfire_splash_screens_landscape": "${base_options_dir}/amazonfire/splash/landscape.png", + "option_amazonfire_splash_screens_portrait": "${base_options_dir}/amazonfire/splash/portrait.png", + "option_amazonfire_splash_time": 0, + "option_amazonfire_launchscreen_fill": 0, + "option_amazonfire_splashscreen_background_colour": 255, + "option_amazonfire_tv_banner": "${base_options_dir}/amazonfire/tv_banner.png", + "option_amazonfire_interpolate_pixels": false, + "option_amazonfire_screen_depth": 0, + "option_amazonfire_scale": 0, + "option_amazonfire_texture_page": "2048x2048", + "option_amazonfire_icon_ldpi": "${base_options_dir}/android/icons/ldpi.png", + "option_amazonfire_icon_mdpi": "${base_options_dir}/android/icons/mdpi.png", + "option_amazonfire_icon_hdpi": "${base_options_dir}/android/icons/hdpi.png", + "option_amazonfire_icon_xhdpi": "${base_options_dir}/android/icons/xhdpi.png", + "option_amazonfire_icon_xxhdpi": "${base_options_dir}/android/icons/xxhdpi.png", + "option_amazonfire_icon_xxxhdpi": "${base_options_dir}/android/icons/xxxhdpi.png", + "option_amazonfire_permission_write_external_storage": false, + "option_amazonfire_permission_read_phone_state": false, + "option_amazonfire_permission_network_state": false, + "option_amazonfire_permission_internet": true, + "option_amazonfire_permission_bluetooth": true, + "option_amazonfire_permission_record_audio": false, + "option_amazonfire_application_tag_inject": "", + "resourceVersion": "1.0", + "name": "Amazon Fire", + "tags": [], + "resourceType": "GMAmazonFireOptions", +} \ No newline at end of file diff --git a/options/android/options_android.yy b/options/android/options_android.yy new file mode 100644 index 0000000..3a0ed11 --- /dev/null +++ b/options/android/options_android.yy @@ -0,0 +1,76 @@ +{ + "option_android_sync_amazon": false, + "option_android_display_name": "Made in GameMaker Studio 2", + "option_android_version": "1.0.0.0", + "option_android_tools_from_version": false, + "option_android_build_tools": "28.0.3", + "option_android_support_lib": "28.0.0", + "option_android_target_sdk": "28", + "option_android_minimum_sdk": "16", + "option_android_compile_sdk": "28", + "option_android_package_domain": "com", + "option_android_package_company": "company", + "option_android_package_product": "game", + "option_android_arch_armv7": true, + "option_android_arch_x86": false, + "option_android_arch_arm64": false, + "option_android_arch_x86_64": false, + "option_android_orient_portrait": true, + "option_android_orient_portrait_flipped": true, + "option_android_orient_landscape": true, + "option_android_orient_landscape_flipped": true, + "option_android_gamepad_support": true, + "option_android_lint": false, + "option_android_install_location": 0, + "option_android_sleep_margin": 4, + "option_android_splash_screens_landscape": "${base_options_dir}/android/splash/landscape.png", + "option_android_splash_screens_portrait": "${base_options_dir}/android/splash/portrait.png", + "option_android_splash_time": 0, + "option_android_launchscreen_fill": 0, + "option_android_splashscreen_background_colour": 4294967295, + "option_android_tv_banner": "${base_options_dir}/android/tv_banner.png", + "option_android_interpolate_pixels": false, + "option_android_screen_depth": 0, + "option_android_device_support": 0, + "option_android_scale": 0, + "option_android_texture_page": "2048x2048", + "option_android_icon_ldpi": "${base_options_dir}/android/icons/ldpi.png", + "option_android_icon_mdpi": "${base_options_dir}/android/icons/mdpi.png", + "option_android_icon_hdpi": "${base_options_dir}/android/icons/hdpi.png", + "option_android_icon_xhdpi": "${base_options_dir}/android/icons/xhdpi.png", + "option_android_icon_xxhdpi": "${base_options_dir}/android/icons/xxhdpi.png", + "option_android_icon_xxxhdpi": "${base_options_dir}/android/icons/xxxhdpi.png", + "option_android_icon_adaptive_generate": true, + "option_android_icon_adaptive_ldpi": "${base_options_dir}/android/icons_adaptive/ldpi.png", + "option_android_icon_adaptive_mdpi": "${base_options_dir}/android/icons_adaptive/mdpi.png", + "option_android_icon_adaptive_hdpi": "${base_options_dir}/android/icons_adaptive/hdpi.png", + "option_android_icon_adaptive_xhdpi": "${base_options_dir}/android/icons_adaptive/xhdpi.png", + "option_android_icon_adaptive_xxhdpi": "${base_options_dir}/android/icons_adaptive/xxhdpi.png", + "option_android_icon_adaptive_xxxhdpi": "${base_options_dir}/android/icons_adaptive/xxxhdpi.png", + "option_android_icon_adaptivebg_ldpi": "${base_options_dir}/android/icons_adaptivebg/ldpi.png", + "option_android_icon_adaptivebg_mdpi": "${base_options_dir}/android/icons_adaptivebg/mdpi.png", + "option_android_icon_adaptivebg_hdpi": "${base_options_dir}/android/icons_adaptivebg/hdpi.png", + "option_android_icon_adaptivebg_xhdpi": "${base_options_dir}/android/icons_adaptivebg/xhdpi.png", + "option_android_icon_adaptivebg_xxhdpi": "${base_options_dir}/android/icons_adaptivebg/xxhdpi.png", + "option_android_icon_adaptivebg_xxxhdpi": "${base_options_dir}/android/icons_adaptivebg/xxxhdpi.png", + "option_android_use_facebook": false, + "option_android_facebook_id": "", + "option_android_facebook_app_display_name": "", + "option_android_google_cloud_saving": false, + "option_android_google_services_app_id": "", + "option_android_permission_write_external_storage": false, + "option_android_permission_read_phone_state": false, + "option_android_permission_network_state": false, + "option_android_permission_internet": true, + "option_android_permission_bluetooth": false, + "option_android_permission_record_audio": false, + "option_android_application_tag_inject": "", + "option_android_google_apk_expansion": false, + "option_android_google_dynamic_asset_delivery": false, + "option_android_google_licensing_public_key": "", + "option_android_tv_isgame": true, + "resourceVersion": "1.0", + "name": "Android", + "tags": [], + "resourceType": "GMAndroidOptions", +} \ No newline at end of file diff --git a/options/html5/options_html5.yy b/options/html5/options_html5.yy new file mode 100644 index 0000000..8127449 --- /dev/null +++ b/options/html5/options_html5.yy @@ -0,0 +1,34 @@ +{ + "option_html5_browser_title": "Made in GameMaker Studio 2", + "option_html5_version": "1.0.0.0", + "option_html5_foldername": "html5game", + "option_html5_outputname": "index.html", + "option_html5_splash_png": "${base_options_dir}/html5/splash.png", + "option_html5_usesplash": false, + "option_html5_outputdebugtoconsole": true, + "option_html5_display_cursor": true, + "option_html5_localrunalert": true, + "option_html5_index": "", + "option_html5_loadingbar": "", + "option_html5_jsprepend": "", + "option_html5_icon": "${base_options_dir}/html5/fav.ico", + "option_html5_allow_fullscreen": true, + "option_html5_interpolate_pixels": false, + "option_html5_centregame": false, + "option_html5_usebuiltinparticles": true, + "option_html5_usebuiltinfont": false, + "option_html5_webgl": 2, + "option_html5_scale": 0, + "option_html5_texture_page": "2048x2048", + "option_html5_use_facebook": false, + "option_html5_facebook_id": "", + "option_html5_facebook_app_display_name": "", + "option_html5_flurry_enable": false, + "option_html5_flurry_id": "", + "option_html5_google_analytics_enable": false, + "option_html5_google_tracking_id": "", + "resourceVersion": "1.0", + "name": "HTML5", + "tags": [], + "resourceType": "GMHtml5Options", +} \ No newline at end of file diff --git a/options/ios/options_ios.yy b/options/ios/options_ios.yy new file mode 100644 index 0000000..a29fed7 --- /dev/null +++ b/options/ios/options_ios.yy @@ -0,0 +1,50 @@ +{ + "option_ios_display_name": "Made in GameMaker Studio 2", + "option_ios_bundle_name": "com.company.game", + "option_ios_version": "1.0.0.0", + "option_ios_output_dir": "~/GameMakerStudio2/iOS", + "option_ios_team_id": "", + "option_ios_orientation_portrait": true, + "option_ios_orientation_portrait_flipped": true, + "option_ios_orientation_landscape": true, + "option_ios_orientation_landscape_flipped": true, + "option_ios_devices": 2, + "option_ios_defer_home_indicator": false, + "option_ios_icon_iphone_app_120": "${base_options_dir}/ios/icons/app/iphone_120.png", + "option_ios_icon_iphone_app_180": "${base_options_dir}/ios/icons/app/iphone_180.png", + "option_ios_icon_ipad_app_76": "${base_options_dir}/ios/icons/app/ipad_76.png", + "option_ios_icon_ipad_app_152": "${base_options_dir}/ios/icons/app/ipad_152.png", + "option_ios_icon_ipad_pro_app_167": "${base_options_dir}/ios/icons/app/ipad_pro_167.png", + "option_ios_icon_iphone_notification_40": "${base_options_dir}/ios/icons/notification/iphone_40.png", + "option_ios_icon_iphone_notification_60": "${base_options_dir}/ios/icons/notification/iphone_60.png", + "option_ios_icon_ipad_notification_20": "${base_options_dir}/ios/icons/notification/ipad_20.png", + "option_ios_icon_ipad_notification_40": "${base_options_dir}/ios/icons/notification/ipad_40.png", + "option_ios_icon_iphone_spotlight_80": "${base_options_dir}/ios/icons/spotlight/iphone_80.png", + "option_ios_icon_iphone_spotlight_120": "${base_options_dir}/ios/icons/spotlight/iphone_120.png", + "option_ios_icon_ipad_spotlight_40": "${base_options_dir}/ios/icons/spotlight/ipad_40.png", + "option_ios_icon_ipad_spotlight_80": "${base_options_dir}/ios/icons/spotlight/ipad_80.png", + "option_ios_icon_iphone_settings_58": "${base_options_dir}/ios/icons/settings/iphone_58.png", + "option_ios_icon_iphone_settings_87": "${base_options_dir}/ios/icons/settings/iphone_87.png", + "option_ios_icon_ipad_settings_29": "${base_options_dir}/ios/icons/settings/ipad_29.png", + "option_ios_icon_ipad_settings_58": "${base_options_dir}/ios/icons/settings/ipad_58.png", + "option_ios_icon_itunes_artwork_1024": "${base_options_dir}/ios/icons/itunes/itunes_1024.png", + "option_ios_splashscreen_background_colour": 4294967295, + "option_ios_launchscreen_image": "${base_options_dir}/ios/splash/launchscreen.png", + "option_ios_launchscreen_image_landscape": "${base_options_dir}/ios/splash/launchscreen-landscape.png", + "option_ios_launchscreen_fill": 0, + "option_ios_interpolate_pixels": false, + "option_ios_half_ipad1_textures": false, + "option_ios_scale": 0, + "option_ios_texture_page": "2048x2048", + "option_ios_use_facebook": false, + "option_ios_facebook_id": "", + "option_ios_facebook_app_display_name": "", + "option_ios_push_notifications": false, + "option_ios_apple_sign_in": false, + "option_ios_podfile_path": "${options_dir}/ios/Podfile", + "option_ios_podfile_lock_path": "${options_dir}/ios/Podfile.lock", + "resourceVersion": "1.3", + "name": "iOS", + "tags": [], + "resourceType": "GMiOSOptions", +} \ No newline at end of file diff --git a/options/linux/options_linux.yy b/options/linux/options_linux.yy new file mode 100644 index 0000000..6cde620 --- /dev/null +++ b/options/linux/options_linux.yy @@ -0,0 +1,25 @@ +{ + "option_linux_display_name": "Made in GameMaker Studio 2", + "option_linux_version": "1.0.0.0", + "option_linux_maintainer_email": "", + "option_linux_homepage": "http://www.yoyogames.com", + "option_linux_short_desc": "", + "option_linux_long_desc": "", + "option_linux_splash_screen": "${base_options_dir}/linux/splash/splash.png", + "option_linux_display_splash": false, + "option_linux_icon": "${base_options_dir}/linux/icons/64.png", + "option_linux_start_fullscreen": false, + "option_linux_allow_fullscreen": false, + "option_linux_interpolate_pixels": false, + "option_linux_display_cursor": true, + "option_linux_sync": false, + "option_linux_resize_window": false, + "option_linux_scale": 0, + "option_linux_texture_page": "2048x2048", + "option_linux_enable_steam": false, + "option_linux_disable_sandbox": false, + "resourceVersion": "1.0", + "name": "Linux", + "tags": [], + "resourceType": "GMLinuxOptions", +} \ No newline at end of file diff --git a/options/mac/options_mac.yy b/options/mac/options_mac.yy new file mode 100644 index 0000000..69b0712 --- /dev/null +++ b/options/mac/options_mac.yy @@ -0,0 +1,32 @@ +{ + "option_mac_display_name": "Made in GameMaker Studio 2", + "option_mac_app_id": "com.company.game", + "option_mac_version": "1.0.0.0", + "option_mac_output_dir": "~/GameMakerStudio2/Mac", + "option_mac_team_id": null, + "option_mac_signing_identity": "Developer ID Application:", + "option_mac_copyright": "(c) 2017 CompanyName", + "option_mac_splash_png": "${base_options_dir}/mac/splash/splash.png", + "option_mac_icon_png": "${base_options_dir}/mac/icons/1024.png", + "option_mac_menu_dock": false, + "option_mac_display_cursor": true, + "option_mac_start_fullscreen": false, + "option_mac_allow_fullscreen": false, + "option_mac_interpolate_pixels": false, + "option_mac_vsync": false, + "option_mac_resize_window": false, + "option_mac_enable_retina": false, + "option_mac_scale": 0, + "option_mac_texture_page": "2048x2048", + "option_mac_build_app_store": false, + "option_mac_allow_incoming_network": false, + "option_mac_allow_outgoing_network": false, + "option_mac_app_category": "Games", + "option_mac_enable_steam": false, + "option_mac_disable_sandbox": false, + "option_mac_apple_sign_in": false, + "resourceVersion": "1.0", + "name": "macOS", + "tags": [], + "resourceType": "GMMacOptions", +} \ No newline at end of file diff --git a/options/main/inherited/options_main.inherited.yy b/options/main/inherited/options_main.inherited.yy new file mode 100644 index 0000000..2c3fed5 --- /dev/null +++ b/options/main/inherited/options_main.inherited.yy @@ -0,0 +1,8 @@ +1.0.0←ed6a955d-5826-4f98-a450-10b414266c27←ed6a955d-5826-4f98-a450-10b414266c27|{ + "option_gameguid": "61b56097-2011-4784-9dc2-42810efb9a9a", + "option_game_speed": 30 +}←1225f6b0-ac20-43bd-a82e-be73fa0b6f4f|{ + "targets": 461609314234257646 +}←7b2c4976-1e09-44e5-8256-c527145e03bb|{ + "targets": 461609314234257646 +} \ No newline at end of file diff --git a/options/main/options_main.yy b/options/main/options_main.yy new file mode 100644 index 0000000..a7f118d --- /dev/null +++ b/options/main/options_main.yy @@ -0,0 +1,16 @@ +{ + "option_gameguid": "61b56097-2011-4784-9dc2-42810efb9a9a", + "option_game_speed": 30, + "option_mips_for_3d_textures": false, + "option_draw_colour": 4294967295, + "option_window_colour": 255, + "option_steam_app_id": "0", + "option_sci_usesci": false, + "option_author": "", + "option_lastchanged": "", + "option_spine_licence": false, + "resourceVersion": "1.2", + "name": "Main", + "tags": [], + "resourceType": "GMMainOptions", +} \ No newline at end of file diff --git a/options/tvos/options_tvos.yy b/options/tvos/options_tvos.yy new file mode 100644 index 0000000..275eb09 --- /dev/null +++ b/options/tvos/options_tvos.yy @@ -0,0 +1,29 @@ +{ + "option_tvos_display_name": "Made in GameMaker Studio 2", + "option_tvos_bundle_name": "com.company.game", + "option_tvos_version": "1.0.0.0", + "option_tvos_output_dir": "~/GameMakerStudio2/tvOS", + "option_tvos_team_id": "", + "option_tvos_icon_400": "${base_options_dir}/tvos/icons/400.png", + "option_tvos_icon_400_2x": "${base_options_dir}/tvos/icons/400_2x.png", + "option_tvos_icon_1280": "${base_options_dir}/tvos/icons/1280.png", + "option_tvos_topshelf": "${base_options_dir}/tvos/topshelf/topshelf.png", + "option_tvos_topshelf_2x": "${base_options_dir}/tvos/topshelf/topshelf_2x.png", + "option_tvos_topshelf_wide": "${base_options_dir}/tvos/topshelf/topshelf_wide.png", + "option_tvos_topshelf_wide_2x": "${base_options_dir}/tvos/topshelf/topshelf_wide_2x.png", + "option_tvos_splashscreen": "${base_options_dir}/tvos/splash/splash.png", + "option_tvos_splashscreen_2x": "${base_options_dir}/tvos/splash/splash_2x.png", + "option_tvos_splash_time": 10, + "option_tvos_interpolate_pixels": true, + "option_tvos_scale": 0, + "option_tvos_texture_page": "2048x2048", + "option_tvos_display_cursor": false, + "option_tvos_push_notifications": false, + "option_tvos_apple_sign_in": false, + "option_tvos_podfile_path": "${options_dir}\\tvos\\Podfile", + "option_tvos_podfile_lock_path": "${options_dir}\\tvos\\Podfile.lock", + "resourceVersion": "1.3", + "name": "tvOS", + "tags": [], + "resourceType": "GMtvOSOptions", +} \ No newline at end of file diff --git a/options/windows/options_windows.yy b/options/windows/options_windows.yy new file mode 100644 index 0000000..5a6e376 --- /dev/null +++ b/options/windows/options_windows.yy @@ -0,0 +1,36 @@ +{ + "option_windows_display_name": "Made in GameMaker Studio 2", + "option_windows_executable_name": "${project_name}", + "option_windows_version": "1.0.0.0", + "option_windows_company_info": "YoYo Games Ltd", + "option_windows_product_info": "Made in GameMaker Studio 2", + "option_windows_copyright_info": "(c) 2017 CompanyName", + "option_windows_description_info": "A GameMaker Studio 2 Game", + "option_windows_display_cursor": true, + "option_windows_icon": "${base_options_dir}/windows/icons/icon.ico", + "option_windows_save_location": 0, + "option_windows_splash_screen": "${base_options_dir}/windows/splash/splash.png", + "option_windows_use_splash": false, + "option_windows_start_fullscreen": false, + "option_windows_allow_fullscreen_switching": false, + "option_windows_interpolate_pixels": false, + "option_windows_vsync": false, + "option_windows_resize_window": false, + "option_windows_borderless": false, + "option_windows_scale": 0, + "option_windows_copy_exe_to_dest": false, + "option_windows_sleep_margin": 10, + "option_windows_texture_page": "2048x2048", + "option_windows_installer_finished": "${base_options_dir}/windows/installer/finished.bmp", + "option_windows_installer_header": "${base_options_dir}/windows/installer/header.bmp", + "option_windows_license": "${base_options_dir}/windows/installer/license.txt", + "option_windows_nsis_file": "${base_options_dir}/windows/installer/nsis_script.nsi", + "option_windows_enable_steam": false, + "option_windows_disable_sandbox": false, + "option_windows_steam_use_alternative_launcher": false, + "option_windows_use_x64": false, + "resourceVersion": "1.1", + "name": "Windows", + "tags": [], + "resourceType": "GMWindowsOptions", +} \ No newline at end of file diff --git a/options/windowsuap/options_windowsuap.yy b/options/windowsuap/options_windowsuap.yy new file mode 100644 index 0000000..ec03f4e --- /dev/null +++ b/options/windowsuap/options_windowsuap.yy @@ -0,0 +1,61 @@ +{ + "option_windowsuap_display_name": "Made in GameMaker Studio 2", + "option_windowsuap_package_name": "YourPackageName", + "option_windowsuap_publisher_display_name": "YourPublisherName", + "option_windowsuap_package_display_name": "YourPackageDisplayName", + "option_windowsuap_description": "", + "option_windowsuap_version": "1.0.0.0", + "option_windowsuap_orient_portrait": true, + "option_windowsuap_orient_portrait_flipped": true, + "option_windowsuap_orient_landscape": true, + "option_windowsuap_orient_landscape_flipped": true, + "option_windowsuap_small_logo": "${base_options_dir}/windowsuap/logos/SmallLogo.scale-100.png", + "option_windowsuap_smallish_logo": "${base_options_dir}/windowsuap/logos/SmallishLogo.scale-100.png", + "option_windowsuap_store_logo": "${base_options_dir}/windowsuap/logos/StoreLogo.scale-100.png", + "option_windowsuap_logo": "${base_options_dir}/windowsuap/logos/Logo.scale-100.png", + "option_windowsuap_logo_background_colour": 4278190080, + "option_windowsuap_logo_foreground_text": 0, + "option_windowsuap_wide_logo": "${base_options_dir}/windowsuap/logos/WideLogo.scale-100.png", + "option_windowsuap_large_logo": "${base_options_dir}/windowsuap/logos/LargeLogo.scale-100.png", + "option_windowsuap_splash_png": "${base_options_dir}/windowsuap/splash/SplashScreen.scale-100.png", + "option_windowsuap_splash_background_colour": 4278190080, + "option_windowsuap_interpolate_pixels": false, + "option_windowsuap_display_cursor": true, + "option_windowsuap_start_fullscreen": false, + "option_windowsuap_allow_fullscreen_switching": false, + "option_windowsuap_use_synchronization": true, + "option_windowsuap_scale": 0, + "option_windowsuap_texture_page": "2048x2048", + "option_windowsuap_certificate_location": "${base_options_dir}\\windowsuap\\keys\\WinUWPRunner_TemporaryKey.pfx", + "option_windowsuap_certificate_publishername": "CN=Sandbox", + "option_windowsuap_native_cpu": 0, + "option_windowsuap_internet_capable": false, + "option_windowsuap_microphone_capable": false, + "option_windowsuap_iap_sandbox": false, + "option_windowsuap_targetdevicefamily_universal": true, + "option_windowsuap_target_platform_version": "10.0.17763.0", + "option_windowsuap_target_platform_min_version": "10.0.17763.0", + "option_windowsuap_targetdevicefamily_desktop": false, + "option_windowsuap_desktop_family_platform_version": "10.0.14393.0", + "option_windowsuap_desktop_family_platform_min_version": "10.0.14393.0", + "option_windowsuap_targetdevicefamily_xbox": false, + "option_windowsuap_xbox_family_platform_version": "10.0.14393.0", + "option_windowsuap_xbox_family_platform_min_version": "10.0.14393.0", + "option_windowsuap_targetdevicefamily_mobile": false, + "option_windowsuap_mobile_family_platform_version": "10.0.14393.0", + "option_windowsuap_mobile_family_platform_min_version": "10.0.14393.0", + "option_windowsuap_targetdevicefamily_holographic": false, + "option_windowsuap_holographic_family_platform_version": "10.0.14393.0", + "option_windowsuap_holographic_family_platform_min_version": "10.0.14393.0", + "option_windowsuap_targetdevicefamily_team": false, + "option_windowsuap_team_family_platform_version": "10.0.14393.0", + "option_windowsuap_team_family_platform_min_version": "10.0.14393.0", + "option_windowsuap_xbox_live": false, + "option_windowsuap_xbox_live_creators_program": false, + "option_windowsuap_xbox_live_title_id": 0, + "option_windowsuap_xbox_live_scid": null, + "resourceVersion": "1.0", + "name": "Windows UWP", + "tags": [], + "resourceType": "GMWindowsUAPOptions", +} \ No newline at end of file diff --git a/rooms/rm_xorwow_test/RoomCreationCode.gml b/rooms/rm_xorwow_test/RoomCreationCode.gml new file mode 100644 index 0000000..c2a5c07 --- /dev/null +++ b/rooms/rm_xorwow_test/RoomCreationCode.gml @@ -0,0 +1 @@ +layer_background_blend(layer_background_get_id(layer_get_id("Background")), xorwow_test_all() ? c_green : c_red); \ No newline at end of file diff --git a/rooms/rm_xorwow_test/rm_xorwow_test.yy b/rooms/rm_xorwow_test/rm_xorwow_test.yy new file mode 100644 index 0000000..4794d04 --- /dev/null +++ b/rooms/rm_xorwow_test/rm_xorwow_test.yy @@ -0,0 +1,52 @@ +{ + "isDnd": false, + "volume": 1.0, + "parentRoom": null, + "views": [ + {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1024,"hview":768,"xport":0,"yport":0,"wport":1024,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, + {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1024,"hview":768,"xport":0,"yport":0,"wport":1024,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, + {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1024,"hview":768,"xport":0,"yport":0,"wport":1024,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, + {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1024,"hview":768,"xport":0,"yport":0,"wport":1024,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, + {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1024,"hview":768,"xport":0,"yport":0,"wport":1024,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, + {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1024,"hview":768,"xport":0,"yport":0,"wport":1024,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, + {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1024,"hview":768,"xport":0,"yport":0,"wport":1024,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, + {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1024,"hview":768,"xport":0,"yport":0,"wport":1024,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, + ], + "layers": [ + {"instances":[],"visible":true,"depth":0,"userdefinedDepth":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"gridX":32,"gridY":32,"layers":[],"hierarchyFrozen":false,"resourceVersion":"1.0","name":"Instances","tags":[],"resourceType":"GMRInstanceLayer",}, + {"spriteId":null,"colour":4278190080,"x":0,"y":0,"htiled":false,"vtiled":false,"hspeed":0.0,"vspeed":0.0,"stretch":false,"animationFPS":15.0,"animationSpeedType":0,"userdefinedAnimFPS":false,"visible":true,"depth":100,"userdefinedDepth":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"gridX":32,"gridY":32,"layers":[],"hierarchyFrozen":false,"resourceVersion":"1.0","name":"Background","tags":[],"resourceType":"GMRBackgroundLayer",}, + ], + "inheritLayers": false, + "creationCodeFile": "${project_dir}/rooms/rm_xorwow_test/RoomCreationCode.gml", + "inheritCode": false, + "instanceCreationOrder": [], + "inheritCreationOrder": false, + "sequenceId": null, + "roomSettings": { + "inheritRoomSettings": false, + "Width": 960, + "Height": 540, + "persistent": false, + }, + "viewSettings": { + "inheritViewSettings": false, + "enableViews": false, + "clearViewBackground": false, + "clearDisplayBuffer": true, + }, + "physicsSettings": { + "inheritPhysicsSettings": false, + "PhysicsWorld": false, + "PhysicsWorldGravityX": 0.0, + "PhysicsWorldGravityY": 10.0, + "PhysicsWorldPixToMetres": 0.1, + }, + "parent": { + "name": "GMXorWow_test", + "path": "folders/Libraries_test/GMXorWow_test.yy", + }, + "resourceVersion": "1.0", + "name": "rm_xorwow_test", + "tags": [], + "resourceType": "GMRoom", +} \ No newline at end of file diff --git a/scripts/XorWow_classes/XorWow_classes.gml b/scripts/XorWow_classes/XorWow_classes.gml new file mode 100644 index 0000000..52fc1fb --- /dev/null +++ b/scripts/XorWow_classes/XorWow_classes.gml @@ -0,0 +1,497 @@ +///@func __XorSeed__() +///@desc Base XorShift action template constructor +/** +Descendants should override the following: +- toArray() +- toStruct() +- srandomize() +- srandom(n) +- sirandom(n) +The remaining functionality will be filled in by template methods. +*/ +function __XorSeed__() constructor { + /* OVERRIDE THESE */ + + static srandomize = function() { + show_error(instanceof(self) + " failed to implement srandomize().", true); + }; + static srandom = function(n) { + show_error(instanceof(self) + " failed to implement srandom(n).", true); + }; + static sirandom = function(n) { + show_error(instanceof(self) + " failed to implement sirandom(n).", true); + }; + + /* Template methods */ + + ///@func srandom_range(m, n) + ///@param {real} m + ///@param {real} n + ///@desc Seeded replacement for random_range(m, n) + static srandom_range = function(m, n) { + return srandom(n-m)+m; + }; + + ///@func sirandom_range(m, n) + ///@param {int} m + ///@param {int} n + ///@desc Seeded replacement for irandom_range(m, n) + static sirandom_range = function(m, n) { + var _m = floor(m); + var _n = floor(n); + return sirandom(_n-_m)+_m; + }; + + ///@func schoose(...) + ///@desc Seeded replacement for choose(...) + static schoose = function() { + return argument[sirandom(argument_count-1)]; + }; + + ///@func sds_list_shuffle(list) + ///@param {ds_list} list + ///@desc Seeded replacement for ds_list_shuffle(list) + static sds_list_shuffle = function(list) { + for (var i = ds_list_size(list)-1; i > 0; --i) { + var j = sirandom(i); + var temp = list[| i]; + list[| i] = list[| j]; + list[| j] = temp; + } + }; + + ///@func sds_grid_shuffle(grid) + ///@param {ds_grid} grid + ///@desc Seeded replacement for ds_grid_shuffle(grid) + static sds_grid_shuffle = function(grid) { + var gridWidth = ds_grid_width(grid); + for (var i = gridWidth*ds_grid_height(grid)-1; i > 0; --i) { + var j = sirandom(i); + var jx = j mod gridWidth; + var jy = j div gridWidth; + var ix = i mod gridWidth; + var iy = i div gridWidth; + var temp = grid[# ix, iy]; + grid[# ix, iy] = grid[# jx, jy]; + grid[# jx, jy] = temp; + } + }; + + ///@func sarray_shuffle(array) + ///@param {array} array + ///@desc Seeded replacement for array_shuffle(array) + static sarray_shuffle = function(array) { + for (var i = array_length(array)-1; i > 0; --i) { + var j = sirandom(i); + var temp = array[i]; + array[@i] = array[j]; + array[@j] = temp; + } + }; +} + +///@func __xorshift_hex_to_dec__(hex) +///@param {string} hex +///@desc Returns an integer converted from an hexadecimal string. +function __xorshift_hex_to_dec__(hex) { + var dec = int64(0); + var digits = "0123456789abcdef"; + var hexDigits = string_length(hex); + for (var i = 1; i <= hexDigits; ++i) { + dec = (dec << 4) | int64(string_pos(string_char_at(hex, i), digits)-1); + } + return dec; +} + +///@func XorWow(...) +///@desc XorWow seed constructor +/** +- If given no arguments: Initialize based on current date and current_time (non-deterministic). +- If given 1 string argument: Initialize based on SHA1 hash of the given string (deterministic). +- If given 1 array or struct argument: Initialize directly to the seed numbers given (deterministic). +- If given 6 numeric arguments: Initialize directly to the 6 seed numbers (deterministic). +*/ +function XorWow() : __XorSeed__() constructor { + ///@func toArray() + ///@desc Return this seed's state values as an array + static toArray = function() { + return [a, b, c, d, e, counter]; + } + + ///@func toStruct() + ///@desc Return this seed's state values as a struct + static toStruct = function() { + return { a: a, b: b, c: c, d: d, e: e, counter: counter }; + }; + + ///@func srandomize() + ///@desc Randomize this seed + static srandomize = function() { + var hash = sha1_string_unicode(keyboard_lastchar + string(get_timer()) + string(date_current_datetime()) + string(current_time) + keyboard_string); + a = __xorshift_hex_to_dec__(string_copy(hash, 1, 4)); + b = __xorshift_hex_to_dec__(string_copy(hash, 5, 4)); + c = __xorshift_hex_to_dec__(string_copy(hash, 9, 4)); + d = __xorshift_hex_to_dec__(string_copy(hash, 13, 4)); + e = __xorshift_hex_to_dec__(string_copy(hash, 17, 4)); + counter = (a+b+c+d+e) & $FFFFFFFF; + if (a == 0 && b == 0 && c == 0 && d == 0) { + a = int64(1); + b = int64(2); + c = int64(3); + d = int64(4); + } + }; + + ///@func __rand__() + ///@desc Update the seed's state and return a raw random value + static __rand__ = function() { + var t = e; + var s = a; + e = d; + d = c; + c = b; + b = s; + t = t ^ (t >> 2); + t = t ^ ((t << 1) & $FFFFFFFF); + t = t ^ (s ^ ((s << 4) & $FFFFFFFF)); + a = t; + counter = (counter+362437) & $FFFFFFFF; + return (t+counter) & $FFFFFFFF; + }; + + ///@func srandom(n) + ///@param {real} n + ///@desc Seeded replacement for random(n) + static srandom = function(n) { + return real(__rand__())/real($FFFFFFFF); + }; + + ///@func sirandom(n) + ///@param {real} n + ///@desc Seeded replacement for irandom(n) + static sirandom = function(n) { + return __rand__() mod (n+1); + }; + + // Constructor + switch (argument_count) { + case 0: + srandomize(); + break; + case 1: + var seedInput = argument[0]; + switch (typeof(seedInput)) { + case "string": + var hash = sha1_string_unicode(seedInput); + a = __xorshift_hex_to_dec__(string_copy(hash, 1, 4)); + b = __xorshift_hex_to_dec__(string_copy(hash, 5, 4)); + c = __xorshift_hex_to_dec__(string_copy(hash, 9, 4)); + d = __xorshift_hex_to_dec__(string_copy(hash, 13, 4)); + e = __xorshift_hex_to_dec__(string_copy(hash, 17, 4)); + counter = (a+b+c+d+e) & $FFFFFFFF; + break; + case "array": + a = int64(seedInput[0]); + b = int64(seedInput[1]); + c = int64(seedInput[2]); + d = int64(seedInput[3]); + e = int64(seedInput[4]); + counter = int64(seedInput[5]); + break; + case "struct": + a = int64(seedInput.a); + b = int64(seedInput.b); + c = int64(seedInput.c); + d = int64(seedInput.d); + e = int64(seedInput.e); + counter = int64(seedInput.counter); + break; + } + + break; + case 6: + a = int64(argument[0]); + b = int64(argument[1]); + c = int64(argument[2]); + d = int64(argument[3]); + e = int64(argument[4]); + counter = int64(argument[5]); + break; + default: + show_error("Expected 0, 1 or 6 arguments, got " + string(argument_count) + ".", true); + } + if (a == 0 && b == 0 && c == 0 && d == 0) { + a = int64(1); + b = int64(2); + c = int64(3); + d = int64(4); + } +} + +///@func XorShift32(...) +///@desc XorShift32 seed constructor +/** +- If given no arguments: Initialize based on current date and current_time (non-deterministic). +- If given 1 string argument: Initialize based on SHA1 hash of the given string (deterministic). +- If given 1 array or struct argument: Initialize directly to the seed number given (deterministic). +- If given 1 numeric argument: Initialize directly to the seed number (deterministic). +*/ +function XorShift32() : __XorSeed__() constructor { + ///@func toArray() + ///@desc Return this seed's state values as an array + static toArray = function() { + return [a]; + } + + ///@func toStruct() + ///@desc Return this seed's state values as a struct + static toStruct = function() { + return { a: a }; + }; + + ///@func srandomize() + ///@desc Randomize this seed + static srandomize = function() { + var hash = sha1_string_unicode(keyboard_lastchar + string(get_timer()) + string(date_current_datetime()) + string(current_time) + keyboard_string); + a = __xorshift_hex_to_dec__(string_copy(hash, 1, 4)); + }; + + ///@func __rand__() + ///@desc Update the seed's state and return a raw random value + static __rand__ = function() { + var t = a; + t = t ^ ((t << 13) & $FFFFFFFF); + t = t ^ (t >> 17); + t = t ^ ((t << 5) & $FFFFFFFF); + a = t; + return a; + }; + + ///@func srandom(n) + ///@param {real} n + ///@desc Seeded replacement for random(n) + static srandom = function(n) { + return real(__rand__())/real($FFFFFFFF); + }; + + ///@func sirandom(n) + ///@param {real} n + ///@desc Seeded replacement for irandom(n) + static sirandom = function(n) { + return __rand__() mod (n+1); + }; + + // Constructor + switch (argument_count) { + case 0: + srandomize(); + break; + case 1: + var seedInput = argument[0]; + switch (typeof(seedInput)) { + case "string": + var hash = sha1_string_unicode(seedInput); + a = __xorshift_hex_to_dec__(string_copy(hash, 1, 4)); + break; + case "array": + a = int64(seedInput[0]); + break; + case "struct": + a = int64(seedInput.a); + break; + } + break; + default: + show_error("Expected 0 or 1 argument, got " + string(argument_count) + ".", true); + } +} + +///@func XorShift128(...) +///@desc XorShift128 seed constructor +/** +- If given no arguments: Initialize based on current date and current_time (non-deterministic). +- If given 1 string argument: Initialize based on SHA1 hash of the given string (deterministic). +- If given 1 array or struct argument: Initialize directly to the seed numbers given (deterministic). +- If given 4 numeric arguments: Initialize directly to the 4 seed numbers (deterministic). +*/ +function XorShift128() : __XorSeed__() constructor { + ///@func toArray() + ///@desc Return this seed's state values as an array + static toArray = function() { + return [a, b, c, d]; + } + + ///@func toStruct() + ///@desc Return this seed's state values as a struct + static toStruct = function() { + return { a: a, b: b, c: c, d: d }; + }; + + ///@func srandomize() + ///@desc Randomize this seed + static srandomize = function() { + var hash = sha1_string_unicode(keyboard_lastchar + string(get_timer()) + string(date_current_datetime()) + string(current_time) + keyboard_string); + a = __xorshift_hex_to_dec__(string_copy(hash, 1, 4)); + b = __xorshift_hex_to_dec__(string_copy(hash, 5, 4)); + c = __xorshift_hex_to_dec__(string_copy(hash, 9, 4)); + d = __xorshift_hex_to_dec__(string_copy(hash, 13, 4)); + if (a == 0 && b == 0 && c == 0 && d == 0) { + a = int64(1); + b = int64(2); + c = int64(3); + d = int64(4); + } + }; + + ///@func __rand__() + ///@desc Update the seed's state and return a raw random value + static __rand__ = function() { + var t = d; + var s = a; + d = c; + c = b; + b = s; + t = t ^ (t << 11 & $FFFFFFFF); + t = t ^ (t >> 8); + a = t ^ s ^ (s >> 19); + return a; + }; + + ///@func srandom(n) + ///@param {real} n + ///@desc Seeded replacement for random(n) + static srandom = function(n) { + return real(__rand__())/real($FFFFFFFF); + }; + + ///@func sirandom(n) + ///@param {real} n + ///@desc Seeded replacement for irandom(n) + static sirandom = function(n) { + return __rand__() mod (n+1); + }; + + // Constructor + switch (argument_count) { + case 0: + srandomize(); + break; + case 1: + var seedInput = argument[0]; + switch (typeof(seedInput)) { + case "string": + var hash = sha1_string_unicode(seedInput); + a = __xorshift_hex_to_dec__(string_copy(hash, 1, 4)); + b = __xorshift_hex_to_dec__(string_copy(hash, 5, 4)); + c = __xorshift_hex_to_dec__(string_copy(hash, 9, 4)); + d = __xorshift_hex_to_dec__(string_copy(hash, 13, 4)); + break; + case "array": + a = int64(seedInput[0]); + b = int64(seedInput[1]); + c = int64(seedInput[2]); + d = int64(seedInput[3]); + break; + case "struct": + a = int64(seedInput.a); + b = int64(seedInput.b); + c = int64(seedInput.c); + d = int64(seedInput.d); + break; + } + break; + case 4: + a = int64(argument[0]); + b = int64(argument[1]); + c = int64(argument[2]); + d = int64(argument[3]); + break; + default: + show_error("Expected 0, 1 or 4 arguments, got " + string(argument_count) + ".", true); + } + if (a == 0 && b == 0 && c == 0 && d == 0) { + a = int64(1); + b = int64(2); + c = int64(3); + d = int64(4); + } +} + +///@func xrandomize() +///@desc Randomize the current seed +function xrandomize() { + global.__xorshift_state__.srandomize(); +} + +///@func xrandom_get_seed() +///@desc Return the currently used seed +function xrandom_get_seed() { + return global.__xorshift_state__; +} + +///@func xrandom_set_seed(seed) +///@param {__XorSeed__} seed +///@desc Set a new seed +function xrandom_set_seed(seed) { + global.__xorshift_state__ = seed; +} + +///@func xrandom(n) +///@param {real} n +///@desc Replacement for random(n) +function xrandom(n) { + return global.__xorshift_state__.srandom(n); +} + +///@func xirandom(n) +///@param {int} n +///@desc Replacement for irandom(n) +function xirandom(n) { + return global.__xorshift_state__.sirandom(n); +} + +///@func xrandom_range(m, n) +///@param {real} m +///@param {real} n +///@desc Replacement for random_range(m, n) +function xrandom_range(m, n) { + return global.__xorshift_state__.srandom_range(m, n); +} + +///@func xirandom_range(m, n) +///@param {int} m +///@param {int} n +///@desc Replacement for irandom_range(m, n) +function xirandom_range(m, n) { + return global.__xorshift_state__.sirandom_range(m, n); +} + +///@func xchoose(...) +///@desc Replacement for choose(...) +function xchoose() { + return argument[global.__xorshift_state__.sirandom(argument_count-1)]; +} + +///@func xds_list_shuffle(list) +///@param {ds_list} list +///@desc Replacement for ds_list_shuffle(list) +function xds_list_shuffle(list) { + global.__xorshift_state__.sds_list_shuffle(list); +} + +///@func xds_grid_shuffle(grid) +///@param {ds_grid} grid +///@desc Replacement for ds_grid_shuffle(grid) +function xds_grid_shuffle(grid) { + global.__xorshift_state__.sds_grid_shuffle(grid); +} + +///@func xarray_shuffle(array) +///@param {array} array +///@desc Replacement for array_shuffle(array) +function xarray_shuffle(array) { + global.__xorshift_state__.sarray_shuffle(array); +} + +// Initialize global seed randomly +global.__xorshift_state__ = new XorWow(); diff --git a/scripts/XorWow_classes/XorWow_classes.yy b/scripts/XorWow_classes/XorWow_classes.yy new file mode 100644 index 0000000..a00b156 --- /dev/null +++ b/scripts/XorWow_classes/XorWow_classes.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "GMXorWow", + "path": "folders/Libraries/GMXorWow.yy", + }, + "resourceVersion": "1.0", + "name": "XorWow_classes", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/__GMA_BREAKPOINT__/__GMA_BREAKPOINT__.gml b/scripts/__GMA_BREAKPOINT__/__GMA_BREAKPOINT__.gml new file mode 100644 index 0000000..286372e --- /dev/null +++ b/scripts/__GMA_BREAKPOINT__/__GMA_BREAKPOINT__.gml @@ -0,0 +1,15 @@ +/// @function __GMA_BREAKPOINT__ +/// @param message The error message about to be displayed +/// @param got The value received by the failing assertion +/// @param expected The value expected by the failing assertion +/// @description A script that runs just before the error popup in a failed assertion. Return true to bypass the error popup, false to allow it. +function __GMA_BREAKPOINT__(message, got, expected) { + // Place a breakpoint below + var __GMA_MY_BREAKPOINT__ = true; + + /* Additional assertion failure handling behaviours here */ + global.__test_fails__++; + + // Return true to bypass error popup, false otherwise + return false; +} diff --git a/scripts/__GMA_BREAKPOINT__/__GMA_BREAKPOINT__.yy b/scripts/__GMA_BREAKPOINT__/__GMA_BREAKPOINT__.yy new file mode 100644 index 0000000..28ee750 --- /dev/null +++ b/scripts/__GMA_BREAKPOINT__/__GMA_BREAKPOINT__.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "GMAssert", + "path": "folders/Libraries_config/GMAssert.yy", + }, + "resourceVersion": "1.0", + "name": "__GMA_BREAKPOINT__", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/__GMA_SETTINGS__/__GMA_SETTINGS__.gml b/scripts/__GMA_SETTINGS__/__GMA_SETTINGS__.gml new file mode 100644 index 0000000..3256c81 --- /dev/null +++ b/scripts/__GMA_SETTINGS__/__GMA_SETTINGS__.gml @@ -0,0 +1,6 @@ +// This controls whether assertions are active. +// If set to `false`, all assertions will be silenced, and the breakpoint hook will not trigger. +#macro GMASSERT_ENABLED true + +// This controls the minimum difference between two values for them to be considered unequal. +#macro GMASSERT_TOLERANCE 0.000001 diff --git a/scripts/__GMA_SETTINGS__/__GMA_SETTINGS__.yy b/scripts/__GMA_SETTINGS__/__GMA_SETTINGS__.yy new file mode 100644 index 0000000..3029ec1 --- /dev/null +++ b/scripts/__GMA_SETTINGS__/__GMA_SETTINGS__.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "GMAssert", + "path": "folders/Libraries_config/GMAssert.yy", + }, + "resourceVersion": "1.0", + "name": "__GMA_SETTINGS__", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/__xorwow_test_values__/__xorwow_test_values__.gml b/scripts/__xorwow_test_values__/__xorwow_test_values__.gml new file mode 100644 index 0000000..62b3cf2 --- /dev/null +++ b/scripts/__xorwow_test_values__/__xorwow_test_values__.gml @@ -0,0 +1,97 @@ +///@func __xorwow_test_values__(label, tries) +///@param {string} label The label of the seed type to use for error messages +function __xorwow_test_values__(label, tries) { + var got; + + #region xrandom(n) + repeat (tries) { + got = xrandom(1000); + assert_is_real(got, label + " xrandom(n) type failed"); + assert_in_range(got, 0, 1000, label + " xrandom(n) value failed"); + } + #endregion + + #region xrandom_range(m, n) + repeat (tries) { + got = xrandom_range(400, 800); + assert_is_real(got, label + " xrandom_range(m, n) type failed"); + assert_in_range(got, 400, 800, label + " xrandom_range(m, n) value failed"); + } + #endregion + + #region xirandom(n) + repeat (tries) { + got = xirandom(600); + assert_is_real(got, label + " xirandom(n) type failed"); + assert_in_range(got, 0, 600, label + " xirandom(n) value failed"); + } + #endregion + + #region xirandom_range(m, n) + repeat (tries) { + got = xirandom_range(-200, 200); + assert_is_real(got, label + " xirandom_range(n) type failed"); + assert_in_range(got, -200, 200, label + " xirandom_range(m, n) value failed"); + } + #endregion + + #region xchoose(...) + repeat (tries) { + got = xchoose(10, 11, 12, 13); + assert_is_real(got, label + " xchoose(...) type failed"); + assert_equal(frac(got), 0, label + " xchoose(...) integrity failed"); + assert_in_range(got, 10, 13, label + " xchoose(...) value failed"); + } + #endregion + + #region xds_list_shuffle(list) + var listFixture = ds_list_create(); + ds_list_add(listFixture, 11, 22, 33, 44, 55); + repeat (tries) { + xds_list_shuffle(listFixture); + assert_contains(listFixture, 11, label + " xds_list_shuffle(list) failed 1"); + assert_contains(listFixture, 22, label + " xds_list_shuffle(list) failed 2"); + assert_contains(listFixture, 33, label + " xds_list_shuffle(list) failed 3"); + assert_contains(listFixture, 44, label + " xds_list_shuffle(list) failed 4"); + assert_contains(listFixture, 55, label + " xds_list_shuffle(list) failed 5"); + } + #endregion + + #region xds_grid_shuffle(grid) + var gridFixture = ds_grid_create(3, 3); + gridFixture[# 0, 0] = 11; + gridFixture[# 1, 0] = 22; + gridFixture[# 2, 0] = 33; + gridFixture[# 0, 1] = 44; + gridFixture[# 1, 1] = 55; + gridFixture[# 2, 1] = 66; + gridFixture[# 0, 2] = 77; + gridFixture[# 1, 2] = 88; + gridFixture[# 2, 2] = 99; + repeat (tries) { + xds_grid_shuffle(gridFixture); + assert_contains_2d(gridFixture, 11, label + " xds_grid_shuffle(grid) failed 1"); + assert_contains_2d(gridFixture, 22, label + " xds_grid_shuffle(grid) failed 2"); + assert_contains_2d(gridFixture, 33, label + " xds_grid_shuffle(grid) failed 3"); + assert_contains_2d(gridFixture, 44, label + " xds_grid_shuffle(grid) failed 4"); + assert_contains_2d(gridFixture, 55, label + " xds_grid_shuffle(grid) failed 5"); + assert_contains_2d(gridFixture, 66, label + " xds_grid_shuffle(grid) failed 6"); + assert_contains_2d(gridFixture, 77, label + " xds_grid_shuffle(grid) failed 7"); + assert_contains_2d(gridFixture, 88, label + " xds_grid_shuffle(grid) failed 8"); + assert_contains_2d(gridFixture, 99, label + " xds_grid_shuffle(grid) failed 9"); + } + ds_grid_destroy(gridFixture); + #endregion + + #region xarray_shuffle(array) + var arrayFixture = [11, 22, 33, 44, 55]; + repeat (tries) { + xarray_shuffle(arrayFixture); + assert_contains(arrayFixture, 11, label + " xarray_shuffle(array) failed 1"); + assert_contains(arrayFixture, 22, label + " xarray_shuffle(array) failed 2"); + assert_contains(arrayFixture, 33, label + " xarray_shuffle(array) failed 3"); + assert_contains(arrayFixture, 44, label + " xarray_shuffle(array) failed 4"); + assert_contains(arrayFixture, 55, label + " xarray_shuffle(array) failed 5"); + } + #endregion +} diff --git a/scripts/__xorwow_test_values__/__xorwow_test_values__.yy b/scripts/__xorwow_test_values__/__xorwow_test_values__.yy new file mode 100644 index 0000000..5c79c3f --- /dev/null +++ b/scripts/__xorwow_test_values__/__xorwow_test_values__.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "GMXorWow_test", + "path": "folders/Libraries_test/GMXorWow_test.yy", + }, + "resourceVersion": "1.0", + "name": "__xorwow_test_values__", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/xorwow_test_all/xorwow_test_all.gml b/scripts/xorwow_test_all/xorwow_test_all.gml new file mode 100644 index 0000000..1dee672 --- /dev/null +++ b/scripts/xorwow_test_all/xorwow_test_all.gml @@ -0,0 +1,14 @@ +///@func xorwow_test_all() +function xorwow_test_all() { + global.__test_fails__ = 0; + var timeA, timeB; + timeA = current_time; + + xorwow_test_seeding(); + xorwow_test_sequencing(); + xorwow_test_values(); + + timeB = current_time; + show_debug_message("GMXorWow tests done in " + string(timeB-timeA) + "ms."); + return global.__test_fails__ == 0; +} diff --git a/scripts/xorwow_test_all/xorwow_test_all.yy b/scripts/xorwow_test_all/xorwow_test_all.yy new file mode 100644 index 0000000..41214a8 --- /dev/null +++ b/scripts/xorwow_test_all/xorwow_test_all.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "GMXorWow_test", + "path": "folders/Libraries_test/GMXorWow_test.yy", + }, + "resourceVersion": "1.0", + "name": "xorwow_test_all", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/xorwow_test_seeding/xorwow_test_seeding.gml b/scripts/xorwow_test_seeding/xorwow_test_seeding.gml new file mode 100644 index 0000000..bc46a30 --- /dev/null +++ b/scripts/xorwow_test_seeding/xorwow_test_seeding.gml @@ -0,0 +1,22 @@ +///@func xorwow_test_seeding() +function xorwow_test_seeding() { + var seed; + + #region XorWow + seed = new XorWow("omega"); + assert_equal(seed.toArray(), [int64(46472), int64(35342), int64(62099), int64(34646), int64(37634), int64(216193)], "XorWow seeding failed 1"); + assert_equal(seed.toStruct(), {a: int64(46472), b: int64(35342), c: int64(62099), d: int64(34646), e: int64(37634), counter: int64(216193)}, "XorWow seeding failed 2"); + #endregion + + #region XorShift32 + seed = new XorShift32("omega"); + assert_equal(seed.toArray(), [int64(46472)], "XorShift32 seeding failed 1"); + assert_equal(seed.toStruct(), {a: int64(46472)}, "XorShift32 seeding failed 2"); + #endregion + + #region XorShift128 + seed = new XorShift128("omega"); + assert_equal(seed.toArray(), [int64(46472), int64(35342), int64(62099), int64(34646)], "XorShift128 seeding failed 1"); + assert_equal(seed.toStruct(), {a: int64(46472), b: int64(35342), c: int64(62099), d: int64(34646)}, "XorShift128 seeding failed 2"); + #endregion +} diff --git a/scripts/xorwow_test_seeding/xorwow_test_seeding.yy b/scripts/xorwow_test_seeding/xorwow_test_seeding.yy new file mode 100644 index 0000000..2a86bb2 --- /dev/null +++ b/scripts/xorwow_test_seeding/xorwow_test_seeding.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "GMXorWow_test", + "path": "folders/Libraries_test/GMXorWow_test.yy", + }, + "resourceVersion": "1.0", + "name": "xorwow_test_seeding", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/xorwow_test_sequencing/xorwow_test_sequencing.gml b/scripts/xorwow_test_sequencing/xorwow_test_sequencing.gml new file mode 100644 index 0000000..7d3a9d2 --- /dev/null +++ b/scripts/xorwow_test_sequencing/xorwow_test_sequencing.gml @@ -0,0 +1,34 @@ +///@func xorwow_test_sequencing() +function xorwow_test_sequencing() { + var seed, got, expected; + + #region XorWow + seed = new XorWow("omega"); + got = array_create(20); + expected = [ 84,8,38,100,1,17,9,33,27,21,50,99,24,61,57,45,38,4,80,3 ]; + for (var i = 0; i < 20; ++i) { + got[i] = seed.sirandom(100); + } + assert_equal(got, expected, "XorWow sequencing failed"); + #endregion + + #region XorShift32 + seed = new XorShift32("omega"); + got = array_create(20); + expected = [ 79,32,48,92,77,2,26,28,96,72,68,3,31,28,65,64,11,7,81,8 ]; + for (var i = 0; i < 20; ++i) { + got[i] = seed.sirandom(100); + } + assert_equal(got, expected, "XorShift32 sequencing failed"); + #endregion + + #region XorShift128 + seed = new XorShift128("omega"); + got = array_create(20); + expected = [ 91,81,70,4,19,28,33,17,61,100,81,23,38,81,92,83,36,95,42,20 ]; + for (var i = 0; i < 20; ++i) { + got[i] = seed.sirandom(100); + } + assert_equal(got, expected, "XorShift128 sequencing failed"); + #endregion +} diff --git a/scripts/xorwow_test_sequencing/xorwow_test_sequencing.yy b/scripts/xorwow_test_sequencing/xorwow_test_sequencing.yy new file mode 100644 index 0000000..1c35576 --- /dev/null +++ b/scripts/xorwow_test_sequencing/xorwow_test_sequencing.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "GMXorWow_test", + "path": "folders/Libraries_test/GMXorWow_test.yy", + }, + "resourceVersion": "1.0", + "name": "xorwow_test_sequencing", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/xorwow_test_values/xorwow_test_values.gml b/scripts/xorwow_test_values/xorwow_test_values.gml new file mode 100644 index 0000000..a49ab0a --- /dev/null +++ b/scripts/xorwow_test_values/xorwow_test_values.gml @@ -0,0 +1,40 @@ +///@func xorwow_test_values() +function xorwow_test_values() { + var tries = 1000; + var seed; + + #region XorWow + seed = new XorWow(); + xrandom_set_seed(seed); + xrandomize(); + assert_is(xrandom_get_seed(), seed, "XorWow set seed failed"); + __xorwow_test_values__("XorWow", tries); + assert(is_int64(seed.a), "XorWow core type drift a"); + assert(is_int64(seed.b), "XorWow core type drift b"); + assert(is_int64(seed.c), "XorWow core type drift c"); + assert(is_int64(seed.d), "XorWow core type drift d"); + assert(is_int64(seed.e), "XorWow core type drift e"); + assert(is_int64(seed.counter), "XorWow core type drift counter"); + #endregion + + #region XorShift32 + seed = new XorShift32(); + xrandom_set_seed(seed); + xrandomize(); + assert_is(xrandom_get_seed(), seed, "XorShift32 set seed failed"); + __xorwow_test_values__("XorShift32", tries); + assert(is_int64(seed.a), "XorShift32 core type drift a"); + #endregion + + #region XorShift128 + seed = new XorShift128(); + xrandom_set_seed(seed); + xrandomize(); + assert_is(xrandom_get_seed(), seed, "XorShift128 set seed failed"); + __xorwow_test_values__("XorShift128", tries); + assert(is_int64(seed.a), "XorShift128 core type drift a"); + assert(is_int64(seed.b), "XorShift128 core type drift b"); + assert(is_int64(seed.c), "XorShift128 core type drift c"); + assert(is_int64(seed.d), "XorShift128 core type drift d"); + #endregion +} diff --git a/scripts/xorwow_test_values/xorwow_test_values.yy b/scripts/xorwow_test_values/xorwow_test_values.yy new file mode 100644 index 0000000..c4a8fac --- /dev/null +++ b/scripts/xorwow_test_values/xorwow_test_values.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "GMXorWow_test", + "path": "folders/Libraries_test/GMXorWow_test.yy", + }, + "resourceVersion": "1.0", + "name": "xorwow_test_values", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file