Skip to content

Conversation

@duffee
Copy link
Contributor

@duffee duffee commented Jun 5, 2022

This is a Work In Progress to show how the PG test suite would look if it were migrated to Test2. @pstaabp asks for a reason to justify the move and I think the clearest way of talking about the issues is to have a diff we can all refer to.

This starts out with the tests for Units.pm which started the conversation. It uses my preferred style of a Test module in t/lib/ to set the environment and updates the README.md

The test for contextTrigDegrees.pl exposed some existing errors either in how the macro was being loaded or how the module runs. Comments have been left and failing tests wrapped in a TODO block.

More migrated tests will be added to this PR as I find the time.

mgage and others added 30 commits July 20, 2021 05:30
Resolve problem with space after function to a power. (openwebwork#598)
Co-authored-by: Davide P. Cervone <dpvc33@gmail.com>
…tion-parens

Fix calls to Parser::Value::TeX & too many (cooks)
…signment

parserAssignment chokes when previous answer is undefined on the domain
…in PGML via

`[:: ::]` now fail to parse.
…t-parsing

Fix an issue with parserAssignment.pl introduced in openwebwork#609
If a problem sets the answer to be a formula with an assigment,
(something like `Formula("x = 5")` then all answers are counted
incorrect and a warning is displayed that the evaluated answer is not an
answer hash.  This worked prior to openwebwork#609.  The cause of this was the
removal of a line that should not have been removed that converts the
other answer being compared to to a Formula if it is not already.

Note that the original issue that was attempted to be fixed by openwebwork#609
still is fixed with this change.

This fixes issue openwebwork#644 that I just submitted about this.
Update the copyright in files and version bump.
There was an indexing error in the logic of the tab focus handler of the selection tool that results in the last defining point of an object that has three or more defining points not working correctly.

To see the issue, graph any object and then graph a quadratic or cubic after that.  Immediately after completing the graph of the quadratic or cubic hit shift-tab.  With the code in the release candidate branch the focus will jump back to the last point on first object that was graphed.  With this pull request the focus will go to the next to last point on the quadratic or cubic as it should.
…us-order

Fix tab order for the three point quadratic and four point cubic tools.
Curently the center point of a circle can not be focused by clicking on
it with the mouse.  This is because the jsxgraph circle hasPoint method
only returns true if the circle itself contains the given point, but not
if the center point contains the given point.  So redefine the hasPoint
method for a circle to fix that.
…ter-focus

Fix pointer focus for the center of a circle.
still be a final result from the AnswerHints postfilter.
as that would be the result of the calculation used for any such
n due to overflow of the Perl floating point data type.
…K and PG 2.16.

It seems that Safari does not properly honor the specifications for the FocusEvent.RelatedTarget, and the new method does not work for that lame browser (at least the current version).
* Added a test for the factorial.

* FIX: clarified some of the language in the tests.
Limit loop to compute factorial to n<=170, for n>170 return Perl Inf
Minor changes to migrate tests in t/context from Test::More to Test2
There were few tests in these files.

toltype_digits.t organized into subtests by topic
@pstaabp
Copy link
Member

pstaabp commented Jun 5, 2022

Overall, the switch over to Test2 seems to be the right way to go and this branch is a good start to doing so.

I got the t/units/basic_module.t to succeed with prove -vl t/units/basic_module.t, but not with the electron_volts.t file. Just realized that this doesn't include your updates to these units. Eventually, we will need to get all of the changes into develop to test this.

pstaabp and others added 5 commits June 5, 2022 08:19
This expands on the original t/README.md on the details of
testing.

It replaces the earlier commit in this branch where it
was accidentally replaced with the top level README (or something)
Three test files migrated from Test::More to Test2 without modification
(other than moving the environment setup from the script to Test::PG)
Convert `throws_ok` to the like/dies construct
and the tests pass.
Arranged sections in subtests
duffee added 2 commits June 9, 2022 13:23
PITA!  The circular references in MathObjects made
the deep comparisons impossible, so all MathObjects
were stringified for comparisons.

WARN and DEBUG message sub redefinitions were removed.
A "validator" and a stringify sub were added to get around
some of the comparison issues.

Organized into subtests.  Needs cleanup, but everything passes.
Cleanup of code layout to make the file look half-decent
Needs another pair of eyes to make it sensible.
I'm just tired of it now.
@duffee duffee changed the title WIP: Migrate test suite to Test2 Migrate test suite to Test2 Jun 9, 2022
@duffee
Copy link
Contributor Author

duffee commented Jun 9, 2022

@pstaabp All the test files have been migrated to Test2. Of them all, t/macros/tableau.t was the most problematic because of the circular references in MathObjects prevent the deep comparisons. Most of the tests are the same, except for a lot of ->string. None have been removed and they all pass now. I've tried to tidy it up the best I can, but there will be a few format inconsistencies that fresh eyes will spot. Most of the tests have been organized into subtests based on the comments in the original file. You'll have to go through and check that the labels and the groupings make sense.

t/macros/math_objects_basics.t has examples of migrating throws_ok to the like( dies {} ) pattern. Everything else was fairly easy.

Once #690 has been merged into PG-2.17, I'll remove the version checking code from t/units/electron_volts.t

drgrice1 and others added 15 commits June 13, 2022 11:40
…ols.

When graphing a parabola (via any of the tools that do so) or a cubic it is possible to create degenerate objects.  The code that is supposed to prevent that wasn't quite working right.  The jsxgraph board object needs to be updated after setting the position of a point programatically.

To test this graph any of those objects and then move one of the defining points of the object around with the keyboard.  For example, graph a three point quadratic and try to move one point onto the same vertical line as another point.  That should not be possible.
Correct value for electron volt in Units.pm
…ates

Fix the prevention of creating degenerate objects with keyboard contols.
…lbar-focus-hack

Revert to the mqeditor toolbar focus hack previously used with WeBWorK and PG 2.16.
Fix ww3 mq-editor preview button code causing console log error in ww2 gateway quizzes.
…roblems.

This removes the font size and from these elements.  It also removes the
font-family that was set on selects.  The font family still applies to
textreas and text inputs.
  Only use \textstyle formating option in a fraction's TeX output for
  mixed numbers. For other cases don't include this to allow the size
  of the fraction to be formatted according to \displaystyle.
In contextFraction only use \textstyle for mixed numbers.
For PTX output, don't include hidden MathQuill inputs
Tweak the styles for labels, text inputs, selects, and textareas in problems.
This fixes issue openwebwork/webwork2#1739.

In the PG problem editor, the page in the iframe is not displayed until
after the page loads.  As such the javascript getComputedStyle method
fails.  The same things happens with the graphtool.  The same solution
is now implemented for knowls.
Make knowls wait until the page css has loaded before initializing.
@duffee duffee closed this Jul 21, 2022
@duffee duffee deleted the migration_to_Test2 branch July 21, 2022 21:17
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.

9 participants