Skip to content

Explain plans around for() loops in GMS2 and GMRT runtimes, so tests can be determined #196

@tinkerer-red

Description

@tinkerer-red

Description

I was debating making some unit tests for the for statement which covers oddities of it. for instance for(;;show_debug_message("second")){ show_debug_message("first") } will actually cycle and default the conditional statement to true. Secondly the note that an initializer isn't needed, and thirdly the incrementor should be a valid block statement. Though the downside with this is with gmrt it's possible these features are not intended behavior, and they are not syntax valid. So before making a PR I was hoping to get confirmation on which of these are expected syntax.

Much of this information was covered quite well by Katsaii in her Syntax Extension blog post.

Steps To The Task

Initializer:

  • [Missing Initializer] Should be valid to be optional, this is only variable declaration and not a valid block statement
  • [Single var Initializer] This is the standard var i=0, and just a sanity check
  • [Double var Initializer] Confirmation var i=0, j=1; should work. (due note var i=0; var j=1 wont work even if wrapped in brackets)

Condition:

  • [Missing Conditional] Should result in a default of true every time

Incrementor:

  • [Missing Incrementor] Incrementor statements are optional, and could simply be placed into the block statement
  • [Incrementor Block Statement] The incrementor can accept a block statement such as { i += 2; j += 1 }.

Block Statement:

  • [Empty Block Statement] for(var i=0; i<j; i++){} valid syntax, however for(var i=0; i<j; i++); is crashing syntax reasonably

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentImprovements or additions to documentation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions