Skip to content

assert and asserts with messages added #974

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

Merged
merged 4 commits into from
Jul 15, 2025
Merged

Conversation

DaddyWesker
Copy link
Contributor

@DaddyWesker DaddyWesker commented Jul 11, 2025

So, I've added assert as @ngeiswei asked here , please check if it is what you've asked.

I've also added some asserts with custom messages as @Necr0x0Der asked here . Please also check if it is fine with you.

One thing about asserts with custom message. Regular assert will stop program from further interpretation on failure, but -Msg asserts won't. I'm not sure about this behavior. As an alternative, instead of just outputting custom message it could be wrapped into Error like regular output of assert. So some
!(assertEqualMsg (+ 1 2) 4 "Test message") will output (Error (assertEqualMsg (+ 1 2) 4 "Test message") "Test message") instead of just ("Test message"). What behavior is preferable?


; next part of tests is to test if message is being output on assert failure

!(assertEqual (assertEqualMsg (+ 1 2) 4 "Test message") ("Test message"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do I understand correctly that (assertEqualMsg (+ 1 2) 4 "Test message") returns ("Test message")? I supposed it should return a Error expression with the given message. Otherwise, it doesn't work as an assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Necr0x0Der well currently yes. As i said in the description:

One thing about asserts with custom message. Regular assert will stop program from further interpretation on failure, but -Msg asserts won't. I'm not sure about this behavior. As an alternative, instead of just outputting custom message it could be wrapped into Error like regular output of assert. So some
!(assertEqualMsg (+ 1 2) 4 "Test message") will output (Error (assertEqualMsg (+ 1 2) 4 "Test message") "Test message") instead of just ("Test message"). What behavior is preferable?

@DaddyWesker
Copy link
Contributor Author

@Necr0x0Der I've fixed what asserts with message returns. It looks like this currently:
(assertEqualMsg (+ 1 2) 4 "Test message") ; (Error (assertEqualMsg (+ 1 2) 4) "Test message")

Is this fine?

@Necr0x0Der
Copy link
Collaborator

Is this fine?

Looks acceptable to me.

@DaddyWesker DaddyWesker merged commit 556bfdf into trueagi-io:main Jul 15, 2025
1 check 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.

3 participants