-
Notifications
You must be signed in to change notification settings - Fork 239
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
Allow lazily-evaluated code as argument to TEST #3490
base: development
Are you sure you want to change the base?
Changes from all commits
692f9e9
a5f6300
e2e1e1d
357b426
3656742
54f727d
ad8384b
8448e54
87361bd
c43056b
5772ffc
5be1c7b
0318cec
00af1af
5d46294
44f6447
c8efd14
93c1355
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 |
---|---|---|
|
@@ -257,6 +257,13 @@ export nbinaryop(lhs:ParseTree, token2:Token, file:TokenFile, prec:int, obeyline | |
export arrowop(lhs:ParseTree, token2:Token, file:TokenFile, prec:int, obeylines:bool):ParseTree := ( | ||
e := parse(file,token2.word.parse.binaryStrength,obeylines); | ||
if e == errorTree then e else ParseTree(Arrow(lhs, token2, e, dummyDesc))); | ||
-- "thunk" operator (e.g., TEST) for creating nullary functions | ||
export thunkop(token:Token,file:TokenFile,prec:int,obeylines:bool):ParseTree:=( | ||
ret := parse(file,max(prec,token.word.parse.unaryStrength),obeylines); | ||
if ret == errorTree then ret | ||
else accumulate( | ||
ParseTree(Arrow(dummy(dummyPosition), token, ret, dummyDesc)), | ||
file, prec, obeylines)); | ||
MatchPair := {left:string, right:string, next:(null or MatchPair)}; | ||
|
||
matchList := (null or MatchPair)(NULL); | ||
|
@@ -518,7 +525,10 @@ export treePosition(e:ParseTree):Position := ( | |
is s:Parentheses do combinePositionL(s.left.position, s.right.position) | ||
is s:EmptyParentheses do combinePositionL(s.left.position, s.right.position) | ||
is a:Adjacent do combinePositionM(treePosition(a.lhs), treePosition(a.rhs)) | ||
is a:Arrow do combinePositionL(treePosition(a.lhs), treePosition(a.rhs)) | ||
is a:Arrow do ( | ||
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. Treating 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. Yeah, it is a little strange. We need to call I also considered creating another member of |
||
when a.lhs | ||
is dummy do combinePositionL(a.Operator.position, treePosition(a.rhs)) | ||
else combinePositionL(treePosition(a.lhs), treePosition(a.rhs))) | ||
is o:Unary do combinePositionL(o.Operator.position, treePosition(o.rhs)) | ||
is o:Binary do combinePositionC(treePosition(o.lhs), treePosition(o.rhs), o.Operator.position) | ||
is o:Postfix do combinePositionR(treePosition(o.lhs), o.Operator.position) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
newPackage( | ||
"JSON", | ||
Headline => "JSON encoding and decoding", | ||
Version => "0.2", | ||
Date => "January 28, 2024", | ||
Version => "0.3", | ||
Date => "September 28, 2024", | ||
Authors => {{ | ||
Name => "Doug Torrance", | ||
Email => "[email protected]", | ||
HomePage => "https://webwork.piedmont.edu/~dtorrance"}}, | ||
Keywords => {"System"}, | ||
PackageImports => {"Parsing"}, | ||
AuxiliaryFiles => true) | ||
AuxiliaryFiles => true, | ||
TestFiles => {"test-parse.m2", "test-encode.m2"}) | ||
|
||
--------------- | ||
-- ChangeLog -- | ||
--------------- | ||
|
||
-* | ||
|
||
0.3 (2024-09-28, M2 1.24.11) | ||
* use new TestFiles options instead of TEST for loading tests | ||
|
||
0.2 (2024-01-24, M2 1.23) | ||
* use single-string version of exportFrom | ||
* use null coalescing operator in toJSON | ||
|
@@ -357,6 +361,3 @@ for tst in sort select(tsts, f -> match("^y_", f)) do ( | |
format json << ", " << toExternalString fromJSON json << ")" << endl) | ||
close outfile | ||
/// | ||
|
||
TEST get(currentPackage#"auxiliary files" | "test-parse.m2") | ||
TEST get(currentPackage#"auxiliary files" | "test-encode.m2") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,6 +271,7 @@ Node | |
[newPackage, PackageExports] | ||
[newPackage, PackageImports] | ||
[newPackage, Reload] | ||
[newPackage, TestFiles] | ||
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. This is complicating the testing system rather than simplifying it, and I would personally rather not add yet another option to 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. Fair enough -- I wasn't that excited about this idea either. Another possibility would be to change 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.
|
||
[newPackage, UseCachedExampleOutput] | ||
[newPackage, Version] | ||
Name | ||
|
@@ -338,6 +339,9 @@ Node | |
but a backup will be made and the user's settings for the surviving options will be retained. | ||
Reload=>Boolean | ||
whether to reload the package, if it has been loaded before | ||
TestFiles=>List | ||
of strings, names of auxiliary files to be run as part of the package's | ||
test suite when calling @TO check@ | ||
Outputs | ||
:Package | ||
the new package | ||
|
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 don't understand why this is better. It's much more complicated than before.
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.
The current behavior is to store a test's location in a hash table, which is easy to do at top level. But with this proposal, tests are becoming functions, and so unless we want all the tests that have been loaded from files to have
testing.m2
as their location, we need to fake it somehow in the interpreter. This function was my attempt at doing that. I figured we should try to find out the ending position so thatcode
will work.