Skip to content

Commit

Permalink
Merge pull request #114 from jazzbox35/main
Browse files Browse the repository at this point in the history
sealing function ontology and test updates
  • Loading branch information
TeamSPoon authored Sep 5, 2024
2 parents 08b7cc9 + e7da4e9 commit 39fda46
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/canary/metta_ontology.pfc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
properties('&corelib','case', [flow_control, qhelp("Case selection."), conditional_execution]).
properties('&corelib','let', [variable_assignment, qhelp("Variable assignment.")]).
properties('&corelib','let*', [variable_assignment, qhelp("Sequential variable assignment."), sequential]).
properties('&corelib','sealed', [variable_scoping, qhelp("Variable scoping.")]).
properties('&corelib','function', [function_definition, qhelp("Function block.")]).
properties('&corelib','return', [function_definition, qhelp("Return value of a function block."), return_value]).
properties('&corelib','Error', [error_handling, qhelp("Defines or triggers an error.")]).
Expand Down
32 changes: 32 additions & 0 deletions tests/baseline_compat/hyperon-mettalog_sanity/sealed_test.metta
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
!(assertEqualToResult (sealed ($x) (sealed ($a $b) (quote (= ($a $x $c) ($b))))) ((quote (= ($a $x $c) ($b)))))

!(assertEqualToResult (sealed ($x $y) (quote (= ($y $z)))) ((quote (= ($y $z)))))

; !(assertEqualToResult (let $x (input $x) (output $x)) (output (input $x)))

; !(assertEqualToResult (let (quote ($sv $st)) (sealed ($x) (quote ($x (output $x)))) (let $sv (input $x) $st)) (output (input $x)))

(: callsealer (-> Number Number Expression))
(= (callsealer $a $b) (sealed () (quote ((* (+ 40 $a) (/ 100 $b))))))

!(assertEqualToResult (callsealer $x $y) ((quote ((* (+ 40 $x) (/ 100 $y)))))) ; no sealing

!(assertEqualToResult (callsealer 10 25) ((quote ((* (+ 40 10) (/ 100 25))))))

(: callsealer1 (-> Number Number Expression))
(= (callsealer1 $a $b) (sealed ($a) (quote ((* (+ 40 $a) (/ 100 $b))))))

!(assertEqualToResult (callsealer1 5 $y) ((quote ((* (+ 40 5) (/ 100 $y))))))

!(assertEqualToResult (callsealer1 $x $y) ((quote ((* (+ 40 $a) (/ 100 $y)))))) ; $x should be sealed

(: callsealer2 (-> Number Number Expression))
(= (callsealer2 $a $b) (sealed ($a $b) (quote ((* (+ 40 $a) (/ 100 $b))))))

!(assertEqualToResult (callsealer2 $x 4 ) ((quote ((* (+ 40 $a) (/ 100 4 )))))) ;$x sealed

!(assertEqualToResult (callsealer2 $x $y) ((quote ((* (+ 40 $a) (/ 100 $b)))))) ;both $x and $y sealed




0 comments on commit 39fda46

Please sign in to comment.