Skip to content

Commit

Permalink
[WIP] Draft of Runtime.assert
Browse files Browse the repository at this point in the history
  • Loading branch information
Akirathan committed Sep 25, 2023
1 parent df4183e commit 4380526
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Runtime.enso
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ gc = @Builtin_Method "Runtime.gc"
## PRIVATE
ADVANCED

Asserts that the given action succeeds, otherwise throws a panic.

Assertions are disable by default, meaning that call to this method is
essentially a no-op. To enable assertions, set the environment variable
`ENSO_ENABLE_ASSERTIONS=true`
assert : (Any -> Boolean) -> Text -> Nothing
assert ~action msg="" =
if assertions_enabled_builtin.not then Nothing else
if action.not then Panic.throw ("Assertion Error: " + msg) else
Nothing

## ADVANCED

Executes the provided action without allowing it to inline.

Arguments:
Expand Down

0 comments on commit 4380526

Please sign in to comment.