-
Notifications
You must be signed in to change notification settings - Fork 69
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
Make mathematica_test a little less brittle #2829
Make mathematica_test a little less brittle #2829
Conversation
mathematica/mathematica_test.cpp
Outdated
"SetPrecision[+2.00000000000000000*^+00,$MachinePrecision]," | ||
"SetPrecision[+3.00000000000000000*^+00,$MachinePrecision]]", | ||
ToMathematica(std::vector<double>{2, 3})); | ||
EXPECT_EQ("List[" + ToMathematica(2.0) + "," + ToMathematica(3.0) + "]", |
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.
I'd like to preserve a formatting closer to the original one: (1) line break after [
(2) line break after ,
(3) line break after the (replacement for) the SetPrecision
call, i.e., after the +
(unless followed by a comma). The clang-format
formatting makes it hard to visually parse the structure.
"SetPrecision[+3.00000000000000000*^+00,$MachinePrecision]," | ||
"SetPrecision[-4.00000000000000000*^+00,$MachinePrecision]]", | ||
EXPECT_EQ("List[" + ToMathematica(2.0) + "," + ToMathematica(3.0) + "," + | ||
ToMathematica(-4.0) + "]", |
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.
These expectations are now very, very similar to the code under test (compare with line 305-307 in mathematica_body.hpp
). This bothers me as I am afraid that we are moving from long-strings-that-are-hard-to-maintain to tests-that-replicate-the-code.
As a matter of fact, I would like to understand the expected workflow with this new structure. FWIW, my workflow (I wrote most of mathematica_test.cpp
) used to be:
- Write the code.
- Write a test with a bogus string in the expectation.
- Run the test.
- Copy the actual string into Mathematica to make sure that it parses (no missing commas, etc.).
- Copy the actual string into the C++ test, format it by hand and, while doing so, verify that the output makes sense (lists have the right number of elements, are properly nested, etc.).
With the new style step 5 becomes much more contrived as string elements need to be replaced with function calls. It will be very tempting to just copy the code, which seems wrong.
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.
That workflow seems backward; you should generally be able to write the test before you first run the code.
retest this please |
No description provided.