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

Escape strings printed by std.assertEqual #1139

Merged

Conversation

johnbartholomew
Copy link
Collaborator

Fixes #363.

When std.assertEqual fails, the error message it produces includes the values that were passed in. This PR uses std.escapeStringJson to escape strings passed to std.assertEqual. Other values are concatenated as normal (relying on the string concatenation to stringize them as before).

An alternative is to call std.manifestJson on both arguments regardless of type. However it's not clear to me that std.manifestJson will produce the same output as the (internal) toString performed by string concatenation.

PR adds test cases for std.assertEqual with two unequal strings and with two unequal objects.

@johnbartholomew
Copy link
Collaborator Author

@sparkprime Do you think this is ok, or would you be concerned about changing the (error-case) output of std.assertEqual?

@johnbartholomew johnbartholomew force-pushed the escape-assertion-output-363 branch from fc23710 to b8728ea Compare March 23, 2024 14:25
@johnbartholomew johnbartholomew merged commit b8728ea into google:master Mar 23, 2024
6 checks passed
@johnbartholomew johnbartholomew deleted the escape-assertion-output-363 branch March 23, 2024 14:31
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.

Strings not escaped in assertEqual errors
1 participant