summaryrefslogtreecommitdiff
path: root/src/Test/Builtins.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-09-28 11:53:34 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-09-28 12:37:17 +0200
commitf91ff15b9551cd0d325dbd03f066d48dfd70ed25 (patch)
treecd35fb0ec6d3e21b1c8c31e912bb472a335f24f7 /src/Test/Builtins.hs
parentdf1d8d72a06a7d4b3b8801dce0374e6b0294f628 (diff)
Implement "send" as a builtin
Diffstat (limited to 'src/Test/Builtins.hs')
-rw-r--r--src/Test/Builtins.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Test/Builtins.hs b/src/Test/Builtins.hs
index 3f42335..774ad70 100644
--- a/src/Test/Builtins.hs
+++ b/src/Test/Builtins.hs
@@ -3,13 +3,16 @@ module Test.Builtins (
) where
import Data.Map qualified as M
+import Data.Text (Text)
import Data.Typeable
+import Process (Process)
import Test
builtins :: [ ( VarName, SomeVarValue ) ]
builtins =
- [ ( VarName "guard", builtinGuard )
+ [ ( VarName "send", builtinSend )
+ , ( VarName "guard", builtinGuard )
, ( VarName "wait", builtinWait )
]
@@ -19,6 +22,15 @@ getArg (FunctionArguments args) kw =
Just (SomeExpr expr) | Just expr' <- cast expr -> expr'
_ -> error "parameter mismatch"
+builtinSend :: SomeVarValue
+builtinSend = SomeVarValue (FunctionArguments $ M.fromList atypes) $
+ \_ args -> TestBlock [ Send (getArg args (Just "to")) (getArg args Nothing) ]
+ where
+ atypes =
+ [ ( Just "to", SomeArgumentType (ContextDefault @Process) )
+ , ( Nothing, SomeArgumentType (NoDefault @Text) )
+ ]
+
builtinGuard :: SomeVarValue
builtinGuard = SomeVarValue (FunctionArguments $ M.singleton Nothing (SomeArgumentType (NoDefault @Bool))) $
\sline args -> TestBlock [ Guard sline (getArg args Nothing) ]