-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conversation
lib/tests/test_stdlib.metta
Outdated
|
||
; next part of tests is to test if message is being output on assert failure | ||
|
||
!(assertEqual (assertEqualMsg (+ 1 2) 4 "Test message") ("Test message")) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
@Necr0x0Der I've fixed what asserts with message returns. It looks like this currently: Is this fine? |
Looks acceptable to me. |
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?