-
-
Notifications
You must be signed in to change notification settings - Fork 66
Tests for MakeBoxes #1579
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
Tests for MakeBoxes #1579
Changes from 2 commits
4810a6c
a4963b6
b3984f3
8cbe6dd
f4a8d60
b56e59a
4e972c1
4da8180
7894482
6499f5d
82a07b3
308839c
7eb0096
ce95171
bd11c5d
aae6a35
2b4bd2e
d90abaa
be675d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,9 +9,95 @@ | |||||
| DEBUGMAKEBOXES = int(os.environ.get("DEBUGMAKEBOXES", "0")) == 1 | ||||||
|
|
||||||
| if DEBUGMAKEBOXES: | ||||||
| skip_or_fail = pytest.mark.xfail | ||||||
|
|
||||||
| def skip_or_fail(x): | ||||||
| return x | ||||||
|
|
||||||
| else: | ||||||
| skip_or_fail = pytest.mark.skip | ||||||
| skip_or_fail = pytest.mark.xfail | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.parametrize( | ||||||
| ("str_expr", "str_expected", "fail_msg"), | ||||||
| [ | ||||||
| ("MakeBoxes[x]", '"x"', "StandardForm"), | ||||||
| ( | ||||||
| "MakeBoxes[InputForm[x]]", | ||||||
| 'InterpretationBox[StyleBox["x", ShowStringCharacters -> True, NumberMarks -> True], InputForm[x], Editable -> True, AutoDelete -> True]', | ||||||
| "InputForm, expression", | ||||||
| ), | ||||||
| ( | ||||||
| "MakeBoxes[OutputForm[x]]", | ||||||
| 'InterpretationBox[PaneBox[""x""], OutputForm[x], Editable -> False]', | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I see a duplicate set of quotes. I am wondering about the merits of having exhaustive tests that are wrong, versus having limited tests that are right with tests that are skipped that need to be worked on.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am trying to get useful references from WMA. This is exactly what I get when I evaluate
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I see is: InterpretationBox[PaneBox["\"x\"", BaselinePosition -> Baseline], x, Editable -> False]Note the extra backslashes. This is slightly different. |
||||||
| "OutputForm, expression", | ||||||
| ), | ||||||
| ( | ||||||
| "MakeBoxes[FullForm[x]]", | ||||||
| 'TagBox[StyleBox["x", ShowSpecialCharacters -> False, ShowStringCharacters -> True, NumberMarks -> True], FullForm]', | ||||||
| "MakeBoxes expression FullForm", | ||||||
| ), | ||||||
| ( | ||||||
| "MakeBoxes[TeXForm[x]]", | ||||||
| 'InterpretationBox[""x"", TeXForm[x], Editable -> True, AutoDelete -> True]', | ||||||
| "TeXForm, expression", | ||||||
| ), | ||||||
| # Basic Expressions | ||||||
| ("MakeBoxes[F[x]]", 'RowBox[{"F", "[", "x", "]"}]', "StandardForm"), | ||||||
| ( | ||||||
| "MakeBoxes[InputForm[F[x]]]", | ||||||
| 'InterpretationBox[StyleBox["F[x]", ShowStringCharacters -> True, NumberMarks -> True], InputForm[F[x]], Editable -> True, AutoDelete -> True]', | ||||||
| "InputForm, expression", | ||||||
| ), | ||||||
| ( | ||||||
| "MakeBoxes[OutputForm[F[x]]]", | ||||||
| 'InterpretationBox[PaneBox[""F[x]""], OutputForm[F[x]], Editable -> False]', | ||||||
| "OutputForm, expression", | ||||||
| ), | ||||||
| ( | ||||||
| "MakeBoxes[FullForm[F[x]]]", | ||||||
| 'TagBox[StyleBox[RowBox[{"F", "[", "x", "]"}], ShowSpecialCharacters -> False, ShowStringCharacters -> True, NumberMarks -> True], FullForm]', | ||||||
| "MakeBoxes expression FullForm", | ||||||
| ), | ||||||
| ( | ||||||
| "MakeBoxes[TeXForm[F[x]]]", | ||||||
| 'InterpretationBox[""F(x)"", TeXForm[F[x]], Editable -> True, AutoDelete -> True]', | ||||||
| "TeXForm, expression", | ||||||
| ), | ||||||
| # Arithmetic | ||||||
| ("MakeBoxes[a-b]", 'RowBox[{"a", "-", "b"}]', "difference, StandardForm"), | ||||||
| ( | ||||||
| "MakeBoxes[a-b//InputForm]", | ||||||
| 'InterpretationBox[StyleBox["a - b", ShowStringCharacters -> True, NumberMarks -> True], InputForm[a - b], Editable -> True, AutoDelete -> True]', | ||||||
| "difference, InputForm", | ||||||
| ), | ||||||
| ( | ||||||
| "MakeBoxes[a-b//OutputForm]", | ||||||
| 'InterpretationBox[PaneBox[""a - b""], OutputForm[a - b], Editable -> False]', | ||||||
| "difference, OutputForm", | ||||||
| ), | ||||||
| ( | ||||||
| "MakeBoxes[a-b//FullForm]", | ||||||
| 'TagBox[StyleBox[RowBox[{"Plus", "[", RowBox[{"a", ",", RowBox[{"Times", "[", RowBox[{RowBox[{"-", "1"}], ",", "b"}], "]"}]}], "]"}], ShowSpecialCharacters -> False, ShowStringCharacters -> True, NumberMarks -> True], FullForm]', | ||||||
| "Difference, FullForm", | ||||||
| ), | ||||||
| ( | ||||||
| "MakeBoxes[a-b//TeXForm]", | ||||||
| ' InterpretationBox[""a-b"", TeXForm[a-b], Editable -> True, AutoDelete -> True]', | ||||||
| "Difference, TeXForm", | ||||||
| ), | ||||||
| ], | ||||||
| ) | ||||||
| @skip_or_fail | ||||||
| def test_makeboxes_basic_forms(str_expr, str_expected, fail_msg, msgs): | ||||||
| check_evaluation( | ||||||
| str_expr, | ||||||
| str_expected, | ||||||
| to_string_expr=True, | ||||||
| to_string_expected=True, | ||||||
| hold_expected=True, | ||||||
| failure_message=fail_msg, | ||||||
| expected_messages=msgs, | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.parametrize( | ||||||
|
|
@@ -79,16 +165,29 @@ def test_makeboxes_real(str_expr, str_expected, msg): | |||||
| @pytest.mark.parametrize( | ||||||
| ("str_expr", "str_expected", "msg"), | ||||||
| [ | ||||||
| (r"MakeBoxes[1.4]", r"1.4`", None), | ||||||
| (r"MakeBoxes[1.4`]", r"1.4`", None), | ||||||
| (r"MakeBoxes[1.4`]", r"1.4`", "StandardForm always shows a prec mark."), | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ( | ||||||
| r"MakeBoxes[OutputForm[1.4]]", | ||||||
| r'InterpretationBox[PaneBox["1.4"], 1.4, Editable -> False]', | ||||||
| "MachineReal, OutputForm", | ||||||
| ), | ||||||
| ( | ||||||
| r"MakeBoxes[3.142`3]", | ||||||
| r"3.142`3", | ||||||
| "StandadForm with Prec real shows all the stored digits, and prec", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ), | ||||||
| ( | ||||||
| r"MakeBoxes[OutputForm[3.142`3]]", | ||||||
| r'InterpretationBox[PaneBox["3.14"], 3.14, Editable -> False]', | ||||||
| "OutputForm trims digits up to prec.", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The abbreviation "prec" can confuse me to mean precedence or preceding. While I see this as a parameter name in some WMA documentation, outside of that I am not seeing this in common use as a shorthand for precision. |
||||||
| ), | ||||||
| (r"MakeBoxes[1.5`20]", r"1.5`20.", None), | ||||||
| (r"MakeBoxes[1.4`20]", r"1.4`20.", None), | ||||||
| (r"MakeBoxes[1.5``20]", r"1.5`20.1760912591", None), | ||||||
| (r"MakeBoxes[-1.4]", r"RowBox[{-, 1.4`}]", None), | ||||||
| (r"MakeBoxes[34.*^3]", r"34000.`", None), | ||||||
| (r"MakeBoxes[0`]", r"0.`", None), | ||||||
| (r"MakeBoxes[0``30]", r"0.``30.", None), | ||||||
| (r"MakeBoxes[0.`]", r"0.`", None), | ||||||
| (r"MakeBoxes[0.`3]", r"0.`", None), | ||||||
| (r"MakeBoxes[0.``30]", r"0.``30.", None), | ||||||
| (r"MakeBoxes[-14]", r"RowBox[{-, 14}]", None), | ||||||
|
|
||||||
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.
WMA has
x, instead ofInputForm[x]and there are no quotes around "x" inStyleBox["x"]. What gives?