Post generated tests.

This commit is contained in:
Sigilante 2024-11-18 16:57:23 -06:00
parent 98778364af
commit d3831f7225
22 changed files with 509 additions and 26 deletions

Binary file not shown.

View File

@ -20,37 +20,108 @@
/* comparator %jock /lib/tests/comparator
::
/* test-let-edit %hoon /tests/lib/let-edit
/* test-let-inner-exp %hoon /tests/lib/let-inner-exp
:: /* test-call %hoon /tests/lib/call
/* test-axis-call %hoon /tests/lib/axis-call
/* test-inline-lambda-call %hoon /tests/lib/inline-lambda-call
/* test-in-subj-call %hoon /tests/lib/in-subj-call
/* test-if-else %hoon /tests/lib/if-else
/* test-if-elseif-else %hoon /tests/lib/if-elseif-else
/* test-assert %hoon /tests/lib/assert
/* test-call-let-edit %hoon /tests/lib/call-let-edit
/* test-inline-point %hoon /tests/lib/inline-point
/* test-inline-lambda-no-arg %hoon /tests/lib/inline-lambda-no-arg
/* test-dec %hoon /tests/lib/dec
/* test-eval %hoon /tests/lib/eval
/* test-multi-limb %hoon /tests/lib/multi-limb
/* test-compose %hoon /tests/lib/compose
/* test-compose-cores %hoon /tests/lib/compose-cores
/* test-baby %hoon /tests/lib/baby
/* test-comparator %hoon /tests/lib/comparator
::
|%
++ list-jocks
^- (list [term @t])
:~ [%let-edit q.let-edit]
:: [%let-inner-exp q.let-inner-exp]
[%let-inner-exp q.let-inner-exp]
:: [%call q.call]
:: [%axis-call q.axis-call]
:: [%inline-lambda-call q.inline-lambda-call]
:: [%in-subj-call q.in-subj-call]
:: [%if-else q.if-else]
:: [%if-elseif-else q.if-elseif-else]
:: [%assert q.assert]
:: [%call-let-edit q.call-let-edit]
:: [%inline-point q.inline-point]
:: [%inline-lambda-no-arg q.inline-lambda-no-arg]
:: [%dec q.dec]
:: [%eval q.eval]
:: [%multi-limb q.multi-limb]
:: [%compose q.compose]
:: [%compose-cores q.compose-cores]
:: [%baby q.baby]
:: [%comparator q.comparator]
[%axis-call q.axis-call]
[%inline-lambda-call q.inline-lambda-call]
[%in-subj-call q.in-subj-call]
[%if-else q.if-else]
[%if-elseif-else q.if-elseif-else]
[%assert q.assert]
[%call-let-edit q.call-let-edit]
[%inline-point q.inline-point]
[%inline-lambda-no-arg q.inline-lambda-no-arg]
[%dec q.dec]
[%eval q.eval]
[%multi-limb q.multi-limb]
[%compose q.compose]
[%compose-cores q.compose-cores]
[%baby q.baby]
[%comparator q.comparator]
==
::
++ test-jocks
!:
^- (list [term *])
^- (list [term tang])
:~ [%test-let-edit-tokens test-tokenize:test-let-edit]
[%test-let-edit-jeam test-jeam:test-let-edit]
[%test-let-edit-mint test-mint:test-let-edit]
[%test-let-inner-exp-tokens test-tokenize:test-let-inner-exp]
[%test-let-inner-exp-jeam test-jeam:test-let-inner-exp]
[%test-let-inner-exp-mint test-mint:test-let-inner-exp]
:: [%test-call-tokens test-tokenize:test-call]
:: [%test-call-jeam test-jeam:test-call]
:: [%test-call-mint test-mint:test-call]
[%test-axis-call-tokens test-tokenize:test-axis-call]
[%test-axis-call-jeam test-jeam:test-axis-call]
[%test-axis-call-mint test-mint:test-axis-call]
[%test-inline-lambda-call-tokens test-tokenize:test-inline-lambda-call]
[%test-inline-lambda-call-jeam test-jeam:test-inline-lambda-call]
[%test-inline-lambda-call-mint test-mint:test-inline-lambda-call]
[%test-in-subj-call-tokens test-tokenize:test-in-subj-call]
[%test-in-subj-call-jeam test-jeam:test-in-subj-call]
[%test-in-subj-call-mint test-mint:test-in-subj-call]
[%test-if-else-tokens test-tokenize:test-if-else]
[%test-if-else-jeam test-jeam:test-if-else]
[%test-if-else-mint test-mint:test-if-else]
[%test-if-elseif-else-tokens test-tokenize:test-if-elseif-else]
[%test-if-elseif-else-jeam test-jeam:test-if-elseif-else]
[%test-if-elseif-else-mint test-mint:test-if-elseif-else]
[%test-assert-tokens test-tokenize:test-assert]
[%test-assert-jeam test-jeam:test-assert]
[%test-assert-mint test-mint:test-assert]
[%test-call-let-edit-tokens test-tokenize:test-call-let-edit]
[%test-call-let-edit-jeam test-jeam:test-call-let-edit]
[%test-call-let-edit-mint test-mint:test-call-let-edit]
[%test-inline-point-tokens test-tokenize:test-inline-point]
[%test-inline-point-jeam test-jeam:test-inline-point]
[%test-inline-point-mint test-mint:test-inline-point]
[%test-inline-lambda-no-arg-tokens test-tokenize:test-inline-lambda-no-arg]
[%test-inline-lambda-no-arg-jeam test-jeam:test-inline-lambda-no-arg]
[%test-inline-lambda-no-arg-mint test-mint:test-inline-lambda-no-arg]
[%test-dec-tokens test-tokenize:test-dec]
[%test-dec-jeam test-jeam:test-dec]
[%test-dec-mint test-mint:test-dec]
[%test-eval-tokens test-tokenize:test-eval]
[%test-eval-jeam test-jeam:test-eval]
[%test-eval-mint test-mint:test-eval]
[%test-multi-limb-tokens test-tokenize:test-multi-limb]
[%test-multi-limb-jeam test-jeam:test-multi-limb]
[%test-multi-limb-mint test-mint:test-multi-limb]
[%test-compose-tokens test-tokenize:test-compose]
[%test-compose-jeam test-jeam:test-compose]
[%test-compose-mint test-mint:test-compose]
[%test-compose-cores-tokens test-tokenize:test-compose-cores]
[%test-compose-cores-jeam test-jeam:test-compose-cores]
[%test-compose-cores-mint test-mint:test-compose-cores]
[%test-baby-tokens test-tokenize:test-baby]
[%test-baby-jeam test-jeam:test-baby]
[%test-baby-mint test-mint:test-baby]
[%test-comparator-tokens test-tokenize:test-comparator]
[%test-comparator-jeam test-jeam:test-comparator]
[%test-comparator-mint test-mint:test-comparator]
==
::
++ parse

View File

@ -39,9 +39,25 @@
~& "could not mold poke type: {<dat>}" !!
=/ c=cause u.soft-cau
~& exec-all:test-jock
~& parse-all:test-jock
~& jeam-all:test-jock
~& mint-all:test-jock
:: ~& > " "
:: ~& =| results=(list tank)
:: =/ pa parse-all:test-jock
:: |-
:: ?~ pa results
:: $(pa t.pa, results `(list tank)`[leaf+"{<i.pa>}" results])
:: ~& > " "
:: ~& =| results=(list tank)
:: =/ pa jeam-all:test-jock
:: |-
:: ?~ pa results
:: $(pa t.pa, results `(list tank)`[leaf+"{<i.pa>}" results])
:: ~& > " "
:: ~& =| results=(list tank)
:: =/ pa mint-all:test-jock
:: |-
:: ?~ pa results
:: $(pa t.pa, results `(list tank)`[leaf+"{<i.pa>}" results])
:: ~& > " "
~& test-jocks:test-jock
?- -.c
%test-n [~ k]

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let a: @ = 5;\0alet b: @ = 0;\0a\0aassert a != 0;\0alet c = ?([a a]);\0aloop;\0a\0aif a == +(b) {\0a b\0a} else {\0a b = +(b);\0a recur\0a}\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%punctuator %'('] [%name %b] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'{'] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %'}'] [%punctuator %'('] [%punctuator %')']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%call func=[%lambda p=[arg=[inp=[~ [p=[%atom p=%number] name=%b]] out=[p=[%atom p=%number] name=%$]] body=[%increment val=[%limb p=~[[%name p=%b]]]] payload=~]] arg=~]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [7 [8 [1 0] [1 4 0 6] 0 1] 9 2 0 1]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let a: (c: @ -> @) = (b:@ -> @) {\0a +(b)\0a};\0a\0a&2(17)\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %g] [%punctuator %'='] [%punctuator %'('] [%name %a] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'{'] [%literal [%number 29]] [%punctuator %'}'] [%punctuator %';'] [%keyword %compose] [%keyword %with] [%keyword %this] [%punctuator %';'] [%keyword %object] [%punctuator %'{'] [%name %b] [%punctuator %'='] [%punctuator %'('] [%name %c] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'{'] [%name %g] [%punctuator %'('] [%literal [%number 5]] [%punctuator %')'] [%punctuator %'}'] [%name %c] [%punctuator %'='] [%literal [%number 89]] [%punctuator %'}'] [%punctuator %';'] [%name %b] [%punctuator %'('] [%literal [%number 3]] [%punctuator %')']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%untyped ~] name=%g] val=[%lambda p=[arg=[inp=[~ [p=[%atom p=%number] name=%a]] out=[p=[%atom p=%number] name=%$]] body=[%atom p=[%number 29]] payload=~]] next=[%compose p=[%object name=%$ p=[n=[p=%b q=[%lambda p=[arg=[inp=[~ [p=[%atom p=%number] name=%c]] out=[p=[%atom p=%number] name=%$]] body=[%call func=[%limb p=~[[%name p=%g]]] arg=[~ [%atom p=[%number 5]]]] payload=~]]] l=~ r=[n=[p=%c q=[%atom p=[%number 89]]] l=~ r=~]] q=[~ [%limb p=~[[%axis p=1]]]]] q=[%call func=[%limb p=~[[%name p=%b]]] arg=[~ [%atom p=[%number 3]]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [8 [1 0] [1 1 29] 0 1] 7 [[1 [8 [1 0] [1 8 [0 30] 9 2 10 [6 7 [0 3] 1 5] 0 2] 0 1] 1 89] 0 1] 8 [9 4 0 1] 9 2 10 [6 7 [0 3] 1 3] 0 2]
!> (mint:jock text)
--

22
hoon/tests/lib/baby.hoon Normal file
View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'compose with 0; object {\0a load = crash\0a peek = crash\0a poke = (a:* -> [* &1]) {\0a [a &1]\0a }\0a wish = crash\0a};\0a\0apoke(3)\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %':'] [%punctuator %'('] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'='] [%punctuator %'('] [%name %b] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'{'] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %'}'] [%punctuator %';'] [%name %a] [%punctuator %'('] [%literal [%number 23]] [%punctuator %')']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%core p=[%.y p=[inp=[~ [p=[%atom p=%number] name=%$]] out=[p=[%atom p=%number] name=%$]]] q=~] name=%a] val=[%lambda p=[arg=[inp=[~ [p=[%atom p=%number] name=%b]] out=[p=[%atom p=%number] name=%$]] body=[%increment val=[%limb p=~[[%name p=%b]]]] payload=~]] next=[%call func=[%limb p=~[[%name p=%a]]] arg=[~ [%atom p=[%number 23]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [8 [1 0] [1 4 0 6] 0 1] 8 [0 2] 9 2 10 [6 7 [0 3] 1 23] 0 2]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let a = (c:@ -> @) {\0a +(c)\0a};\0a\0alet b: @ = 42;\0a\0ab = a(23);\0a\0ab\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'='] [%literal [%number 5]] [%punctuator %';'] [%keyword %let] [%name %b] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'='] [%literal [%number 0]] [%punctuator %';'] [%keyword %loop] [%punctuator %';'] [%keyword %if] [%name %a] [%punctuator %'='] [%punctuator %'='] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %'{'] [%name %b] [%punctuator %'}'] [%keyword %else] [%punctuator %'{'] [%name %b] [%punctuator %'='] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %';'] [%punctuator %'$'] [%punctuator %'}']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%atom p=%number] name=%a] val=[%atom p=[%number 5]] next=[%let type=[p=[%atom p=%number] name=%b] val=[%atom p=[%number 0]] next=[%loop next=[%if cond=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'==' b=[%increment val=[%limb p=~[[%name p=%b]]]]] then=[%limb p=~[[%name p=%b]]] after=[%else then=[%edit limb=~[[%name p=%b]] val=[%increment val=[%limb p=~[[%name p=%b]]]] next=[%call func=[%limb p=~[[%axis p=0]]] arg=~]]]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [1 5] 8 [1 0] 8 [1 6 [5 [0 14] 4 0 6] [0 6] 7 [10 [6 4 0 6] 0 1] 9 2 0 1] 9 2 0 1]
!> (mint:jock text)
--

22
hoon/tests/lib/call.hoon Normal file
View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let a: (@ -> @) = (b:@ -> @) {\0a +(b)\0a};\0a\0aa(23)\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %compose] [%keyword %with] [%literal [%number 0]] [%punctuator %';'] [%keyword %object] [%punctuator %'{'] [%name %load] [%punctuator %'='] [%keyword %crash] [%name %peek] [%punctuator %'='] [%keyword %crash] [%name %poke] [%punctuator %'='] [%punctuator %'('] [%name %a] [%punctuator %':'] [%punctuator %'*'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'['] [%punctuator %'*'] [%punctuator %'&'] [%literal [%number 1]] [%punctuator %']'] [%punctuator %')'] [%punctuator %'{'] [%punctuator %'['] [%name %a] [%punctuator %'&'] [%literal [%number 1]] [%punctuator %']'] [%punctuator %'}'] [%name %wish] [%punctuator %'='] [%keyword %crash] [%punctuator %'}'] [%punctuator %';'] [%name %poke] [%punctuator %'('] [%literal [%number 3]] [%punctuator %')']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%compose p=[%object name=%$ p=[n=[p=%load q=[%crash ~]] l=[n=[p=%wish q=[%crash ~]] l=~ r=~] r=[n=[p=%peek q=[%crash ~]] l={[p=%poke q=[%lambda p=[arg=[inp=[~ [p=[%untyped ~] name=%a]] out=[[p=[p=[%untyped ~] name=%$] q=[p=[%limb p=~[[%axis p=1]]] name=%$]] name=%$]] body=[p=[%limb p=~[[%name p=%a]]] q=[%limb p=~[[%axis p=1]]]] payload=~]]]} r=~]] q=[~ [%atom p=[%number 0]]]] q=[%call func=[%limb p=~[[%name p=%poke]]] arg=[~ [%atom p=[%number 3]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [7 [[1 [0 0] [0 0] [8 [1 0] [1 [0 6] 0 1] 0 1] 0 0] 1 0] 8 [9 22 0 1] 9 2 10 [6 7 [0 3] 1 3] 0 2]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'\0alet a = true;\0alet b = a == true;\0alet c = a < 1;\0alet d = a > 2;\0alet e = b != true;\0alet f = a <= 1;\0alet g = a >= 2;\0a\0ag\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %'='] [%punctuator %'{'] [%keyword %let] [%name %b] [%punctuator %'='] [%literal [%number 3]] [%punctuator %';'] [%literal [%number 3]] [%punctuator %'}'] [%punctuator %';'] [%name %a]]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%untyped ~] name=%a] val=[%let type=[p=[%untyped ~] name=%b] val=[%atom p=[%number 3]] next=[%atom p=[%number 3]]] next=[%limb p=~[[%name p=%a]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [8 [1 3] 1 3] 0 2]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let g = (a:@ -> @) {\0a 29\0a};\0a\0acompose\0a with this; object {\0a b = (c:@ -> @) {\0a g(5)\0a }\0a c = 89\0a };\0a\0ab(3)\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %':'] [%punctuator %'('] [%name %c] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'='] [%punctuator %'('] [%name %b] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'{'] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %'}'] [%punctuator %';'] [%punctuator %'&'] [%literal [%number 2]] [%punctuator %'('] [%literal [%number 17]] [%punctuator %')']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%core p=[%.y p=[inp=[~ [p=[%atom p=%number] name=%c]] out=[p=[%atom p=%number] name=%$]]] q=~] name=%a] val=[%lambda p=[arg=[inp=[~ [p=[%atom p=%number] name=%b]] out=[p=[%atom p=%number] name=%$]] body=[%increment val=[%limb p=~[[%name p=%b]]]] payload=~]] next=[%call func=[%limb p=~[[%axis p=2]]] arg=[~ [%atom p=[%number 17]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [8 [1 0] [1 4 0 6] 0 1] 8 [0 2] 9 2 10 [6 7 [0 3] 1 17] 0 2]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'compose\0a object {\0a b = 5\0a a = (c: @ -> @) {\0a +(c)\0a }\0a };\0aa(b)\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%punctuator %'('] [%name %b] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'{'] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %'}'] [%punctuator %'('] [%literal [%number 23]] [%punctuator %')']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%call func=[%lambda p=[arg=[inp=[~ [p=[%atom p=%number] name=%b]] out=[p=[%atom p=%number] name=%$]] body=[%increment val=[%limb p=~[[%name p=%b]]]] payload=~]] arg=[~ [%atom p=[%number 23]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [7 [8 [1 0] [1 4 0 6] 0 1] 9 2 10 [6 7 [0 3] 1 23] 0 1]
!> (mint:jock text)
--

22
hoon/tests/lib/dec.hoon Normal file
View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let dec = (a:@ -> @) {\0a let b = 0;\0a loop;\0a if a == +(b) {\0a b\0a } else {\0a b = +(b);\0a recur\0a }\0a};\0a\0adec(5)\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'='] [%literal [%number 3]] [%punctuator %';'] [%keyword %if] [%name %a] [%punctuator %'='] [%punctuator %'='] [%literal [%number 3]] [%punctuator %'{'] [%literal [%number 72]] [%punctuator %'}'] [%keyword %else] [%keyword %if] [%name %a] [%punctuator %'='] [%punctuator %'='] [%literal [%number 5]] [%punctuator %'{'] [%literal [%number 17]] [%punctuator %'}'] [%keyword %else] [%punctuator %'{'] [%literal [%number 15]] [%punctuator %'}']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%atom p=%number] name=%a] val=[%atom p=[%number 3]] next=[%if cond=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'==' b=[%atom p=[%number 3]]] then=[%atom p=[%number 72]] after=[%else-if cond=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'==' b=[%atom p=[%number 5]]] then=[%atom p=[%number 17]] after=[%else then=[%atom p=[%number 15]]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [1 3] 6 [5 [0 2] 1 3] [1 72] 6 [5 [0 2] 1 5] [1 17] 1 15]
!> (mint:jock text)
--

22
hoon/tests/lib/eval.hoon Normal file
View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'\0alet a = {\0a eval [42 55] [0 2]\0a};\0a\0aa\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'='] [%literal [%number 3]] [%punctuator %';'] [%keyword %if] [%name %a] [%punctuator %'='] [%punctuator %'='] [%literal [%number 3]] [%punctuator %'{'] [%literal [%number 72]] [%punctuator %'}'] [%keyword %else] [%punctuator %'{'] [%literal [%number 17]] [%punctuator %'}']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%atom p=%number] name=%a] val=[%atom p=[%number 3]] next=[%if cond=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'==' b=[%atom p=[%number 3]]] then=[%atom p=[%number 72]] after=[%else then=[%atom p=[%number 17]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [1 3] 6 [5 [0 2] 1 3] [1 72] 1 17]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let a: @ = 3;\0a\0aif a == 3 {\0a 72\0a} else {\0a 17\0a}\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %'='] [%punctuator %'{'] [%keyword %eval] [%punctuator %'['] [%literal [%number 42]] [%literal [%number 55]] [%punctuator %']'] [%punctuator %'['] [%literal [%number 0]] [%literal [%number 2]] [%punctuator %']'] [%punctuator %'}'] [%punctuator %';'] [%name %a]]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%untyped ~] name=%a] val=[%eval p=[p=[%atom p=[%number 42]] q=[%atom p=[%number 55]]] q=[p=[%atom p=[%number 0]] q=[%atom p=[%number 2]]]] next=[%limb p=~[[%name p=%a]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [2 [[1 42] 1 55] [1 0] 1 2] 0 2]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let a: @ = 3;\0a\0aif a == 3 {\0a 72\0a} else if a == 5 {\0a 17\0a} else {\0a 15\0a}\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %dec] [%punctuator %'='] [%punctuator %'('] [%name %a] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'{'] [%keyword %let] [%name %b] [%punctuator %'='] [%literal [%number 0]] [%punctuator %';'] [%keyword %loop] [%punctuator %';'] [%keyword %if] [%name %a] [%punctuator %'='] [%punctuator %'='] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %'{'] [%name %b] [%punctuator %'}'] [%keyword %else] [%punctuator %'{'] [%name %b] [%punctuator %'='] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %';'] [%keyword %recur] [%punctuator %'}'] [%punctuator %'}'] [%punctuator %';'] [%name %dec] [%punctuator %'('] [%literal [%number 5]] [%punctuator %')']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%untyped ~] name=%dec] val=[%lambda p=[arg=[inp=[~ [p=[%atom p=%number] name=%a]] out=[p=[%atom p=%number] name=%$]] body=[%let type=[p=[%untyped ~] name=%b] val=[%atom p=[%number 0]] next=[%loop next=[%if cond=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'==' b=[%increment val=[%limb p=~[[%name p=%b]]]]] then=[%limb p=~[[%name p=%b]]] after=[%else then=[%edit limb=~[[%name p=%b]] val=[%increment val=[%limb p=~[[%name p=%b]]]] next=[%call func=[%limb p=~[[%axis p=0]]] arg=~]]]]]] payload=~]] next=[%call func=[%limb p=~[[%name p=%dec]]] arg=[~ [%atom p=[%number 5]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [8 [1 0] [1 8 [1 0] 8 [1 6 [5 [0 30] 4 0 6] [0 6] 7 [10 [6 4 0 6] 0 1] 9 2 0 1] 9 2 0 1] 0 1] 8 [0 2] 9 2 10 [6 7 [0 3] 1 5] 0 2]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let a = 17;\0a\0alet b = ([b:@ c:&1] -> @) {\0a if c == 18 {\0a +(b)\0a } else {\0a b\0a }\0a}([23 &1]);\0a\0a&1\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %':'] [%punctuator %'['] [%name %p] [%punctuator %':'] [%punctuator %'@'] [%name %q] [%punctuator %':'] [%punctuator %'['] [%name %k] [%punctuator %':'] [%punctuator %'@'] [%name %v] [%punctuator %':'] [%punctuator %'@'] [%punctuator %']'] [%punctuator %']'] [%punctuator %'='] [%punctuator %'['] [%literal [%number 52]] [%literal [%number 30]] [%literal [%number 45]] [%punctuator %']'] [%punctuator %';'] [%name %v] [%punctuator %'.'] [%name %q] [%punctuator %'.'] [%name %a]]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[[p=[p=[%atom p=%number] name=%p] q=[[p=[p=[%atom p=%number] name=%k] q=[p=[%atom p=%number] name=%v]] name=%q]] name=%a] val=[p=[%atom p=[%number 52]] q=[p=[%atom p=[%number 30]] q=[%atom p=[%number 45]]]] next=[%limb p=~[[%name p=%a] [%name p=%q] [%name p=%v]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [[1 52] [1 30] 1 45] 0 11]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'(b:@ -> @) {\0a +(b)\0a}(23)\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %compose] [%keyword %object] [%punctuator %'{'] [%name %b] [%punctuator %'='] [%literal [%number 5]] [%name %a] [%punctuator %'='] [%punctuator %'('] [%name %c] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'{'] [%punctuator %'+'] [%punctuator %'('] [%name %c] [%punctuator %')'] [%punctuator %'}'] [%punctuator %'}'] [%punctuator %';'] [%name %a] [%punctuator %'('] [%name %b] [%punctuator %')']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%compose p=[%object name=%$ p=[n=[p=%b q=[%atom p=[%number 5]]] l=~ r=[n=[p=%a q=[%lambda p=[arg=[inp=[~ [p=[%atom p=%number] name=%c]] out=[p=[%atom p=%number] name=%$]] body=[%increment val=[%limb p=~[[%name p=%c]]]] payload=~]]] l=~ r=~]] q=~] q=[%call func=[%limb p=~[[%name p=%a]]] arg=[~ [%limb p=~[[%name p=%b]]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [7 [1 [1 5] 8 [1 0] [1 4 0 6] 0 1] 8 [9 3 0 1] 9 2 10 [6 7 [0 3] 9 2 0 1] 0 2]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'(b:@ -> @) {\0a +(b)\0a}()\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'='] [%literal [%number 5]] [%punctuator %';'] [%keyword %let] [%name %b] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'='] [%literal [%number 0]] [%punctuator %';'] [%keyword %assert] [%name %a] [%punctuator %'!'] [%punctuator %'='] [%literal [%number 0]] [%punctuator %';'] [%keyword %let] [%name %c] [%punctuator %'='] [%punctuator %'?'] [%punctuator %'('] [%punctuator %'['] [%name %a] [%name %a] [%punctuator %']'] [%punctuator %')'] [%punctuator %';'] [%keyword %loop] [%punctuator %';'] [%keyword %if] [%name %a] [%punctuator %'='] [%punctuator %'='] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %'{'] [%name %b] [%punctuator %'}'] [%keyword %else] [%punctuator %'{'] [%name %b] [%punctuator %'='] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %';'] [%keyword %recur] [%punctuator %'}']]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%atom p=%number] name=%a] val=[%atom p=[%number 5]] next=[%let type=[p=[%atom p=%number] name=%b] val=[%atom p=[%number 0]] next=[%assert cond=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'!=' b=[%atom p=[%number 0]]] then=[%let type=[p=[%untyped ~] name=%c] val=[%cell-check val=[p=[%limb p=~[[%name p=%a]]] q=[%limb p=~[[%name p=%a]]]]] next=[%loop next=[%if cond=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'==' b=[%increment val=[%limb p=~[[%name p=%b]]]]] then=[%limb p=~[[%name p=%b]]] after=[%else then=[%edit limb=~[[%name p=%b]] val=[%increment val=[%limb p=~[[%name p=%b]]]] next=[%call func=[%limb p=~[[%axis p=0]]] arg=~]]]]]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [1 5] 8 [1 0] 6 [6 [5 [0 6] 1 0] [1 1] 1 0] [8 [3 [0 6] 0 6] 8 [1 6 [5 [0 30] 4 0 14] [0 14] 7 [10 [14 4 0 14] 0 1] 9 2 0 1] 9 2 0 1] 0 0]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let a: @ = 5;\0alet b: @ = 0;\0aloop;\0aif a == +(b) {\0a b\0a} else {\0a b = +(b);\0a $\0a}\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %'='] [%punctuator %'('] [%name %c] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'{'] [%punctuator %'+'] [%punctuator %'('] [%name %c] [%punctuator %')'] [%punctuator %'}'] [%punctuator %';'] [%keyword %let] [%name %b] [%punctuator %':'] [%punctuator %'@'] [%punctuator %'='] [%literal [%number 42]] [%punctuator %';'] [%name %b] [%punctuator %'='] [%name %a] [%punctuator %'('] [%literal [%number 23]] [%punctuator %')'] [%punctuator %';'] [%name %b]]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%untyped ~] name=%a] val=[%lambda p=[arg=[inp=[~ [p=[%atom p=%number] name=%c]] out=[p=[%atom p=%number] name=%$]] body=[%increment val=[%limb p=~[[%name p=%c]]]] payload=~]] next=[%let type=[p=[%atom p=%number] name=%b] val=[%atom p=[%number 42]] next=[%edit limb=~[[%name p=%b]] val=[%call func=[%limb p=~[[%name p=%a]]] arg=[~ [%atom p=[%number 23]]]] next=[%limb p=~[[%name p=%b]]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [8 [1 0] [1 4 0 6] 0 1] 8 [1 42] 7 [10 [2 8 [0 6] 9 2 10 [6 7 [0 3] 1 23] 0 2] 0 1] 0 2]
!> (mint:jock text)
--

View File

@ -3,7 +3,7 @@
::
|%
++ text
'let a:? = true;\0aa = false;\0aa'
'let a: ? = true;\0a\0aa = false;\0a\0aa\0a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %':'] [%punctuator %'?'] [%punctuator %'='] [%literal [%loobean %.y]] [%punctuator %';'] [%name %a] [%punctuator %'='] [%literal [%loobean %.n]] [%punctuator %';'] [%name %a]]
@ -12,11 +12,11 @@
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[[%let type=[p=[%atom p=%loobean] name=%a] val=[%atom p=[%loobean %.y]] next=[%edit limb=~[[%name p=%a]] val=[%atom p=[%loobean %.n]] next=[%limb p=~[[%name p=%a]]]]]]
!> (jeam:jock txt)
[%let type=[p=[%atom p=%loobean] name=%a] val=[%atom p=[%loobean %.y]] next=[%edit limb=~[[%name p=%a]] val=[%atom p=[%loobean %.n]] next=[%limb p=~[[%name p=%a]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [1 0] 7 [10 [2 1 1] 0 1] 0 2]
!> (mint:jock txt)
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'let a = {\0a let b = 3;\0a 3\0a};\0a\0aa\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %'='] [%literal [%loobean %.y]] [%punctuator %';'] [%keyword %let] [%name %b] [%punctuator %'='] [%name %a] [%punctuator %'='] [%punctuator %'='] [%literal [%loobean %.y]] [%punctuator %';'] [%keyword %let] [%name %c] [%punctuator %'='] [%name %a] [%punctuator %'<'] [%literal [%number 1]] [%punctuator %';'] [%keyword %let] [%name %d] [%punctuator %'='] [%name %a] [%punctuator %'>'] [%literal [%number 2]] [%punctuator %';'] [%keyword %let] [%name %e] [%punctuator %'='] [%name %b] [%punctuator %'!'] [%punctuator %'='] [%literal [%loobean %.y]] [%punctuator %';'] [%keyword %let] [%name %f] [%punctuator %'='] [%name %a] [%punctuator %'<'] [%punctuator %'='] [%literal [%number 1]] [%punctuator %';'] [%keyword %let] [%name %g] [%punctuator %'='] [%name %a] [%punctuator %'>'] [%punctuator %'='] [%literal [%number 2]] [%punctuator %';'] [%name %g]]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%untyped ~] name=%a] val=[%atom p=[%loobean %.y]] next=[%let type=[p=[%untyped ~] name=%b] val=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'==' b=[%atom p=[%loobean %.y]]] next=[%let type=[p=[%untyped ~] name=%c] val=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'<' b=[%atom p=[%number 1]]] next=[%let type=[p=[%untyped ~] name=%d] val=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'>' b=[%atom p=[%number 2]]] next=[%let type=[p=[%untyped ~] name=%e] val=[%compare a=[%limb p=~[[%name p=%b]]] comp=%'!=' b=[%atom p=[%loobean %.y]]] next=[%let type=[p=[%untyped ~] name=%f] val=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'<=' b=[%atom p=[%number 1]]] next=[%let type=[p=[%untyped ~] name=%g] val=[%compare a=[%limb p=~[[%name p=%a]]] comp=%'>=' b=[%atom p=[%number 2]]] next=[%limb p=~[[%name p=%g]]]]]]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [1 0] 8 [5 [0 2] 1 0] 8 [11 6.845.548 0 0] 8 [11 6.845.543 0 0] 8 [6 [5 [0 14] 1 0] [1 1] 1 0] 8 [11 6.648.940 0 0] 8 [11 6.648.935 0 0] 0 2]
!> (mint:jock text)
--

View File

@ -0,0 +1,22 @@
/+ jock,
test
::
|%
++ text
'\0alet a: [p:@ q:[k:@ v:@]] = [52 30 45];\0a\0av.q.a\0a'
++ test-tokenize
%+ expect-eq:test
!> ~[[%keyword %let] [%name %a] [%punctuator %'='] [%literal [%number 17]] [%punctuator %';'] [%keyword %let] [%name %b] [%punctuator %'='] [%punctuator %'('] [%punctuator %'['] [%name %b] [%punctuator %':'] [%punctuator %'@'] [%name %c] [%punctuator %':'] [%punctuator %'&'] [%literal [%number 1]] [%punctuator %']'] [%punctuator %'-'] [%punctuator %'>'] [%punctuator %'@'] [%punctuator %')'] [%punctuator %'{'] [%keyword %if] [%name %c] [%punctuator %'='] [%punctuator %'='] [%literal [%number 18]] [%punctuator %'{'] [%punctuator %'+'] [%punctuator %'('] [%name %b] [%punctuator %')'] [%punctuator %'}'] [%keyword %else] [%punctuator %'{'] [%name %b] [%punctuator %'}'] [%punctuator %'}'] [%punctuator %'('] [%punctuator %'['] [%literal [%number 23]] [%punctuator %'&'] [%literal [%number 1]] [%punctuator %']'] [%punctuator %')'] [%punctuator %';'] [%punctuator %'&'] [%literal [%number 1]]]
!> (rash text parse-tokens:jock)
::
++ test-jeam
%+ expect-eq:test
!> ^- jock:jock
[%let type=[p=[%untyped ~] name=%a] val=[%atom p=[%number 17]] next=[%let type=[p=[%untyped ~] name=%b] val=[%call func=[%lambda p=[arg=[inp=[~ [[p=[p=[%atom p=%number] name=%b] q=[p=[%limb p=~[[%axis p=1]]] name=%c]] name=%$]] out=[p=[%atom p=%number] name=%$]] body=[%if cond=[%compare a=[%limb p=~[[%name p=%c]]] comp=%'==' b=[%atom p=[%number 18]]] then=[%increment val=[%limb p=~[[%name p=%b]]]] after=[%else then=[%limb p=~[[%name p=%b]]]]] payload=~]] arg=[~ [p=[%atom p=[%number 23]] q=[%limb p=~[[%axis p=1]]]]]] next=[%limb p=~[[%axis p=1]]]]]
!> (jeam:jock text)
::
++ test-mint
%+ expect-eq:test
!> [8 [1 17] 8 [7 [8 [[1 0] [1 0] 1 0] [1 6 [5 [0 13] 1 18] [4 0 12] 0 12] 0 1] 9 2 10 [6 7 [0 3] [1 23] 0 1] 0 1] 0 1]
!> (mint:jock text)
--