diff --git a/M2/Macaulay2/d/actors5.d b/M2/Macaulay2/d/actors5.d index fdde6bcd9ae..da30e10b3ae 100644 --- a/M2/Macaulay2/d/actors5.d +++ b/M2/Macaulay2/d/actors5.d @@ -459,7 +459,8 @@ examine(e:Expr):Expr := ( << " restargs : " << desc.restargs << endl << " frameID : " << desc.frameID << endl << " framesize : " << desc.framesize << endl - << " numparms : " << desc.numparms << endl; + << " numparms : " << desc.numparms << endl + << " operator : " << model.Operator.name << endl; showFrames(f); nullE) is model:functionCode do ( @@ -470,7 +471,8 @@ examine(e:Expr):Expr := ( << " restargs : " << desc.restargs << endl << " frameID : " << desc.frameID << endl << " framesize : " << desc.framesize << endl - << " numparms : " << desc.numparms << endl; + << " numparms : " << desc.numparms << endl + << " operator : " << model.Operator.name << endl; nullE) is fn:CompiledFunction do ( stdIO diff --git a/M2/Macaulay2/d/binding.d b/M2/Macaulay2/d/binding.d index 7276cf35803..d26b372b9a3 100644 --- a/M2/Macaulay2/d/binding.d +++ b/M2/Macaulay2/d/binding.d @@ -227,6 +227,7 @@ bumpPrecedence(); export RightArrowW := binaryright("->",arrowop); export RightArrowS := makeKeyword(RightArrowW); export DoubleArrowS := makeKeyword(binaryright("=>")); export GreaterGreaterS := makeKeyword(binaryright(">>")); + export TestS := special("TEST", thunkop, prec, prec); bumpPrecedence(); whenW = token("when"); makeKeyword(whenW); ofW = token("of"); makeKeyword(ofW); @@ -311,7 +312,6 @@ bumpPrecedence(); export elapsedTimeS := special("elapsedTime",unaryop,precSpace,wide); export elapsedTimingS := special("elapsedTiming",unaryop,precSpace,wide); export shieldS := special("shield",unaryop,precSpace,wide); - export TestS := special("TEST",unaryop,precSpace,wide); export throwS := special("throw",nunaryop,precSpace,wide); export returnS := special("return",nunaryop,precSpace,wide); export breakS := special("break",nunaryop,precSpace,wide); @@ -846,7 +846,9 @@ export bind(e:ParseTree,dictionary:Dictionary):void := ( is a:Arrow do ( newdict := newLocalDictionary(dictionary); a.desc = functionDescription(newdict.frameID,0,0,false); - bindParenParmList(a.lhs,newdict,a.desc); + when a.lhs + is dummy do nothing + else bindParenParmList(a.lhs,newdict,a.desc); bind(a.rhs,newdict); a.desc.framesize = newdict.framesize; ) diff --git a/M2/Macaulay2/d/convertr.d b/M2/Macaulay2/d/convertr.d index b3a9d3e7221..e305fa0a1dd 100644 --- a/M2/Macaulay2/d/convertr.d +++ b/M2/Macaulay2/d/convertr.d @@ -177,7 +177,8 @@ export convert0(e:ParseTree):Code := ( is p:Parentheses do convertParentheses(makeCodeSequence(p.contents, CommaW), p.left.word, pos) is a:Adjacent do Code(adjacentCode(convert(a.lhs), convert(a.rhs), pos)) is a:Arrow do ( - fc := functionCode(convert(a.rhs), a.desc, hash_t(0), pos); + fc := functionCode(convert(a.rhs), a.desc, hash_t(0), pos, + a.Operator.word); fc.hash = hashFromAddress(Expr(fc)); Code(fc)) is b:Binary do ( diff --git a/M2/Macaulay2/d/evaluate.d b/M2/Macaulay2/d/evaluate.d index 209b866ea7c..77ec8fd5cbb 100644 --- a/M2/Macaulay2/d/evaluate.d +++ b/M2/Macaulay2/d/evaluate.d @@ -29,6 +29,8 @@ export nextS := setupvar("next", nullE); export applyIteratorS := setupvar("applyIterator", nullE); export joinIteratorsS := setupvar("joinIterators", nullE); +addTestS := setupvar("addTest", nullE); -- will be overwritten in testing.m2 + handleError(c:Code,e:Expr):Expr; eval(c:Code):Expr; applyEE(f:Expr,e:Expr):Expr; @@ -1442,7 +1444,11 @@ export evalraw(c:Code):Expr := ( is m:functionCode do ( fc := FunctionClosure(noRecycle(localFrame),m,hash_t(0)); fc.hash = hashFromAddress(Expr(fc)); - return Expr(fc)) + if m.Operator == TestS.symbol.word + then ( + r := applyEE(getGlobalVariable(addTestS), Expr(fc)); + when r is Error do r else nullE) + else Expr(fc)) is r:localMemoryReferenceCode do ( f := localFrame; nd := r.nestingDepth; @@ -1656,13 +1662,28 @@ breakFun(a:Code):Expr := ( when e is Error do e else Expr(Error(dummyPosition,breakMessage,e,false,dummyFrame))); setupop(breakS,breakFun); -addTestS := setupvar("addTest", nullE); -- will be overwritten in testing.m2 -testfun(c:Code):Expr := ( - r := applyEE( - getGlobalVariable(addTestS), - seq(eval(c), locate(codePosition(c)))); - when r is Error do r else nullE); -setupop(TestS, testfun); +addTestFromFile(e:Expr):Expr := ( + when e + is filename:stringCell do ( + x := get(filename.v); + when x + is err:errmsg do buildErrorPacket(err.message) + is s:stringCell do ( + lastrow := 1; + lastcol := 0; + for i from 0 to length(s.v) - 2 do ( + if s.v.i == '\n' then ( + lastcol = 0; + lastrow = lastrow + 1) + else lastcol = lastcol + 1); + p := Position(filename.v, ushort(1), ushort(1), ushort(lastrow), + ushort(lastcol), ushort(1), ushort(1), loadDepth); + fc := functionCode(stringCode(s.v, p), dummyDesc, hash_t(0), p, + TestS.symbol.word); + fc.hash = hashFromAddress(Expr(fc)); + eval(Code(fc)))) + else WrongArgString()); +setupfun("addTestFromFile", addTestFromFile); assigntofun(lhs:Code,rhs:Code):Expr := ( left := eval(lhs); diff --git a/M2/Macaulay2/d/parse.d b/M2/Macaulay2/d/parse.d index a5765f0acb0..2cbf2d60960 100644 --- a/M2/Macaulay2/d/parse.d +++ b/M2/Macaulay2/d/parse.d @@ -256,7 +256,8 @@ export functionCode := {+ -- this is called FunctionBody in the top-level body:Code, desc:functionDescription, hash:hash_t, - position:Position + position:Position, + Operator:Word }; export Code := ( -- when adding or removing classes of core here, also update debugging.dd diff --git a/M2/Macaulay2/d/parser.d b/M2/Macaulay2/d/parser.d index ca1a23a7caf..3d23d7f5655 100644 --- a/M2/Macaulay2/d/parser.d +++ b/M2/Macaulay2/d/parser.d @@ -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 ( + 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) diff --git a/M2/Macaulay2/m2/examples.m2 b/M2/Macaulay2/m2/examples.m2 index bd3d1f754b3..2770df6b6cf 100644 --- a/M2/Macaulay2/m2/examples.m2 +++ b/M2/Macaulay2/m2/examples.m2 @@ -142,7 +142,7 @@ isCapturable = (inputs, pkg, isTest) -> ( and not match("(capture|read|input|load|needs)\\b", inputs) -- these commands hide undesirable functions and not match("([Cc]ommand|fork|schedule|thread|Task)", inputs) -- remove when threads work more predictably and not match("(temporaryFileName)", inputs) -- this is sometimes bug prone - and not match("(addHook|export|newPackage)", inputs) -- these commands have permanent effects + and not match("(addHook|export|newPackage|TEST)", inputs) -- these commands have permanent effects and not match("(installMethod|installAssignmentMethod)", inputs) -- same as above and not match("(Global.*Hook|add.*Function|Echo|Print)", inputs) -- same as above and not match("(importFrom|exportFrom)", inputs) -- currently capture tries to clear all symbols created, these break it diff --git a/M2/Macaulay2/m2/exports.m2 b/M2/Macaulay2/m2/exports.m2 index 2d9febd66ec..f27315615d8 100644 --- a/M2/Macaulay2/m2/exports.m2 +++ b/M2/Macaulay2/m2/exports.m2 @@ -411,7 +411,8 @@ export { "TensorProduct", "TeXmacs", "Test", - "TestInput", + "TestClosure", + "TestFiles", "Thing", "Threads", "Time", @@ -1284,6 +1285,7 @@ export { "numrows" => "numRows", "res" => "resolution", "sub" => "substitute", + "TestInput" => "TestClosure", "threadVariable" => "threadLocal", -- TODO: eventually remove this? -- unicode synonyms: "ℚ" => "QQ", diff --git a/M2/Macaulay2/m2/packages.m2 b/M2/Macaulay2/m2/packages.m2 index e036c5172e7..c5a2b905c27 100644 --- a/M2/Macaulay2/m2/packages.m2 +++ b/M2/Macaulay2/m2/packages.m2 @@ -223,7 +223,8 @@ newPackage = method( PackageImports => {}, Reload => false, UseCachedExampleOutput => null, - Version => "0.0" + Version => "0.0", + TestFiles => {} }) newPackage Sequence := opts -> x -> newPackage splice(nonnull x, opts) -- to allow null entries newPackage String := opts -> pkgname -> ( diff --git a/M2/Macaulay2/m2/testing.m2 b/M2/Macaulay2/m2/testing.m2 index eff8381cc32..8ee94c1f297 100644 --- a/M2/Macaulay2/m2/testing.m2 +++ b/M2/Macaulay2/m2/testing.m2 @@ -3,35 +3,30 @@ needs "code.m2" needs "run.m2" ----------------------------------------------------------------------------- --- TestInput +-- TestClosure ----------------------------------------------------------------------------- -TestInput = new SelfInitializingType of HashTable -TestInput.synonym = "test input" +TestClosure = new SelfInitializingType of FunctionClosure +TestClosure.synonym = "test closure" -code TestInput := code @@ locate -toString TestInput := T -> T#"code" -locate TestInput := T -> T#"location" -net TestInput := lookup(net, Function) -precedence TestInput := lookup(precedence, Function) -editMethod TestInput := editMethod @@ locate -capture TestInput := opt -> T -> capture(toString T, opt) +capture TestClosure := o -> t -> ( + if instance(teststring := t(), String) then capture(teststring, o)) ----------------------------------------------------------------------------- -- TEST ----------------------------------------------------------------------------- --- TEST is a keyword that takes an object as input and determines its --- location. It then passes the object and its location to addTest. +-- TEST is a keyword that takes M2 code and turns it into a nullary function, +-- which it then passes to addTest + addTest = method() -addTest(String, FilePosition) := (str, loc) -> ( +addTest FunctionClosure := f -> ( n := #currentPackage#"test inputs"; - currentPackage#"test inputs"#n = TestInput { - "location" => loc, - "code" => str}) + currentPackage#"test inputs"#n = TestClosure f) + -- the following is not called by TEST, but called directly when we want to -- add a test from a file (used by loadTestDir) -addTest String := filename -> addTest(get filename, - new FilePosition from(filename, 1, 1)) +addTest String := addTestFromFile + -- TODO: support test titles ----------------------------------------------------------------------------- @@ -61,16 +56,16 @@ captureTestResult := (desc, teststring, pkg, usermode) -> ( loadTestDir := pkg -> ( -- TODO: prioritize reading the tests from topSrcdir | "Macaulay2/tests/normal" instead - testDir := pkg#"package prefix" | - replace("PKG", pkg#"pkgname", currentLayout#"packagetests"); - pkg#"test directory loaded" = - if fileExists testDir then ( - tmp := currentPackage; - currentPackage = pkg; - scan(sort select(readDirectory testDir, file -> match("\\.m2$", file)), - test -> addTest(testDir | test)); - currentPackage = tmp; - true) else false) + testDir := pkg#"package prefix" | replace("PKG", pkg#"pkgname", + currentLayout#"packagetests"); + pushvar(symbol currentPackage, pkg); + if fileExists testDir then scan( + sort select(readDirectory testDir, file -> match("\\.m2$", file)), + test -> addTest(testDir | test)); + if pkg#?"auxiliary files" then scan((options pkg).TestFiles, + file -> addTest(pkg#"auxiliary files" | file)); + popvar symbol currentPackage; + pkg#"test directory loaded" = true) tests = method() tests Package := pkg -> ( @@ -101,15 +96,21 @@ check(List, Package) := opts -> (L, pkg) -> ( -- errorList := for k in testKeys list ( if not inputs#?k then error(pkg, " has no test #", k); - teststring := inputs#k#"code"; desc := "check(" | toString k | ", " | format pkg#"pkgname" | ")"; - ret := elapsedTime captureTestResult(desc, teststring, pkg, usermode); - if not ret then (k, temporaryFilenameCounter - 2) else continue); + elapsedTime ( + try teststring := inputs#k() then ( + if instance(teststring, String) then ( + if captureTestResult(desc, teststring, pkg, usermode) + then continue + else (k, temporaryFilenameCounter - 2)) + else (checkmsg("calling", desc); continue)) + else (checkmsg("calling", desc); (k, null)))); outfile := errfile -> temporaryDirectory() | errfile | ".tmp"; if #errorList > 0 then ( if opts.Verbose then apply(errorList, (k, errfile) -> ( - stderr << locate inputs#k << " error:" << endl; - printerr getErrors(outfile errfile))); + if errfile =!= null then ( + stderr << locate inputs#k << " error:" << endl; + printerr getErrors(outfile errfile)))); error("test(s) #", demark(", ", toString \ first \ errorList), " of package ", toString pkg, " failed."))) checkAllPackages = () -> ( diff --git a/M2/Macaulay2/packages/JSON.m2 b/M2/Macaulay2/packages/JSON.m2 index fde10187981..71eb87a4120 100644 --- a/M2/Macaulay2/packages/JSON.m2 +++ b/M2/Macaulay2/packages/JSON.m2 @@ -1,15 +1,16 @@ 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 => "dtorrance@piedmont.edu", HomePage => "https://webwork.piedmont.edu/~dtorrance"}}, Keywords => {"System"}, PackageImports => {"Parsing"}, - AuxiliaryFiles => true) + AuxiliaryFiles => true, + TestFiles => {"test-parse.m2", "test-encode.m2"}) --------------- -- ChangeLog -- @@ -17,6 +18,9 @@ newPackage( -* +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") diff --git a/M2/Macaulay2/packages/Macaulay2Doc/functions/check-doc.m2 b/M2/Macaulay2/packages/Macaulay2Doc/functions/check-doc.m2 index 3197c81e0ab..cb3174bbc7c 100644 --- a/M2/Macaulay2/packages/Macaulay2Doc/functions/check-doc.m2 +++ b/M2/Macaulay2/packages/Macaulay2Doc/functions/check-doc.m2 @@ -25,12 +25,23 @@ Node If a test should be skipped when running @TO "check"@, e.g., it is known to fail under certain circumstances, then the comment @TT "-* no-check-flag *-"@ may be added to @TT "s"@. + + Tests may also be defined using arbitrary Macaulay2 code. Tests created + in this way will be called as functions with no arguments, and so it + is important to write them as such. For example, variables should be + local (see @TO "local variables in a function"@) and all but the final + statement should end with a @TO symbol ;@. + Example + TEST ( + x := 4; + assert(2 + 2 == x)) Caveat When creating tests, try to ensure that they run relatively quickly. SeeAlso assert beginDocumentation check + tests /// doc /// @@ -79,8 +90,9 @@ Node One provides tests using the @TO symbol TEST@ function following the @TO beginDocumentation@ call in the source of the package. - Optionally, one can store all tests in a @TT "tests.m2"@ directory under the auxiliary subdirectory of - the package and load the file from the main package source file. + Optionally, one can store tests as files in the auxiliary subdirectory of + the package and include their filenames in the @TO TestFiles@ option + to @TO newPackage@. For example, to run the tests for the @TO "LLLBases :: LLLBases"@ package (Lenstra-Lenstra-Lovasz bases), use: CannedExample diff --git a/M2/Macaulay2/packages/Macaulay2Doc/functions/package-doc.m2 b/M2/Macaulay2/packages/Macaulay2Doc/functions/package-doc.m2 index 6a2b022f9c3..e005d0ae875 100644 --- a/M2/Macaulay2/packages/Macaulay2Doc/functions/package-doc.m2 +++ b/M2/Macaulay2/packages/Macaulay2Doc/functions/package-doc.m2 @@ -271,6 +271,7 @@ Node [newPackage, PackageExports] [newPackage, PackageImports] [newPackage, Reload] + [newPackage, TestFiles] [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 diff --git a/M2/Macaulay2/packages/Macaulay2Doc/functions/tests-doc.m2 b/M2/Macaulay2/packages/Macaulay2Doc/functions/tests-doc.m2 index 3fae4f148f3..7d132dfb14e 100644 --- a/M2/Macaulay2/packages/Macaulay2Doc/functions/tests-doc.m2 +++ b/M2/Macaulay2/packages/Macaulay2Doc/functions/tests-doc.m2 @@ -5,9 +5,7 @@ doc /// (tests, String) (tests, ZZ, Package) (tests, ZZ, String) - TestInput - (code, TestInput) - (locate, TestInput) + TestClosure Headline locate a package's tests Usage @@ -17,25 +15,25 @@ doc /// i:ZZ pkg:{Package, String} Outputs - :{NumberedVerticalList, TestInput} + :{NumberedVerticalList, TestClosure} Description Text When an integer is not provided, this returns all the tests for the given package. The position of each element would be passed as the first argument of @TO check@ to run the test. - Each value is a @TT "TestInput"@ object. These are printed with + Each value is a @TT "TestClosure"@ object. These are printed with the location of the file so that you may quickly jump to the source code of the test when using Emacs. Example tests "FirstPackage" Text If the test number is also provided, then the corresponding - @TT "TestInput"@ object is returned. + @TT "TestClosure"@ object is returned. Example t = tests(0, "FirstPackage") Text The @TO locate@ and @TO code@ functions do the expected thing - when given a @TT "TestInput"@ object. + when given a @TT "TestClosure"@ object. Example locate t code t @@ -45,6 +43,6 @@ doc /// Example code 0 Text - You may also pass a @TT "TestInput"@ object to @TO edit@ to open the + You may also pass a @TT "TestClosure"@ object to @TO edit@ to open the code in your favorite editor. /// diff --git a/M2/Macaulay2/packages/MinimalPrimes/tests.m2 b/M2/Macaulay2/packages/MinimalPrimes/tests.m2 index 953d0f15b8c..32b7428b40d 100644 --- a/M2/Macaulay2/packages/MinimalPrimes/tests.m2 +++ b/M2/Macaulay2/packages/MinimalPrimes/tests.m2 @@ -39,13 +39,13 @@ TEST /// assert( intersect decompose J == J ) /// -TEST get(currentFileDirectory | "decompose-test.m2") -- FIXME: one test here may be wrong -TEST get(currentFileDirectory | "decompose2-test.m2") -- FIXME: not testing anything -TEST get(currentFileDirectory | "decompose4-test.m2") -TEST get(currentFileDirectory | "decompose5-test.m2") -TEST get(currentFileDirectory | "minprimes-test.m2") -TEST get(currentFileDirectory | "minprimes2-test.m2") -- TODO: add Binomial strategy -TEST get(currentFileDirectory | "radical-test.m2") -- FIXME: not testing anything +TEST get(MinimalPrimes#"auxiliary files" | "decompose-test.m2") -- FIXME: one test here may be wrong +TEST get(MinimalPrimes#"auxiliary files" | "decompose2-test.m2") -- FIXME: not testing anything +TEST get(MinimalPrimes#"auxiliary files" | "decompose4-test.m2") +TEST get(MinimalPrimes#"auxiliary files" | "decompose5-test.m2") +TEST get(MinimalPrimes#"auxiliary files" | "minprimes-test.m2") +TEST get(MinimalPrimes#"auxiliary files" | "minprimes2-test.m2") -- TODO: add Binomial strategy +TEST get(MinimalPrimes#"auxiliary files" | "radical-test.m2") -- FIXME: not testing anything TEST /// R = ZZ/101[a..d] diff --git a/M2/Macaulay2/packages/PrimaryDecomposition/tests.m2 b/M2/Macaulay2/packages/PrimaryDecomposition/tests.m2 index 79d5bdb4433..9e8be3ef6f9 100644 --- a/M2/Macaulay2/packages/PrimaryDecomposition/tests.m2 +++ b/M2/Macaulay2/packages/PrimaryDecomposition/tests.m2 @@ -37,9 +37,9 @@ TEST /// assert(primaryDecomposition M == {0}) /// -TEST get(currentFileDirectory | "associatedPrimes-test.m2") -TEST get(currentFileDirectory | "associatedPrimes2-test.m2") -TEST get(currentFileDirectory | "primaryDecomposition-test.m2") +TEST get(PrimaryDecomposition#"auxiliary files" | "associatedPrimes-test.m2") +TEST get(PrimaryDecomposition#"auxiliary files" | "associatedPrimes2-test.m2") +TEST get(PrimaryDecomposition#"auxiliary files" | "primaryDecomposition-test.m2") testResult = method() testResult(Ideal,List) := (I,L) -> ( diff --git a/M2/Macaulay2/packages/RInterface/test.m2 b/M2/Macaulay2/packages/RInterface/test.m2 index 7d3002c92ce..8a3f9dcf17f 100644 --- a/M2/Macaulay2/packages/RInterface/test.m2 +++ b/M2/Macaulay2/packages/RInterface/test.m2 @@ -6,194 +6,188 @@ -- tests -- ----------- -TEST /// --- basic conversions -assert BinaryOperation(symbol ===, value RObject null, null) -assert Equation(value RObject (1, 2, 3), (1, 2, 3)) -assert BinaryOperation(symbol ===, - value RObject ("foo" => 1, "bar" => 2), ("foo" => 1, "bar" => 2)) -assert Equation(value RObject true, true) -assert Equation(value RObject false, false) -assert Equation(value RObject 5, 5) -assert Equation(value RObject 0.2, 0.2) -assert Equation(value RObject(1/2), 0.5) -assert Equation(value RObject pi, numeric pi) -assert Equation(value RObject(2 + 3*ii), 2 + 3*ii) -assert Equation(value RObject "foo", "foo") -assert Equation(value RObject {1, 2, 3}, {1, 2, 3}) -assert BinaryOperation(symbol ===, - value RObject {"foo" => 1, "bar" => 2}, {"foo" => 1, "bar" => 2}) -/// +TEST ( + -- basic conversions + assert BinaryOperation(symbol ===, value RObject null, null); + assert Equation(value RObject (1, 2, 3), (1, 2, 3)); + assert BinaryOperation(symbol ===, + value RObject ("foo" => 1, "bar" => 2), ("foo" => 1, "bar" => 2)); + assert Equation(value RObject true, true); + assert Equation(value RObject false, false); + assert Equation(value RObject 5, 5); + assert Equation(value RObject 0.2, 0.2); + assert Equation(value RObject(1/2), 0.5); + assert Equation(value RObject pi, numeric pi); + assert Equation(value RObject(2 + 3*ii), 2 + 3*ii); + assert Equation(value RObject "foo", "foo"); + assert Equation(value RObject {1, 2, 3}, {1, 2, 3}); + assert BinaryOperation(symbol ===, + value RObject {"foo" => 1, "bar" => 2}, {"foo" => 1, "bar" => 2})) -TEST /// --- iterators -assert Equation(toList RObject null, {}) -c = RFunction "c" -assert Equation(value c(true, false), {true, false}) -assert Equation(value c(1, 2, 3), {1, 2, 3}) -assert Equation(value c(1.5, 2.5), {1.5, 2.5}) -assert Equation(value c(ii, 2*ii), {ii, 2*ii}) -assert Equation(value c("foo", "bar"), {"foo", "bar"}) -list' = RFunction "list" -assert Equation(value list'(true, 2, pi), {true, 2, numeric pi}) -/// +TEST ( + -- iterators + assert Equation(toList RObject null, {}); + c := RFunction "c"; + assert Equation(value c(true, false), {true, false}); + assert Equation(value c(1, 2, 3), {1, 2, 3}); + assert Equation(value c(1.5, 2.5), {1.5, 2.5}); + assert Equation(value c(ii, 2*ii), {ii, 2*ii}); + assert Equation(value c("foo", "bar"), {"foo", "bar"}); + list' := RFunction "list"; + assert Equation(value list'(true, 2, pi), {true, 2, numeric pi})) -TEST /// --- subscripting -x = RObject {2, 4, 6, 8, 10} -assert Equation(x_1, RObject 2) -assert Equation(x_2, RObject 4) -assert Equation(x_3, RObject 6) -assert Equation(x_4, RObject 8) -assert Equation(x_5, RObject 10) -assert Equation(x[1], RObject 2) -assert Equation(x[1, 3, 5], RObject {2, 6, 10}) -assert Equation(x_1 = 3, RObject {3, 4, 6, 8, 10}) -assert Equation(x[1, 3, 5] = {3, 7, 11}, RObject {3, 4, 7, 8, 11}) -/// +TEST ( + -- subscripting + x := RObject {2, 4, 6, 8, 10}; + assert Equation(x_1, RObject 2); + assert Equation(x_2, RObject 4); + assert Equation(x_3, RObject 6); + assert Equation(x_4, RObject 8); + assert Equation(x_5, RObject 10); + assert Equation(x[1], RObject 2); + assert Equation(x[1, 3, 5], RObject {2, 6, 10}); + assert Equation(x_1 = 3, RObject {3, 4, 6, 8, 10}); + assert Equation(x[1, 3, 5] = {3, 7, 11}, RObject {3, 4, 7, 8, 11})) -TEST /// --- binary operators -assert Equation(RObject 5 + RObject 2, RObject 7) -assert Equation(RObject 5 + 2, RObject 7) -assert Equation(5 + RObject 2, RObject 7) -assert Equation(RObject 5 - RObject 2, RObject 3) -assert Equation(RObject 5 - 2, RObject 3) -assert Equation(5 - RObject 2, RObject 3) -assert Equation(RObject 5 * RObject 2, RObject 10) -assert Equation(RObject 5 * 2, RObject 10) -assert Equation(5 * RObject 2, RObject 10) -assert Equation(RObject 5 / RObject 2, RObject 2.5) -assert Equation(RObject 5 / 2, RObject 2.5) -assert Equation(5 / RObject 2, RObject 2.5) -assert Equation(RObject 5^(RObject 2), RObject 25) -assert Equation(RObject 5^2, RObject 25) -assert Equation(5^(RObject 2), RObject 25) -assert Equation(RObject 5 % RObject 2, RObject 1) -assert Equation(RObject 5 % 2, RObject 1) -assert Equation(5 % RObject 2, RObject 1) -assert Equation(RObject 5 // RObject 2, RObject 2) -assert Equation(RObject 5 // 2, RObject 2) -assert Equation(5 // RObject 2, RObject 2) -assert Equation(RObject 5 ?? RObject 2, RObject 5) -assert Equation(RObject null ?? RObject 2, RObject 2) -/// +TEST ( + -- binary operators + assert Equation(RObject 5 + RObject 2, RObject 7); + assert Equation(RObject 5 + 2, RObject 7); + assert Equation(5 + RObject 2, RObject 7); + assert Equation(RObject 5 - RObject 2, RObject 3); + assert Equation(RObject 5 - 2, RObject 3); + assert Equation(5 - RObject 2, RObject 3); + assert Equation(RObject 5 * RObject 2, RObject 10); + assert Equation(RObject 5 * 2, RObject 10); + assert Equation(5 * RObject 2, RObject 10); + assert Equation(RObject 5 / RObject 2, RObject 2.5); + assert Equation(RObject 5 / 2, RObject 2.5); + assert Equation(5 / RObject 2, RObject 2.5); + assert Equation(RObject 5^(RObject 2), RObject 25); + assert Equation(RObject 5^2, RObject 25); + assert Equation(5^(RObject 2), RObject 25); + assert Equation(RObject 5 % RObject 2, RObject 1); + assert Equation(RObject 5 % 2, RObject 1); + assert Equation(5 % RObject 2, RObject 1); + assert Equation(RObject 5 // RObject 2, RObject 2); + assert Equation(RObject 5 // 2, RObject 2); + assert Equation(5 // RObject 2, RObject 2); + assert Equation(RObject 5 ?? RObject 2, RObject 5); + assert Equation(RObject null ?? RObject 2, RObject 2)) -TEST /// --- logic operators -assert Equation(RObject true and RObject true, RObject true) -assert Equation(RObject true and true, RObject true) -assert Equation(true and RObject true, RObject true) -assert Equation(RObject true or RObject true, RObject true) -assert Equation(RObject true or true, RObject true) -assert Equation(true or RObject true, RObject true) -assert Equation(RObject true xor RObject true, RObject false) -assert Equation(RObject true xor true, RObject false) -assert Equation(true xor RObject true, RObject false) -assert Equation(not RObject true, RObject false) -/// +TEST ( + -- logic operators + assert Equation(RObject true and RObject true, RObject true); + assert Equation(RObject true and true, RObject true); + assert Equation(true and RObject true, RObject true); + assert Equation(RObject true or RObject true, RObject true); + assert Equation(RObject true or true, RObject true); + assert Equation(true or RObject true, RObject true); + assert Equation(RObject true xor RObject true, RObject false); + assert Equation(RObject true xor true, RObject false); + assert Equation(true xor RObject true, RObject false); + assert Equation(not RObject true, RObject false)) -TEST /// --- comparison operators -assert Equation(RObject 2, RObject 2) -assert Equation(RObject 2, 2) -assert Equation(2, RObject 2) -assert BinaryOperation(symbol <, RObject 2, RObject 3) -assert BinaryOperation(symbol <, RObject 2, 3) -assert BinaryOperation(symbol <, 2, RObject 3) -assert BinaryOperation(symbol <=, RObject 2, RObject 3) -assert BinaryOperation(symbol <=, RObject 2, 3) -assert BinaryOperation(symbol <=, 2, RObject 3) -assert BinaryOperation(symbol >, RObject 3, RObject 2) -assert BinaryOperation(symbol >, RObject 3, 2) -assert BinaryOperation(symbol >, 3, RObject 2) -assert BinaryOperation(symbol >=, RObject 3, RObject 2) -assert BinaryOperation(symbol >=, RObject 3, 2) -assert BinaryOperation(symbol >=, 3, RObject 2) -assert BinaryOperation(symbol !=, RObject 2, RObject 3) -assert BinaryOperation(symbol !=, RObject 2, 3) -assert BinaryOperation(symbol !=, 2, RObject 3) -/// +TEST ( + -- comparison operators + assert Equation(RObject 2, RObject 2); + assert Equation(RObject 2, 2); + assert Equation(2, RObject 2); + assert BinaryOperation(symbol <, RObject 2, RObject 3); + assert BinaryOperation(symbol <, RObject 2, 3); + assert BinaryOperation(symbol <, 2, RObject 3); + assert BinaryOperation(symbol <=, RObject 2, RObject 3); + assert BinaryOperation(symbol <=, RObject 2, 3); + assert BinaryOperation(symbol <=, 2, RObject 3); + assert BinaryOperation(symbol >, RObject 3, RObject 2); + assert BinaryOperation(symbol >, RObject 3, 2); + assert BinaryOperation(symbol >, 3, RObject 2); + assert BinaryOperation(symbol >=, RObject 3, RObject 2); + assert BinaryOperation(symbol >=, RObject 3, 2); + assert BinaryOperation(symbol >=, 3, RObject 2); + assert BinaryOperation(symbol !=, RObject 2, RObject 3); + assert BinaryOperation(symbol !=, RObject 2, 3); + assert BinaryOperation(symbol !=, 2, RObject 3)) -TEST /// --- matrices/arrays -c = RFunction "c" -matrix' = RFunction "matrix" -array = RFunction "array" -assert Equation(value matrix'(c(1, 2, 3, 11, 12, 13), "nrow" => 2, "ncol" => 3), - {{1, 2}, {3, 11}, {12, 13}}) -assert Equation(value array(c splice(5, 9, 3, 10..15), "dim" => c(3, 3, 2)), { - {{5, 9, 3}, {10, 11, 12}, {13, 14, 15}}, - {{5, 9, 3}, {10, 11, 12}, {13, 14, 15}}}) -/// +TEST ( + -- matrices/arrays + c := RFunction "c"; + matrix' := RFunction "matrix"; + array := RFunction "array"; + assert Equation( + value matrix'(c(1, 2, 3, 11, 12, 13), "nrow" => 2, "ncol" => 3), + {{1, 2}, {3, 11}, {12, 13}}); + assert Equation( + value array(c splice(5, 9, 3, 10..15), "dim" => c(3, 3, 2)), { + {{5, 9, 3}, {10, 11, 12}, {13, 14, 15}}, + {{5, 9, 3}, {10, 11, 12}, {13, 14, 15}}})) -TEST /// --- functions -assert Equation(+RObject 1, RObject 1) -assert Equation(-RObject 1, RObject(-1)) -assert Equation(abs RObject(-1), RObject 1) -assert Equation(acos RObject 1, RObject 0) -assert Equation(acosh RObject 1, RObject 0) -assert Equation(asin RObject 0, RObject 0) -assert Equation(asinh RObject 0, RObject 0) -assert Equation(atan RObject 0, RObject 0) -assert Equation(atanh RObject 0, RObject 0) -assert Equation(ceiling RObject 2.5, RObject 3) -assert Equation(cos RObject 0, RObject 1) -assert Equation(cosh RObject 0, RObject 1) -assert Equation(exp RObject 0, RObject 1) -assert Equation(expm1 RObject 0, RObject 0) -assert Equation(floor RObject 2.5, RObject 2) -assert Equation(log RObject 1, RObject 0) -assert Equation(log1p RObject 0, RObject 0) -assert Equation(max RObject {1, 3, 5}, RObject 5) -assert Equation(min RObject {1, 3, 5}, RObject 1) -assert Equation(round RObject 2.6, RObject 3) -assert Equation(sin RObject 0, RObject 0) -assert Equation(sinh RObject 0, RObject 0) -assert Equation(sqrt RObject 1, RObject 1) -assert Equation(sum RObject {1, 3, 5}, RObject 9) -assert Equation(tan RObject 0, RObject 0) -assert Equation(tanh RObject 0, RObject 0) -assert Equation((RObject 1)!, RObject 1) -assert Equation((RObject 1)~, RObject(-2)) -assert Equation(conjugate RObject ii, RObject(-ii)) -assert(abs(Digamma RObject 1 + RObject EulerConstant) < - RObject(1e-15)) -assert Equation(Gamma RObject 1, RObject 1) -assert Equation(imaginaryPart RObject ii, RObject 1) -assert Equation(lngamma RObject 1, RObject 0) -assert Equation(product RObject {1, 3, 5}, RObject 15) -assert Equation(realPart RObject ii, RObject 0) -assert Equation(truncate RObject 2.5, RObject 2) -assert Equation(value((RObject 1):(RObject 5)), {1, 2, 3, 4, 5}) -assert Equation(value((RObject 1):5), {1, 2, 3, 4, 5}) -assert Equation(value((RObject 1)..(RObject 5)), {1, 2, 3, 4, 5}) -assert Equation(value((RObject 1)..5), {1, 2, 3, 4, 5}) -assert Equation(value(1..(RObject 5)), {1, 2, 3, 4, 5}) -assert Equation(RObject 3 & RObject 5, RObject 1) -assert Equation(RObject 3 & 5, RObject 1) -assert Equation(3 & RObject 5, RObject 1) -assert Equation(RObject 3 | RObject 5, RObject 7) -assert Equation(RObject 3 | 5, RObject 7) -assert Equation(3 | RObject 5, RObject 7) -assert Equation(RObject 3 ^^ RObject 5, RObject 6) -assert Equation(RObject 3 ^^ 5, RObject 6) -assert Equation(3 ^^ RObject 5, RObject 6) -assert Equation(RObject 3 << RObject 5, RObject 96) -assert Equation(RObject 3 << 5, RObject 96) -assert Equation(3 << RObject 5, RObject 96) -assert Equation(RObject 10 >> RObject 1, RObject 5) -assert Equation(RObject 10 >> 1, RObject 5) -assert Equation(10 >> RObject 1, RObject 5) -assert Equation(atan2(RObject 0, RObject 1), RObject 0) -assert Equation(atan2(RObject 0, 1), RObject 0) -assert Equation(atan2(0, RObject 1), RObject 0) -assert Equation(Beta(RObject 1, RObject 1), RObject 1) -assert Equation(Beta(RObject 1, 1), RObject 1) -assert Equation(Beta(1, RObject 1), RObject 1) -assert Equation(binomial(RObject 1, RObject 1), RObject 1) -assert Equation(binomial(RObject 1, 1), RObject 1) -assert Equation(binomial(1, RObject 1), RObject 1) -/// +TEST ( + -- functions + assert Equation(+RObject 1, RObject 1); + assert Equation(-RObject 1, RObject(-1)); + assert Equation(abs RObject(-1), RObject 1); + assert Equation(acos RObject 1, RObject 0); + assert Equation(acosh RObject 1, RObject 0); + assert Equation(asin RObject 0, RObject 0); + assert Equation(asinh RObject 0, RObject 0); + assert Equation(atan RObject 0, RObject 0); + assert Equation(atanh RObject 0, RObject 0); + assert Equation(ceiling RObject 2.5, RObject 3); + assert Equation(cos RObject 0, RObject 1); + assert Equation(cosh RObject 0, RObject 1); + assert Equation(exp RObject 0, RObject 1); + assert Equation(expm1 RObject 0, RObject 0); + assert Equation(floor RObject 2.5, RObject 2); + assert Equation(log RObject 1, RObject 0); + assert Equation(log1p RObject 0, RObject 0); + assert Equation(max RObject {1, 3, 5}, RObject 5); + assert Equation(min RObject {1, 3, 5}, RObject 1); + assert Equation(round RObject 2.6, RObject 3); + assert Equation(sin RObject 0, RObject 0); + assert Equation(sinh RObject 0, RObject 0); + assert Equation(sqrt RObject 1, RObject 1); + assert Equation(sum RObject {1, 3, 5}, RObject 9); + assert Equation(tan RObject 0, RObject 0); + assert Equation(tanh RObject 0, RObject 0); + assert Equation((RObject 1)!, RObject 1); + assert Equation((RObject 1)~, RObject(-2)); + assert Equation(conjugate RObject ii, RObject(-ii)); + assert(abs(Digamma RObject 1 + RObject EulerConstant) < + RObject(1e-15)); + assert Equation(Gamma RObject 1, RObject 1); + assert Equation(imaginaryPart RObject ii, RObject 1); + assert Equation(lngamma RObject 1, RObject 0); + assert Equation(product RObject {1, 3, 5}, RObject 15); + assert Equation(realPart RObject ii, RObject 0); + assert Equation(truncate RObject 2.5, RObject 2); + assert Equation(value((RObject 1):(RObject 5)), {1, 2, 3, 4, 5}); + assert Equation(value((RObject 1):5), {1, 2, 3, 4, 5}); + assert Equation(value((RObject 1)..(RObject 5)), {1, 2, 3, 4, 5}); + assert Equation(value((RObject 1)..5), {1, 2, 3, 4, 5}); + assert Equation(value(1..(RObject 5)), {1, 2, 3, 4, 5}); + assert Equation(RObject 3 & RObject 5, RObject 1); + assert Equation(RObject 3 & 5, RObject 1); + assert Equation(3 & RObject 5, RObject 1); + assert Equation(RObject 3 | RObject 5, RObject 7); + assert Equation(RObject 3 | 5, RObject 7); + assert Equation(3 | RObject 5, RObject 7); + assert Equation(RObject 3 ^^ RObject 5, RObject 6); + assert Equation(RObject 3 ^^ 5, RObject 6); + assert Equation(3 ^^ RObject 5, RObject 6); + assert Equation(RObject 3 << RObject 5, RObject 96); + assert Equation(RObject 3 << 5, RObject 96); + assert Equation(3 << RObject 5, RObject 96); + assert Equation(RObject 10 >> RObject 1, RObject 5); + assert Equation(RObject 10 >> 1, RObject 5); + assert Equation(10 >> RObject 1, RObject 5); + assert Equation(atan2(RObject 0, RObject 1), RObject 0); + assert Equation(atan2(RObject 0, 1), RObject 0); + assert Equation(atan2(0, RObject 1), RObject 0); + assert Equation(Beta(RObject 1, RObject 1), RObject 1); + assert Equation(Beta(RObject 1, 1), RObject 1); + assert Equation(Beta(1, RObject 1), RObject 1); + assert Equation(binomial(RObject 1, RObject 1), RObject 1); + assert Equation(binomial(RObject 1, 1), RObject 1); + assert Equation(binomial(1, RObject 1), RObject 1)) diff --git a/M2/Macaulay2/packages/Saturation/saturate-test.m2 b/M2/Macaulay2/packages/Saturation/saturate-test.m2 index d778a091604..0c2091bc8bc 100644 --- a/M2/Macaulay2/packages/Saturation/saturate-test.m2 +++ b/M2/Macaulay2/packages/Saturation/saturate-test.m2 @@ -27,9 +27,9 @@ TEST /// assert(Q == quotient(Q, a)) /// -TEST get(currentFileDirectory | "saturate3.m2") -TEST get(currentFileDirectory | "saturate4.m2") -TEST get(currentFileDirectory | "saturate5.m2") +TEST get(Saturation#"auxiliary files" | "saturate3.m2") +TEST get(Saturation#"auxiliary files" | "saturate4.m2") +TEST get(Saturation#"auxiliary files" | "saturate5.m2") TEST /// -- used to be in tests/quarantine/saturate.m2 diff --git a/M2/Macaulay2/packages/TerraciniLoci.m2 b/M2/Macaulay2/packages/TerraciniLoci.m2 index 23c558b28fa..98d64c5a967 100644 --- a/M2/Macaulay2/packages/TerraciniLoci.m2 +++ b/M2/Macaulay2/packages/TerraciniLoci.m2 @@ -31,8 +31,8 @@ newPackage("TerraciniLoci", Headline => "Terracini loci of projective varieties", - Version => "0.1", - Date => "November 16, 2023", + Version => "0.2", + Date => "September 22, 2024", Authors => { { Name => "Francesco Galuppi", @@ -50,9 +50,26 @@ newPackage("TerraciniLoci", HomePage => "https://github.com/d-torrance/terracini-loci", Keywords => {"Projective Algebraic Geometry"}, PackageImports => { - "CorrespondenceScrolls", - "FastMinors", - "MinimalPrimes"}) + "CorrespondenceScrolls",-- for productOfProjectiveSpaces + "FastMinors", -- for recursiveMinors + "MinimalPrimes", -- for radical + "PrimaryDecomposition", -- for primaryDecomposition (tests) + "Resultants"}) -- for veronese (tests) + +--------------- +-- ChangeLog -- +--------------- + +-* + +0.2 (2024-09-22, M2 1.24.11) +* convert tests from strings to functions for new TEST behavior +* add PrimaryDecomposition and Resultants to PackageImports (needed for tests) + +0.1 (2023-11-16, M2 1.23) +* initial release + +*- export { "terraciniLocus" @@ -181,71 +198,64 @@ doc /// ----------- -- just the faster (< 1s) examples -TEST /// --- rational normal curves -needsPackage "Resultants" -assertEmptyTerracini = (r, f) -> assert Equation(terraciniLocus(r, f), 1) - --- ring map -assertEmptyTerracini(2, veronese(1, 3)) -assertEmptyTerracini(2, veronese(1, 4)) - --- ideal (slower) -assertEmptyTerracini(2, ker veronese(1, 3)) - --- also check Threads option -assert Equation(terraciniLocus(2, veronese(1, 3), Threads => 2), 1) -/// - -TEST /// --- del pezzo surfaces -delPezzoSurface = t -> ( - kk := ZZ/32003; - d := 9 - t; - (x, y) := (symbol x, symbol y); - R := kk[y_0..y_2]; - S := kk[x_0..x_d]; - P := intersect \\ ideal \ { - {y_0, y_1}, {y_0, y_2}, {y_1, y_2}, {y_0 - y_1, y_0 - y_2} - }_{0..t - 1}; - map(R, S, super basis(3, P))) - -assert Equation( - apply(primaryDecomposition terraciniLocus(2, delPezzoSurface 1), - I -> dim I - 2), {3}) -assert Equation( - apply(primaryDecomposition terraciniLocus(2, delPezzoSurface 2), - I -> dim I - 2), {3, 3}) -assert Equation( - apply(primaryDecomposition terraciniLocus(2, delPezzoSurface 3), - I -> dim I - 2), {3, 3, 3}) -assert Equation( - apply(primaryDecomposition terraciniLocus(2, delPezzoSurface 4), - I -> dim I - 2), {3, 3, 3, 3, 3}) -/// - -TEST /// --- veronese -needsPackage "Resultants" - -assert Equation(terraciniLocus(2, veronese(2, 3)), 1) -/// - -TEST /// --- segre-veronese - -segreVeronese = (n, d) -> ( - x := symbol x; - r := #n; - R := QQ new Array from splice apply(r, i -> x_(i, 0)..x_(i, n#i)); - y := symbol y; - S := QQ[y_0..y_(product(n, d, (ni, di) -> binomial(ni + di, di)) - 1)]; - map(R, S, flatten entries first tensor apply(r, i -> ( - vector apply(subsets(n#i + d#i, d#i), A -> product(d#i, j -> - x_(i, A#j - j))))))) - -assert Equation( - apply( - primaryDecomposition terraciniLocus(2, segreVeronese({1, 1}, {1, 2})), - I -> dim I - 4), {3, 3}) -/// +TEST ( + -- rational normal curves + assertEmptyTerracini := (r, f) -> assert Equation(terraciniLocus(r, f), 1); + + -- ring map + assertEmptyTerracini(2, veronese(1, 3)); + assertEmptyTerracini(2, veronese(1, 4)); + + -- ideal (slower) + assertEmptyTerracini(2, ker veronese(1, 3)); + + -- also check Threads option + assert Equation(terraciniLocus(2, veronese(1, 3), Threads => 2), 1)) + +TEST ( + -- del pezzo surfaces + delPezzoSurface := t -> ( + kk := ZZ/32003; + d := 9 - t; + (x, y) := (symbol x, symbol y); + R := kk[y_0..y_2]; + S := kk[x_0..x_d]; + P := intersect \\ ideal \ { + {y_0, y_1}, {y_0, y_2}, {y_1, y_2}, {y_0 - y_1, y_0 - y_2} + }_{0..t - 1}; + map(R, S, super basis(3, P))); + + assert Equation( + apply(primaryDecomposition terraciniLocus(2, delPezzoSurface 1), + I -> dim I - 2), {3}); + assert Equation( + apply(primaryDecomposition terraciniLocus(2, delPezzoSurface 2), + I -> dim I - 2), {3, 3}); + assert Equation( + apply(primaryDecomposition terraciniLocus(2, delPezzoSurface 3), + I -> dim I - 2), {3, 3, 3}); + assert Equation( + apply(primaryDecomposition terraciniLocus(2, delPezzoSurface 4), + I -> dim I - 2), {3, 3, 3, 3, 3})) + +TEST ( + -- veronese + assert Equation(terraciniLocus(2, veronese(2, 3)), 1)) + +TEST ( + -- segre-veronese + + segreVeronese := (n, d) -> ( + x := symbol x; + r := #n; + R := QQ new Array from splice apply(r, i -> x_(i, 0)..x_(i, n#i)); + y := symbol y; + S := QQ[y_0..y_(product(n, d, (ni, di) -> binomial(ni + di, di)) - 1)]; + map(R, S, flatten entries first tensor apply(r, i -> ( + vector apply(subsets(n#i + d#i, d#i), A -> product(d#i, j -> + x_(i, A#j - j))))))); + + assert Equation( + apply( + primaryDecomposition terraciniLocus(2, segreVeronese({1, 1}, {1, 2})), + I -> dim I - 4), {3, 3})) diff --git a/M2/Macaulay2/tests/normal/testing.m2 b/M2/Macaulay2/tests/normal/testing.m2 index 0a7f557203a..24219261214 100644 --- a/M2/Macaulay2/tests/normal/testing.m2 +++ b/M2/Macaulay2/tests/normal/testing.m2 @@ -6,18 +6,15 @@ TEST "assert Equation(1 + 1, 2)" loadPackage("TestPackage", FileName => testpkg) check "TestPackage" pkgtest = tests(0, "TestPackage") -assert instance(pkgtest, TestInput) -assert Equation(toSequence locate pkgtest, (testpkg, 3, 5, 3, 32, 3, 5)) -assert Equation(toString pkgtest, "assert Equation(1 + 1, 2)") -assert Equation(net pkgtest, "TestInput[" | testpkg | ":3:5-3:32]") +assert instance(pkgtest, TestClosure) +loc = (testpkg, 3, 0, 3, 32, 3, 0) +assert Equation(toSequence locate pkgtest, loc) beginDocumentation() -expectedCode = DIV{ - new FilePosition from (testpkg, 3, 5, 3, 32, 3, 5), - ": --source code:", - PRE{CODE{"class" => "language-macaulay2", - "TEST \"assert Equation(1 + 1, 2)\""}}} -assert BinaryOperation(symbol ===, code pkgtest, expectedCode) -assert BinaryOperation(symbol ===, code 0, expectedCode) +expectedCode = net((net new FilePosition from loc) | ///: --source code: +TEST "assert Equation(1 + 1, 2)"///) +printWidth = 0 -- don't wrap +assert Equation(net code pkgtest, expectedCode) +assert Equation(net code 0, expectedCode) assert( (for i from 1 to 2 list { for j from 1 to 2 do { if j == 2 then break 444; } }) === {{444}, {444}} ) -- see issue #2522