Skip to content

Add overload for assert functions for unit test#28341

Open
stoutes wants to merge 11 commits into
chapel-lang:mainfrom
stoutes:main
Open

Add overload for assert functions for unit test#28341
stoutes wants to merge 11 commits into
chapel-lang:mainfrom
stoutes:main

Conversation

@stoutes

@stoutes stoutes commented Jan 24, 2026

Copy link
Copy Markdown

Resolves #28311

This feature adds the overloads for assert functions:

  1. assertTrue
  2. assertFalse
  3. assertEqual
  4. assertNotEqual
  5. assertGreaterThan
  6. assertLessThan

This will allow additional args on an assert failure to be printed.

Also added unit test files in UnitTest.

Signed-off-by: stoutes <31317041+stoutes@users.noreply.github.com>
Signed-off-by: stoutes <31317041+stoutes@users.noreply.github.com>
Signed-off-by: stoutes <31317041+stoutes@users.noreply.github.com>
Signed-off-by: stoutes <31317041+stoutes@users.noreply.github.com>
Signed-off-by: stoutes <31317041+stoutes@users.noreply.github.com>
Comment thread modules/packages/UnitTest.chpl Outdated
Comment thread modules/packages/UnitTest.chpl
Comment thread modules/packages/UnitTest.chpl Outdated
Comment thread modules/packages/UnitTest.chpl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have you tested this with start_test test/library/packages/UnitTest/assertWithArgs.chpl? It doesn't look as if this good file will pass?

regardless, while these tests are fine and should be kept, I think you should also expand tests in test/library/packages/UnitTest/Assert*/*.chpl tests to include your new overloads, as those are more exhaustive in terms of types passed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

So I re-did the good file, compiled and ran the test, and it showed a pass.

Comment thread test/library/packages/UnitTest/assertWithArgsFailure.chpl
@stoutes stoutes force-pushed the main branch 3 times, most recently from 8d431e2 to 03bf8c0 Compare January 31, 2026 18:31
Signed-off-by: stoutes <31317041+stoutes@users.noreply.github.com>
Signed-off-by: stoutes <31317041+stoutes@users.noreply.github.com>

@jabraham17 jabraham17 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! Other than a few nits I left this is pretty much ready to go. I would still strongly like to see more test cases added in test/library/packages/UnitTest/Assert*/*.chpl.

Make sure to fix the DCO for one of the commits or I won't be able to merge this.
880e074. If you need help, see https://chapel-lang.org/docs/main/developer/bestPractices/DCO.html#troubleshooting-dcos

Comment thread modules/packages/UnitTest.chpl Outdated
Comment thread modules/packages/UnitTest.chpl Outdated
} catch e: AssertionError {
var msg = e.message() + " - " + chpl_stringify_wrapper((...args));
throw new owned AssertionError(msg);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is still not indented right

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Noting this is not resolved, the indentation is still wrong

@stoutes

stoutes commented Feb 5, 2026

Copy link
Copy Markdown
Author

Looks good! Other than a few nits I left this is pretty much ready to go. I would still strongly like to see more test cases added in test/library/packages/UnitTest/Assert*/*.chpl.

Make sure to fix the DCO for one of the commits or I won't be able to merge this. 880e074. If you need help, see https://chapel-lang.org/docs/main/developer/bestPractices/DCO.html#troubleshooting-dcos

I'll just add those test files in with this MR. Working on them right now.

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.

[Feature Request]: Add UnitTest.assert* overloads with extra information

2 participants