Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Enso-specific asserts #5973

Closed
Akirathan opened this issue Mar 16, 2023 · 4 comments · Fixed by #7883
Closed

Implement Enso-specific asserts #5973

Akirathan opened this issue Mar 16, 2023 · 4 comments · Fixed by #7883
Assignees
Labels
-compiler -libs Libraries: New libraries to be implemented d-easy Difficulty: little prior knowledge required x-chore Type: chore
Milestone

Comments

@Akirathan
Copy link
Member

Implement something like this:

Runtime.assert : (Any -> Boolean) -> Text -> Nothing
Runtime.assert ~action msg="" =
  if assertions_enabled_builtin.not then Nothing else
    if action.not then Panic.throw ("Assertion Error: " + msg) else
      Nothing

(where assertions_enable_builtin is a builtin method that just check an Assumption in EnsoContext)

Assertions will be enabled with ENSO_EA=true environment variable.

Implement it via truffle Assumption in EnsoContext, so that Runtime.assert is a no-op if assertions are disabled.

JVM assertions and Enso assertions can be enabled separately.

@Akirathan Akirathan added d-easy Difficulty: little prior knowledge required x-chore Type: chore -compiler -libs Libraries: New libraries to be implemented labels Mar 16, 2023
@Akirathan Akirathan self-assigned this Mar 16, 2023
@radeusgd
Copy link
Member

Subjective, but I would suggest to call the env var ENSO_ENABLE_ASSERTIONS. It's not much more typing but it is much clearer what this variable is doing vs EA which is rather cryptic. And it would be more aligned with our style guide.

@radeusgd
Copy link
Member

Also, I'm really excited to see this feature implemented, I've been dreaming about it for a while, just never had enough spare cycles to get it done!

I think asserts are a really great help for ensuring correctness and they act as additional documentation of programmers intent. So I appreciate this.

@enso-bot
Copy link

enso-bot bot commented Sep 27, 2023

Pavel Marek reports a new STANDUP for today (2023-09-27):

Progress: - Almost finished, just have to write few more tests, and make sure that assertions are enabled on the CI It should be finished by 2023-09-29.

@enso-bot
Copy link

enso-bot bot commented Sep 28, 2023

Pavel Marek reports a new STANDUP for today (2023-09-28):

Progress: - Trying to use jUnit 5 Jupiter, but failed to integrate that - #7915

  • At least using some hamcrest matchers in the new tests.
  • Writing rest of the tests
  • Finished the implementation, should merge tomorrow after final review. It should be finished by 2023-09-29.

@mergify mergify bot closed this as completed in #7883 Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-compiler -libs Libraries: New libraries to be implemented d-easy Difficulty: little prior knowledge required x-chore Type: chore
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants