-
Notifications
You must be signed in to change notification settings - Fork 476
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
[Test] Add do-notation support for 'TestNested' #5948
Changes from 3 commits
75ab43c
e465bba
9945a60
3ce6337
6740703
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 |
---|---|---|
|
@@ -131,7 +131,7 @@ compileProgram = curry $ \case | |
(SUplc _ _, SPir SName _) -> throwingPIR "Cannot compile uplc to pir" | ||
|
||
embedProgram :: PLC.Program tyname name uni fun ann -> PIR.Program tyname name uni fun ann | ||
embedProgram (PLC.Program a v t) = PIR.Program a v $ embed t | ||
embedProgram (PLC.Program a v t) = PIR.Program a v $ embedTerm t | ||
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.
|
||
|
||
toOutAnn :: (Functor f, PIR.AsError e uni fun a, MonadError e m) | ||
=> SAnn s1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ import Types | |
import UntypedPlutusCore as UPLC | ||
import UntypedPlutusCore.Evaluation.Machine.Cek as UPLC | ||
|
||
import Data.Foldable | ||
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'm going to occasionally update |
||
import Data.Text as Text | ||
|
||
runRun :: (?opts :: Opts) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,7 @@ test_PrettyReadable = | |
where | ||
folder :: Pretty fun => PlcFolderContents DefaultUni fun -> TestTree | ||
folder | ||
= runTestNestedIn ["plutus-core", "test", "Pretty", "Golden"] | ||
. testNested "Readable" | ||
= runTestNested ["plutus-core", "test", "Pretty", "Golden", "Readable"] | ||
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.
|
||
. foldPlcFolderContents testNested testReadable testReadable | ||
|
||
test_Pretty :: TestTree | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,8 +67,7 @@ foldAssertWell | |
-> PlcFolderContents DefaultUni fun | ||
-> TestTree | ||
foldAssertWell semvar | ||
= runTestNestedIn ["plutus-core", "test", "TypeSynthesis"] | ||
. testNested "Golden" | ||
= runTestNested ["plutus-core", "test", "TypeSynthesis", "Golden"] | ||
. foldPlcFolderContents testNested | ||
(\name -> nestedGoldenVsErrorOrThing name . kindcheck) | ||
(\name -> nestedGoldenVsErrorOrThing name . typecheck semvar) | ||
|
@@ -126,29 +125,28 @@ test_typecheckIllTyped = | |
TypeErrorE (NameMismatch {}) -> True | ||
_ -> False | ||
] | ||
|
||
test_typecheckAllFun | ||
:: forall fun. (ToBuiltinMeaning DefaultUni fun, Show fun) | ||
:: forall fun. (ToBuiltinMeaning DefaultUni fun, Show fun, Show (BuiltinSemanticsVariant fun)) | ||
=> String | ||
-> BuiltinSemanticsVariant fun | ||
-> TestTree | ||
test_typecheckAllFun name semvar | ||
= runTestNestedIn ["plutus-core", "test", "TypeSynthesis", "Golden"] | ||
. testNested name | ||
-> TestNested | ||
test_typecheckAllFun name semVar | ||
= testNestedNamed name (show semVar) | ||
Comment on lines
-131
to
+135
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 would previously print |
||
. map testFun | ||
$ enumerate @fun | ||
where | ||
testFun fun = | ||
nestedGoldenVsErrorOrThing (show fun) . kindcheck $ typeOfBuiltinFunction semvar fun | ||
nestedGoldenVsErrorOrThing (show fun) . kindcheck $ typeOfBuiltinFunction semVar fun | ||
|
||
test_typecheckDefaultFuns :: TestTree | ||
test_typecheckDefaultFuns = | ||
-- This checks that for each set of builtins the Plutus type of every builtin is the same | ||
-- regardless of versioning. | ||
testGroup "builtins" $ concat | ||
[ map (test_typecheckAllFun @DefaultFun "DefaultFun") enumerate | ||
, map (test_typecheckAllFun @ExtensionFun "ExtensionFun") enumerate | ||
] | ||
testGroup "builtins" . pure $ | ||
runTestNested ["plutus-core", "test", "TypeSynthesis", "Golden"] $ concat | ||
[ map (test_typecheckAllFun @DefaultFun "DefaultFun") enumerate | ||
, map (test_typecheckAllFun @ExtensionFun "ExtensionFun") enumerate | ||
] | ||
|
||
test_typecheck :: TestTree | ||
test_typecheck = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,15 @@ import Test.Tasty.Extras | |
|
||
test_datatypes :: TestTree | ||
test_datatypes = | ||
runTestNestedIn ["plutus-ir", "test", "PlutusIR", "Compiler"] $ testNested "Datatype" | ||
[ goldenPlcFromPir pTermAsProg "maybe" | ||
, goldenPlcFromPir pTermAsProg "listMatch" | ||
, goldenPlcFromPir pTermAsProg "idleAll" | ||
, goldenPlcFromPir pTermAsProg "some" | ||
, goldenEvalPir pTermAsProg "listMatchEval" | ||
, goldenTypeFromPir topSrcSpan pTerm "dataEscape" | ||
, testNested "scott" | ||
[ goldenPlcFromPirScott pTermAsProg "maybe" | ||
, goldenPlcFromPirScott pTermAsProg "listMatch" | ||
runTestNested ["plutus-ir", "test", "PlutusIR", "Compiler", "Datatype"] | ||
[ goldenPlcFromPir pTermAsProg "maybe" | ||
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. Made formatting of all the test trees consistent while I was there anyway. |
||
, goldenPlcFromPir pTermAsProg "listMatch" | ||
, goldenPlcFromPir pTermAsProg "idleAll" | ||
, goldenPlcFromPir pTermAsProg "some" | ||
, goldenEvalPir pTermAsProg "listMatchEval" | ||
, goldenTypeFromPir topSrcSpan pTerm "dataEscape" | ||
, testNested "scott" | ||
[ goldenPlcFromPirScott pTermAsProg "maybe" | ||
, goldenPlcFromPirScott pTermAsProg "listMatch" | ||
] | ||
] | ||
] |
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 know this is more wordy than it used to be, but here's my reasoning:
TestNested
stuff should have the same ergonomics asTestTree
and if you want to add an indirection/label in the latter case you usetestGroup name . pure
, so here we're doing the same thing except it'srunTestNested path . pure
(below you'll find examples oftestNested name . pure
). It kinda feels weird to have a special runner when there's "GHC" at the end of the path, given that this is easy to create on the fly without adding more stuff to the API.This could also be written as
but I decided to make it the
pure
version for the reader to learn that they can do it here and similarly with the regulartestGroup
.Also before the API would nudge you into always having "GHC" at the end of the path, now you're forced to make a choice yourself.