myst-lang / myst

A structured, dynamic, general-purpose language.
http://myst-lang.org
MIT License
119 stars 17 forks source link

Fixes #154. Add proper specs for `while` and `until`, catch `break` exceptions to stop looping. #159

Closed faultyserver closed 6 years ago

faultyserver commented 6 years ago

until expressions now properly iterate until their condition is truthy.

As mentioned in #154, the specs for while and until weren't actually testing any of their behavior. The new specs should not be considered complete, but at least cover the basic use cases, including break from within a loop.

Loop expressions also now properly catch BreakExceptions to stop iteration and optionally return a value. Because BreakException pushes a value onto the stack, no additional work is needed to handle this case.