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

test::eq/ne/gt syntax #1928

Merged
merged 2 commits into from
Feb 5, 2025
Merged

Conversation

alexveden
Copy link
Contributor

Terse tests syntax proposal #1918

The test module is refactored in the following logic:

  1. 2-letters eq/ne/gt/le are for regular use (90% of the test code), they are macros but without @.
  2. Special cases have @ prefix, and also reduced to 1 word (it's better to remember). Also, @ will be a reminder that we might have special behavior (less mental overhead for reader).
  • test::setup now test::@setup
  • test::is_almost_equal now test::@almost
  1. Let's keep test:: module instead of introducing new assert_eq/ne/gt keyword, because in the future I think it's possible to add more testing features (mocks maybe?). And test:: is visually more readable due to :: separation and different highlighting.

@@ -127,7 +127,7 @@ macro is_equal(left, right)
@require delta >= 0, delta <= 1 "delta must be a small number"
@require runtime::test_context != null "Only allowed in @test functions"
*>
fn void is_almost_equal(double left, double right, uint places = 7, double delta = 0, bool equal_nan = true)
macro void @almost(double left, double right, uint places = 7, double delta = 0, bool equal_nan = true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eq_delta

@lerno
Copy link
Collaborator

lerno commented Feb 5, 2025

Ok, let's go with this!

@lerno lerno merged commit 3a502fe into c3lang:master Feb 5, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants