From d0138ff7fa0fd7cbb0d6fb5035446b2964a3c056 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 9 Mar 2018 19:25:29 -0800 Subject: [PATCH] fix #654 by having assert-eq accept a vase of a pair flipping the order of the pair while rewriting all the test was necessary anyawy, to accoutn for heavier-twig tendencies --- lib/tester.hoon | 9 +- tests/new-hoon/ls.hoon | 260 +++++++++++------------ tests/new-hoon/mp.hoon | 383 +++++++++++++++++----------------- tests/new-hoon/myb.hoon | 22 +- tests/new-hoon/thr.hoon | 28 +-- tests/zuse/crypto/keccak.hoon | 92 ++++---- 6 files changed, 397 insertions(+), 397 deletions(-) diff --git a/lib/tester.hoon b/lib/tester.hoon index 68e167750..389425204 100644 --- a/lib/tester.hoon +++ b/lib/tester.hoon @@ -137,12 +137,13 @@ +| :: todo: unit testing libraries have a lot more to them than just eq. ++ expect-eq - |* [a=* b=*] + |= a=vase ^- wall - ?: =(a b) + ?@ q.a ["ex-expected-pair: '{(text a)}'"]~ + ?: =(-.q.a +.q.a) ~ - :~ "actual: '{(noah !>(a))}'" - "expected: '{(noah !>(b))}'" + :~ "expected: '{(text (slot 2 a))}'" + "actual: '{(text (slot 3 a))}'" == :> # :> # %formatting diff --git a/tests/new-hoon/ls.hoon b/tests/new-hoon/ls.hoon index 9e4fd8802..f036e73b8 100644 --- a/tests/new-hoon/ls.hoon +++ b/tests/new-hoon/ls.hoon @@ -2,241 +2,241 @@ =, ls:new-hoon |_ _tester:tester ++ test-head - (expect-eq (head [1 ~]) 1) + (expect-eq !>([1 (head [1 ~])])) :: ++ test-last - (expect-eq (last:ls [1 2 ~]) 2) + (expect-eq !>([2 (last:ls [1 2 ~])])) :: ++ test-tail - (expect-eq (tail [1 2 3 ~]) [2 3 ~]) + (expect-eq !>([[2 3 ~] (tail [1 2 3 ~])])) :: ++ test-init - (expect-eq (init [1 2 3 ~]) [1 2 ~]) + (expect-eq !>([[1 2 ~] (init [1 2 3 ~])])) :: ++ test-size - (expect-eq (size ['a' 'b' 'c' ~]) 3) + (expect-eq !>([3 (size ['a' 'b' 'c' ~])])) :: ++ test-map - (expect-eq (map:ls [1 2 ~] |=(a/@ (add 1 a))) [2 3 ~]) + (expect-eq !>([[2 3 ~] (map:ls [1 2 ~] |=(a/@ (add 1 a)))])) :: ++ test-reverse - (expect-eq (reverse [1 2 3 ~]) [3 2 1 ~]) + (expect-eq !>([[3 2 1 ~] (reverse [1 2 3 ~])])) :: ++ test-intersperse - (expect-eq (intersperse 1 [5 5 5 ~]) [5 1 5 1 5 ~]) + (expect-eq !>([[5 1 5 1 5 ~] (intersperse 1 [5 5 5 ~])])) :: ++ test-intercalate - %+ expect-eq - (intercalate "," ["one" "two" "three" ~]) - ["one,two,three"] + %- expect-eq !> + :- ["one,two,three"] + (intercalate "," ["one" "two" "three" ~]) :: ++ test-transpose - %+ expect-eq - (transpose ~[~[1 2 3] ~[4 5 6]]) - ~[~[1 4] ~[2 5] ~[3 6]] + %- expect-eq !> + :- ~[~[1 4] ~[2 5] ~[3 6]] + (transpose ~[~[1 2 3] ~[4 5 6]]) :: ++ test-foldl - (expect-eq (foldl [1 2 3 ~] 3 |=({a/@ b/@} (add a b))) 9) + (expect-eq !>([9 (foldl [1 2 3 ~] 3 |=({a/@ b/@} (add a b)))])) :: ++ test-foldr - (expect-eq (foldr [1 2 3 ~] 1 |=({a/@ b/@} (add a b))) 7) + (expect-eq !>([7 (foldr [1 2 3 ~] 1 |=({a/@ b/@} (add a b)))])) :: ++ test-concat - (expect-eq (concat ~[~[1 2] ~[3 4]]) ~[1 2 3 4]) + (expect-eq !>([~[1 2 3 4] (concat ~[~[1 2] ~[3 4]])])) :: ++ test-weld - (expect-eq (weld:ls ~[1 2 3] ~["one" "two"]) ~[1 2 3 "one" "two"]) + (expect-eq !>([~[1 2 3 "one" "two"] (weld:ls ~[1 2 3] ~["one" "two"])])) :: ++ test-any-true - (expect-eq (any [1 2 3 ~] |=(a/@ =(a 2))) %.y) + (expect-eq !>([%.y (any [1 2 3 ~] |=(a/@ =(a 2)))])) :: ++ test-any-false - (expect-eq (any [1 2 3 ~] |=(a/@ =(a 8))) %.n) + (expect-eq !>([%.n (any [1 2 3 ~] |=(a/@ =(a 8)))])) :: ++ test-all-true - (expect-eq (all [1 1 1 ~] |=(a/@ =(a 1))) %.y) + (expect-eq !>([%.y (all [1 1 1 ~] |=(a/@ =(a 1)))])) :: ++ test-all-false - (expect-eq (all [1 3 1 ~] |=(a/@ =(a 1))) %.n) + (expect-eq !>([%.n (all [1 3 1 ~] |=(a/@ =(a 1)))])) :: ++ test-scanl - %+ expect-eq - (scanl ~[1 2 3] 0 |=({a/@ b/@} (add a b))) - ~[0 1 3 6] + %- expect-eq !> + :- ~[0 1 3 6] + (scanl ~[1 2 3] 0 |=({a/@ b/@} (add a b))) :: ++ test-scanl1 - %+ expect-eq - (scanl1 ~[1 2 3] |=({a/@ b/@} (add a b))) - ~[1 3 6] + %- expect-eq !> + :- ~[1 3 6] + (scanl1 ~[1 2 3] |=({a/@ b/@} (add a b))) :: ++ test-scanr - %+ expect-eq - (scanr ~[1 2 3] 0 |=({a/@ b/@} (add a b))) - ~[6 5 3 0] + %- expect-eq !> + :- ~[6 5 3 0] + (scanr ~[1 2 3] 0 |=({a/@ b/@} (add a b))) :: ++ test-scanr1 - %+ expect-eq - (scanr1 ~[1 2 3] |=({a/@ b/@} (add a b))) - ~[6 5 3] + %- expect-eq !> + :- ~[6 5 3] + (scanr1 ~[1 2 3] |=({a/@ b/@} (add a b))) :: ++ test-map-foldl - %+ expect-eq - (map-foldl ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) - [7 ~[2 3 5]] + %- expect-eq !> + :- [7 ~[2 3 5]] + (map-foldl ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) :: ++ test-map-foldr - %+ expect-eq - (map-foldr ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) - [7 ~[7 5 2]] + %- expect-eq !> + :- [7 ~[7 5 2]] + (map-foldr ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) :: ++ test-unfoldr - %+ expect-eq - (unfoldr 5 |=(a/@ ?:(=(a 0) ~ `[a (dec a)]))) - [5 4 3 2 1 ~] + %- expect-eq !> + :- [5 4 3 2 1 ~] + (unfoldr 5 |=(a/@ ?:(=(a 0) ~ `[a (dec a)]))) :: ++ test-take - %+ expect-eq - (take 3 ~[1 2 3 4 5]) - [1 2 3 ~] + %- expect-eq !> + :- [1 2 3 ~] + (take 3 ~[1 2 3 4 5]) :: ++ test-drop - %+ expect-eq - (drop:ls 3 ~[1 2 3 4 5]) - [4 5 ~] + %- expect-eq !> + :- [4 5 ~] + (drop:ls 3 ~[1 2 3 4 5]) :: ++ test-split-at - %+ expect-eq - (split-at 3 ~[1 2 3 4 5]) - [[1 2 3 ~] [4 5 ~]] + %- expect-eq !> + :- [[1 2 3 ~] [4 5 ~]] + (split-at 3 ~[1 2 3 4 5]) :: ++ test-take-while - %+ expect-eq - (take-while ~[1 2 3 4 5] |=(a/@ (lth a 3))) - [1 2 ~] + %- expect-eq !> + :- [1 2 ~] + (take-while ~[1 2 3 4 5] |=(a/@ (lth a 3))) :: ++ test-drop-while - %+ expect-eq - (drop-while ~[1 2 3 4 5] |=(a/@ (lth a 3))) - [3 4 5 ~] + %- expect-eq !> + :- [3 4 5 ~] + (drop-while ~[1 2 3 4 5] |=(a/@ (lth a 3))) :: ++ test-drop-while-end - %+ expect-eq - (drop-while-end ~[5 5 1 5 5] |=(a/@ =(a 5))) - [5 5 1 ~] + %- expect-eq !> + :- [5 5 1 ~] + (drop-while-end ~[5 5 1 5 5] |=(a/@ =(a 5))) :: ++ test-split-on - %+ expect-eq - (split-on ~[1 2 3 4 1 2 3 4] |=(a/@ (lth a 3))) - [[1 2 ~] [3 4 1 2 3 4 ~]] + %- expect-eq !> + :- [[1 2 ~] [3 4 1 2 3 4 ~]] + (split-on ~[1 2 3 4 1 2 3 4] |=(a/@ (lth a 3))) :: ++ test-break - %+ expect-eq - (break ~[1 2 3 4 1 2 3 4] |=(a/@ (gth a 3))) - [[1 2 3 ~] [4 1 2 3 4 ~]] + %- expect-eq !> + :- [[1 2 3 ~] [4 1 2 3 4 ~]] + (break ~[1 2 3 4 1 2 3 4] |=(a/@ (gth a 3))) :: ++ test-strip-prefix - %+ expect-eq - (strip-prefix "foo" "foobar") - [~ "bar"] + %- expect-eq !> + :- [~ "bar"] + (strip-prefix "foo" "foobar") :: ++ test-inits - %+ expect-eq - (inits "abc") - ["a" "ab" "abc" ~] + %- expect-eq !> + :- ["a" "ab" "abc" ~] + (inits "abc") :: ++ test-tails - %+ expect-eq - (tails "abc") - ["abc" "bc" "c" ~] + %- expect-eq !> + :- ["abc" "bc" "c" ~] + (tails "abc") :: ++ test-is-prefix-of - %+ expect-eq - (is-prefix-of "foo" "foobar") - %.y + %- expect-eq !> + :- %.y + (is-prefix-of "foo" "foobar") :: ++ test-is-suffix-of - %+ expect-eq - (is-suffix-of "bar" "foobar") - %.y + %- expect-eq !> + :- %.y + (is-suffix-of "bar" "foobar") :: ++ test-is-infix-of - %+ expect-eq - (is-infix-of "ob" "foobar") - %.y + %- expect-eq !> + :- %.y + (is-infix-of "ob" "foobar") :: ++ test-elem - %+ expect-eq - (elem 5 [1 2 3 4 5 ~]) - %.y + %- expect-eq !> + :- %.y + (elem 5 [1 2 3 4 5 ~]) :: ++ test-lookup - %+ expect-eq - (lookup "two" [["one" 1] ["two" 2] ["three" 3] ~]) - [~ 2] + %- expect-eq !> + :- [~ 2] + (lookup "two" [["one" 1] ["two" 2] ["three" 3] ~]) :: ++ test-find - %+ expect-eq - (find:ls [3 2 1 5 1 2 3 ~] |=(a/@ (gth a 3))) - [~ 5] + %- expect-eq !> + :- [~ 5] + (find:ls [3 2 1 5 1 2 3 ~] |=(a/@ (gth a 3))) :: ++ test-filter - %+ expect-eq - (filter [1 2 1 2 1 ~] |=(a/@ =(a 2))) - [1 1 1 ~] + %- expect-eq !> + :- [1 1 1 ~] + (filter [1 2 1 2 1 ~] |=(a/@ =(a 2))) :: ++ test-partition - %+ expect-eq - (partition [1 2 1 2 1 ~] |=(a/@ =(a 2))) - [[2 2 ~] [1 1 1 ~]] + %- expect-eq !> + :- [[2 2 ~] [1 1 1 ~]] + (partition [1 2 1 2 1 ~] |=(a/@ =(a 2))) :: ++ test-elem-index - %+ expect-eq - (elem-index 2 [1 2 3 4 ~]) - `1 + %- expect-eq !> + :- `1 + (elem-index 2 [1 2 3 4 ~]) :: ++ test-elem-indices - %+ expect-eq - (elem-indices 2 [1 2 1 2 ~]) - [1 3 ~] + %- expect-eq !> + :- [1 3 ~] + (elem-indices 2 [1 2 1 2 ~]) :: ++ test-find-index - %+ expect-eq - (find-index [1 2 3 ~] |=(a/@ =(a 2))) - `1 + %- expect-eq !> + :- `1 + (find-index [1 2 3 ~] |=(a/@ =(a 2))) :: ++ test-find-indices - %+ expect-eq - (find-indices [1 2 1 2 ~] |=(a/@ =(a 2))) - [1 3 ~] + %- expect-eq !> + :- [1 3 ~] + (find-indices [1 2 1 2 ~] |=(a/@ =(a 2))) :: ++ test-zip - %+ expect-eq - (zip [[1 2 3 ~] [4 5 6 ~] [7 8 9 ~] ~]) - [[1 4 7 ~] [2 5 8 ~] [3 6 9 ~] ~] + %- expect-eq !> + :- [[1 4 7 ~] [2 5 8 ~] [3 6 9 ~] ~] + (zip [[1 2 3 ~] [4 5 6 ~] [7 8 9 ~] ~]) :: ++ test-unique - %+ expect-eq - (unique [1 2 3 1 2 3 ~]) - [1 2 3 ~] + %- expect-eq !> + :- [1 2 3 ~] + (unique [1 2 3 1 2 3 ~]) :: ++ test-delete - %+ expect-eq - (delete 2 [1 2 3 2 ~]) - [1 3 2 ~] + %- expect-eq !> + :- [1 3 2 ~] + (delete 2 [1 2 3 2 ~]) :: ++ test-delete-firsts - %+ expect-eq - (delete-firsts [1 2 2 2 3 4 5 ~] [2 2 5 ~]) - [1 2 3 4 ~] + %- expect-eq !> + :- [1 2 3 4 ~] + (delete-firsts [1 2 2 2 3 4 5 ~] [2 2 5 ~]) :: ++ test-union - %+ expect-eq - (union [1 2 3 ~] [4 2 5 ~]) - [1 2 3 4 5 ~] + %- expect-eq !> + :- [1 2 3 4 5 ~] + (union [1 2 3 ~] [4 2 5 ~]) :: ++ test-intersect - %+ expect-eq - (intersect [5 6 6 7 8 ~] [9 8 8 6 ~]) - [6 6 8 ~] + %- expect-eq !> + :- [6 6 8 ~] + (intersect [5 6 6 7 8 ~] [9 8 8 6 ~]) -- diff --git a/tests/new-hoon/mp.hoon b/tests/new-hoon/mp.hoon index 661d6be60..60237ae2f 100644 --- a/tests/new-hoon/mp.hoon +++ b/tests/new-hoon/mp.hoon @@ -4,87 +4,86 @@ =+ three=(from-list [[1 "one"] [2 "two"] [3 "three"] ~]) |_ _tester:tester ++ test-empty - (expect-eq (empty four) %.n) + (expect-eq !>([%.n (empty four)])) :: ++ test-size - (expect-eq (size four) 4) + (expect-eq !>([4 (size four)])) :: ++ test-member - (expect-eq (member four 4) %.y) + (expect-eq !>([%.y (member four 4)])) :: ++ test-put-with - =+ ints=(from-list [["one" 1] ["two" 2] ["three" 3] ["four" 4] ~]) - %+ expect-eq - (put-with ints "three" 2 add) - (from-list [["one" 1] ["two" 2] ["three" 5] ["four" 4] ~]) + %- expect-eq !> + :- (from-list [["one" 1] ["two" 2] ["three" 5] ["four" 4] ~]) + =/ ints (from-list [["one" 1] ["two" 2] ["three" 3] ["four" 4] ~]) + (put-with ints "three" 2 add) :: ++ test-put-with-key - %+ expect-eq - (put-with-key four 4 "four" |=({a/@ud b/tape c/tape} (weld (scow %ud a) b))) - (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "4four"] ~]) + %- expect-eq !> + :- (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "4four"] ~]) + (put-with-key four 4 "four" |=({a/@ud b/tape c/tape} (weld (scow %ud a) b))) :: ++ test-put-lookup-with-key - %+ expect-eq - %^ put-lookup-with-key four - 4 - :- "five" - |=({key/@ud old/tape new/tape} new) - :- `"four" - (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "five"] ~]) + %- expect-eq !> + :- [`"four" (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "five"] ~])] + %^ put-lookup-with-key four + 4 + :- "five" + |=({key/@ud old/tape new/tape} new) :: ++ test-delete - %+ expect-eq - (delete four 4) - three + %- expect-eq !> + :- three + (delete four 4) :: ++ test-adjust - %+ expect-eq - %^ adjust four - 3 - |=(a/tape (weld "this" a)) - (from-list [[1 "one"] [2 "two"] [3 "thisthree"] [4 "four"] ~]) + %- expect-eq !> + :- (from-list [[1 "one"] [2 "two"] [3 "thisthree"] [4 "four"] ~]) + %^ adjust four + 3 + |=(a/tape (weld "this" a)) :: ++ test-adjust-with-key - %+ expect-eq - %^ adjust-with-key four - 3 - |=({a/@ud b/tape} (weld (scow %ud a) b)) - (from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~]) + %- expect-eq !> + :- (from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~]) + %^ adjust-with-key four + 3 + |=({a/@ud b/tape} (weld (scow %ud a) b)) :: ++ test-update - %+ expect-eq - %^ update four - 3 - |=(a/tape `(maybe tape)`~) - (from-list [[1 "one"] [2 "two"] [4 "four"] ~]) + %- expect-eq !> + :- (from-list [[1 "one"] [2 "two"] [4 "four"] ~]) + %^ update four + 3 + |=(a/tape `(maybe tape)`~) :: ++ test-update-with-key - %+ expect-eq - %^ update-with-key four - 3 - |=({a/@u b/tape} `(maybe tape)`[~ (weld (scow %ud a) b)]) - (from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~]) + %- expect-eq !> + :- (from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~]) + %^ update-with-key four + 3 + |=({a/@u b/tape} `(maybe tape)`[~ (weld (scow %ud a) b)]) :: ++ test-alter-as-add - %+ expect-eq - %^ alter four - 5 - |=(a/(maybe tape) `(maybe tape)`[~ "five"]) - (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] [5 "five"] ~]) + %- expect-eq !> + :- (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] [5 "five"] ~]) + %^ alter four + 5 + |=(a/(maybe tape) `(maybe tape)`[~ "five"]) :: ++ test-alter-as-delete - %+ expect-eq - %^ alter four - 2 - |=(a/(maybe tape) `(maybe tape)`~) - (from-list [[1 "one"] [3 "three"] [4 "four"] ~]) + %- expect-eq !> + :- (from-list [[1 "one"] [3 "three"] [4 "four"] ~]) + %^ alter four + 2 + |=(a/(maybe tape) `(maybe tape)`~) :: ++ test-alter-as-change - %+ expect-eq - %^ alter four - 2 - |=(a/(maybe tape) `(maybe tape)`[~ "dos"]) - (from-list [[1 "one"] [2 "dos"] [3 "three"] [4 "four"] ~]) + %- expect-eq !> + :- (from-list [[1 "one"] [2 "dos"] [3 "three"] [4 "four"] ~]) + %^ alter four + 2 + |=(a/(maybe tape) `(maybe tape)`[~ "dos"]) :: ++ check-alter :: check random dicts of 50 items with 40 random operations done on them @@ -114,192 +113,192 @@ $(i +(i)) :: ++ test-union - %+ expect-eq - %+ union - (from-list [[1 "left"] [2 "left"] ~]) - (from-list [[2 "right"] [3 "right"] ~]) - (from-list [[1 "left"] [2 "left"] [3 "right"] ~]) + %- expect-eq !> + :- (from-list [[1 "left"] [2 "left"] [3 "right"] ~]) + %+ union + (from-list [[1 "left"] [2 "left"] ~]) + (from-list [[2 "right"] [3 "right"] ~]) :: ++ test-union-with - %+ expect-eq - %^ union-with - (from-list [[1 "left"] [2 "left"] ~]) - (from-list [[2 "right"] [3 "right"] ~]) - |=({a/tape b/tape} (weld a b)) - (from-list [[1 "left"] [2 "leftright"] [3 "right"] ~]) + %- expect-eq !> + :- (from-list [[1 "left"] [2 "leftright"] [3 "right"] ~]) + %^ union-with + (from-list [[1 "left"] [2 "left"] ~]) + (from-list [[2 "right"] [3 "right"] ~]) + |=({a/tape b/tape} (weld a b)) :: ++ test-union-with-key - %+ expect-eq - %^ union-with-key - (from-list [[1 "left"] [2 "left"] ~]) - (from-list [[2 "right"] [3 "right"] ~]) - |=({a/@ud b/tape c/tape} :(weld `tape`(scow %ud a) b c)) - (from-list [[1 "left"] [2 "2leftright"] [3 "right"] ~]) + %- expect-eq !> + :- (from-list [[1 "left"] [2 "2leftright"] [3 "right"] ~]) + %^ union-with-key + (from-list [[1 "left"] [2 "left"] ~]) + (from-list [[2 "right"] [3 "right"] ~]) + |=({a/@ud b/tape c/tape} :(weld `tape`(scow %ud a) b c)) :: ++ test-map - %+ expect-eq - (map:dct three crip) - (from-list [[1 'one'] [2 'two'] [3 'three'] ~]) + %- expect-eq !> + :- (from-list [[1 'one'] [2 'two'] [3 'three'] ~]) + (map:dct three crip) :: ++ test-map-with-key - %+ expect-eq - %+ map-with-key three - |=({a/@u b/tape} (weld (scow %ud a) b)) - (from-list [[1 "1one"] [2 "2two"] [3 "3three"] ~]) + %- expect-eq !> + :- (from-list [[1 "1one"] [2 "2two"] [3 "3three"] ~]) + %+ map-with-key three + |=({a/@u b/tape} (weld (scow %ud a) b)) :: ++ test-map-fold - %+ expect-eq - %^ map-fold three - "Everything:" - |= {accumulator/tape value/tape} - [:(weld accumulator " " value) (weld value "X")] - :- "Everything: two one three" - (from-list [[1 "oneX"] [2 "twoX"] [3 "threeX"] ~]) + %- expect-eq !> + :- :- "Everything: two one three" + (from-list [[1 "oneX"] [2 "twoX"] [3 "threeX"] ~]) + %^ map-fold three + "Everything:" + |= {accumulator/tape value/tape} + [:(weld accumulator " " value) (weld value "X")] :: ++ test-map-keys - %+ expect-eq - %+ map-keys three - |=(a/@u (add a 10)) - (from-list [[11 "one"] [12 "two"] [13 "three"] ~]) + %- expect-eq !> + :- (from-list [[11 "one"] [12 "two"] [13 "three"] ~]) + %+ map-keys three + |=(a/@u (add a 10)) :: ++ test-map-keys-with - %+ expect-eq - %^ map-keys-with three - |=(a/@u 42) - weld - (from-list [[42 "twothreeone"] ~]) + %- expect-eq !> + :- (from-list [[42 "twothreeone"] ~]) + %^ map-keys-with three + |=(a/@u 42) + weld :: ++ test-fold - %+ expect-eq - %^ fold three - "Everything: " - :: todo: this works but replacing with just ++weld causes an out of loom. - |= {accumulator/tape value/tape} - ^- tape - (weld accumulator value) - "Everything: twoonethree" + %- expect-eq !> + :- "Everything: twoonethree" + %^ fold three + "Everything: " + :: todo: this works but replacing with just ++weld causes an out of loom. + |= {accumulator/tape value/tape} + ^- tape + (weld accumulator value) :: ++ test-fold-with-keys - %+ expect-eq - %^ fold-with-keys three - "Everything: " - |= {accumulator/tape key/@u value/tape} - ^- tape - :(weld accumulator (scow %ud key) value) - "Everything: 2two1one3three" + %- expect-eq !> + :- "Everything: 2two1one3three" + %^ fold-with-keys three + "Everything: " + |= {accumulator/tape key/@u value/tape} + ^- tape + :(weld accumulator (scow %ud key) value) :: ++ test-elems - %+ expect-eq - (elems three) - ["two" "three" "one" ~] + %- expect-eq !> + :- ["two" "three" "one" ~] + (elems three) :: ++ test-keys - %+ expect-eq - (keys three) - [2 3 1 ~] + %- expect-eq !> + :- [2 3 1 ~] + (keys three) :: ++ test-keys-set - %+ expect-eq - (keys-set three) - (si:nl [2 3 1 ~]) + %- expect-eq !> + :- (si:nl [2 3 1 ~]) + (keys-set three) :: ++ test-from-set - %+ expect-eq - %+ from-set - (si:nl [1 2 3 ~]) - |=(a/@u (scow %ud a)) - (from-list [[1 "1"] [2 "2"] [3 "3"] ~]) + %- expect-eq !> + :- (from-list [[1 "1"] [2 "2"] [3 "3"] ~]) + %+ from-set + (si:nl [1 2 3 ~]) + |=(a/@u (scow %ud a)) :: ++ test-from-list-with - %+ expect-eq - %+ from-list-with - [[1 1] [2 1] [2 1] [3 3] ~] - add - (from-list [[1 1] [2 2] [3 3] ~]) + %- expect-eq !> + :- (from-list [[1 1] [2 2] [3 3] ~]) + %+ from-list-with + [[1 1] [2 1] [2 1] [3 3] ~] + add :: ++ test-filter - %+ expect-eq - %+ filter - (from-list [[1 1] [2 1] [3 2] [4 1] ~]) - |=(a/@u !=(a 1)) - (from-list [[1 1] [2 1] [4 1] ~]) + %- expect-eq !> + :- (from-list [[1 1] [2 1] [4 1] ~]) + %+ filter + (from-list [[1 1] [2 1] [3 2] [4 1] ~]) + |=(a/@u !=(a 1)) :: ++ test-filter-with-key - %+ expect-eq - %+ filter-with-key - (from-list [[1 1] [2 1] [3 2] [4 1] ~]) - |=({a/@u b/@u} =(a 2)) - (from-list [[1 1] [3 2] [4 1] ~]) + %- expect-eq !> + :- (from-list [[1 1] [3 2] [4 1] ~]) + %+ filter-with-key + (from-list [[1 1] [2 1] [3 2] [4 1] ~]) + |=({a/@u b/@u} =(a 2)) :: ++ test-restrict-keys - %+ expect-eq - %+ restrict-keys - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - (si:nl [1 3 5 ~]) - (from-list [[1 1] [3 3] [5 5] ~]) + %- expect-eq !> + :- (from-list [[1 1] [3 3] [5 5] ~]) + %+ restrict-keys + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + (si:nl [1 3 5 ~]) :: ++ test-without-keys - %+ expect-eq - %+ without-keys - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - (si:nl [1 3 5 ~]) - (from-list [[2 2] [4 4] ~]) + %- expect-eq !> + :- (from-list [[2 2] [4 4] ~]) + %+ without-keys + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + (si:nl [1 3 5 ~]) :: ++ test-partition - %+ expect-eq - %+ partition - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - |=(a/@u |(=(a 1) =(a 3))) - :- (from-list [[1 1] [3 3] ~]) - (from-list [[2 2] [4 4] [5 5] ~]) + %- expect-eq !> + :- :- (from-list [[1 1] [3 3] ~]) + (from-list [[2 2] [4 4] [5 5] ~]) + %+ partition + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |=(a/@u |(=(a 1) =(a 3))) :: ++ test-map-maybe - %+ expect-eq - %+ map-maybe - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - |=(a/@u ?:(=(a 3) ~ `a)) - (from-list [[1 1] [2 2] [4 4] [5 5] ~]) + %- expect-eq !> + :- (from-list [[1 1] [2 2] [4 4] [5 5] ~]) + %+ map-maybe + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |=(a/@u ?:(=(a 3) ~ `a)) :: ++ test-map-maybe-with-key - %+ expect-eq - %+ map-maybe-with-key - (from-list [[1 2] [2 3] [3 4] [4 5] [5 6] ~]) - |=({k/@u v/@u} ?:(=(k 3) ~ `v)) - (from-list [[1 2] [2 3] [4 5] [5 6] ~]) + %- expect-eq !> + :- (from-list [[1 2] [2 3] [4 5] [5 6] ~]) + %+ map-maybe-with-key + (from-list [[1 2] [2 3] [3 4] [4 5] [5 6] ~]) + |=({k/@u v/@u} ?:(=(k 3) ~ `v)) :: ++ test-map-either - %+ expect-eq - %+ map-either - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - |= value/@u - ?: =(0 (mod value 2)) - [%& "even"] - [%| 1] - :- (from-list [[2 "even"] [4 "even"] ~]) - (from-list [[1 1] [3 1] [5 1] ~]) -:: -++ test-map-either-with-key - %+ expect-eq - %+ map-either-with-key - (from-list [[1 1] [2 1] [3 1] [4 1] [5 1] ~]) - |= {key/@u value/@u} - ?: =(0 (mod key 2)) + %- expect-eq !> + :- :- (from-list [[2 "even"] [4 "even"] ~]) + (from-list [[1 1] [3 1] [5 1] ~]) + %+ map-either + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |= value/@u + ?: =(0 (mod value 2)) [%& "even"] [%| 1] - :- (from-list [[2 "even"] [4 "even"] ~]) - (from-list [[1 1] [3 1] [5 1] ~]) +:: +++ test-map-either-with-key + %- expect-eq !> + :- :- (from-list [[2 "even"] [4 "even"] ~]) + (from-list [[1 1] [3 1] [5 1] ~]) + %+ map-either-with-key + (from-list [[1 1] [2 1] [3 1] [4 1] [5 1] ~]) + |= {key/@u value/@u} + ?: =(0 (mod key 2)) + [%& "even"] + [%| 1] :: ++ test-is-subdict - %+ expect-eq - %^ is-subdict-by - (from-list [[1 1] [4 4] ~]) - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - |=({a/* b/*} =(a b)) - %.y + %- expect-eq !> + :- & + %^ is-subdict-by + (from-list [[1 1] [4 4] ~]) + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |=({a/* b/*} =(a b)) :: ++ test-valid - %+ expect-eq - (valid (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] [6 6] [7 7] [8 8] [9 9] ~])) - %.y + %- expect-eq !> + :- & + (valid (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] [6 6] [7 7] [8 8] [9 9] ~])) -- diff --git a/tests/new-hoon/myb.hoon b/tests/new-hoon/myb.hoon index 0b1208230..16662a250 100644 --- a/tests/new-hoon/myb.hoon +++ b/tests/new-hoon/myb.hoon @@ -2,30 +2,30 @@ =, myb:new-hoon |_ _tester:tester ++ test-from-list-null - (expect-eq (from-list ~) ~) + (expect-eq !>([~ (from-list ~)])) :: ++ test-from-list-real - (expect-eq (from-list [5 ~]) [~ 5]) + (expect-eq !>([[~ 5] (from-list [5 ~])])) :: ++ test-to-list-null - (expect-eq (to-list ~) ~) + (expect-eq !>([~ (to-list ~)])) :: ++ test-to-list-real - (expect-eq (to-list [~ 5]) [5 ~]) + (expect-eq !>([[5 ~] (to-list [~ 5])])) :: ++ test-concat-null - (expect-eq (concat ~) ~) + (expect-eq !>([~ (concat ~)])) :: ++ test-concat-real :: wait, if i pull the cast out from below, the concat implementation :: doesn't compile anymore? - (expect-eq (concat `(list (maybe @ud))`[~ [~ 1] ~ [~ 2] ~]) [1 2 ~]) + (expect-eq !>([[1 2 ~] (concat `(list (maybe @ud))`[~ [~ 1] ~ [~ 2] ~])])) :: ++ test-map - %+ expect-eq - %+ map:myb - [1 2 3 2 ~] - |=(a/@u ?:(=(2 a) [~ 2] ~)) - [2 2 ~] + %- expect-eq !> + :- [2 2 ~] + %+ map:myb + [1 2 3 2 ~] + |=(a/@u ?:(=(2 a) [~ 2] ~)) -- diff --git a/tests/new-hoon/thr.hoon b/tests/new-hoon/thr.hoon index 2f8c2283c..d160e0bd5 100644 --- a/tests/new-hoon/thr.hoon +++ b/tests/new-hoon/thr.hoon @@ -4,24 +4,24 @@ =/ data/(list (either @u tape)) [[%& 1] [%| "one"] [%& 2] [%| "two"] ~] |_ _tester:tester ++ test-apply - %+ expect-eq - %^ apply `(either @u tape)`[%| "one"] - |=(a/@u "left") - |=(b/tape "right") - "right" + %- expect-eq !> + :- "right" + %^ apply `(either @u tape)`[%| "one"] + |=(a/@u "left") + |=(b/tape "right") :: ++ test-firsts - %+ expect-eq - (firsts data) - [1 2 ~] + %- expect-eq !> + :- [1 2 ~] + (firsts data) :: ++ test-seconds - %+ expect-eq - (seconds data) - ["one" "two" ~] + %- expect-eq !> + :- ["one" "two" ~] + (seconds data) :: ++ test-partition - %+ expect-eq - (partition data) - [[1 2 ~] ["one" "two" ~]] + %- expect-eq !> + :- [[1 2 ~] ["one" "two" ~]] + (partition data) -- diff --git a/tests/zuse/crypto/keccak.hoon b/tests/zuse/crypto/keccak.hoon index 55bf9543b..890684901 100644 --- a/tests/zuse/crypto/keccak.hoon +++ b/tests/zuse/crypto/keccak.hoon @@ -87,9 +87,9 @@ %+ weld $(answers t.answers) =+ `[bytes=@ud answer=@]`i.answers %+ category.tst name - %+ expect-eq.tst - (hash bytes (~(got by keccak-inputs) bytes)) - answer + %- expect-eq.tst !> + :- answer + (hash bytes (~(got by keccak-inputs) bytes)) :: :: keccak :: @@ -241,63 +241,63 @@ :: sha3 :: ++ test-sha3-224 - %+ expect-eq.tst - (sha3-224 0 `@`0) - 0x6b4e.0342.3667.dbb7.3b6e.1545.4f0e.b1ab. - d459.7f9a.1b07.8e3f.5b5a.6bc7 + %- expect-eq.tst !> + :- 0x6b4e.0342.3667.dbb7.3b6e.1545.4f0e.b1ab. + d459.7f9a.1b07.8e3f.5b5a.6bc7 + (sha3-224 0 `@`0) :: ++ test-sha3-256 - %+ expect-eq.tst - (sha3-256 0 `@`0) - 0xa7ff.c6f8.bf1e.d766.51c1.4756.a061.d662. - f580.ff4d.e43b.49fa.82d8.0a4b.80f8.434a + %- expect-eq.tst !> + :- 0xa7ff.c6f8.bf1e.d766.51c1.4756.a061.d662. + f580.ff4d.e43b.49fa.82d8.0a4b.80f8.434a + (sha3-256 0 `@`0) :: ++ test-sha3-384 - %+ expect-eq.tst - (sha3-384 0 `@`0) - 0xc63.a75b.845e.4f7d.0110.7d85.2e4c.2485. - c51a.50aa.aa94.fc61.995e.71bb.ee98.3a2a. - c371.3831.264a.db47.fb6b.d1e0.58d5.f004 + %- expect-eq.tst !> + :- 0xc63.a75b.845e.4f7d.0110.7d85.2e4c.2485. + c51a.50aa.aa94.fc61.995e.71bb.ee98.3a2a. + c371.3831.264a.db47.fb6b.d1e0.58d5.f004 + (sha3-384 0 `@`0) :: ++ test-sha3-512 - %+ expect-eq.tst + %- expect-eq.tst !> + :- 0xa69f.73cc.a23a.9ac5.c8b5.67dc.185a.756e. + 97c9.8216.4fe2.5859.e0d1.dcc1.475c.80a6. + 15b2.123a.f1f5.f94c.11e3.e940.2c3a.c558. + f500.199d.95b6.d3e3.0175.8586.281d.cd26 (sha3-512 0 `@`0) - 0xa69f.73cc.a23a.9ac5.c8b5.67dc.185a.756e. - 97c9.8216.4fe2.5859.e0d1.dcc1.475c.80a6. - 15b2.123a.f1f5.f94c.11e3.e940.2c3a.c558. - f500.199d.95b6.d3e3.0175.8586.281d.cd26 -:: + :: :: shake :: ++ test-shake-128 - %+ expect-eq.tst - (shake-128 512 0 `@`0) - 0x7f9c.2ba4.e88f.827d.6160.4550.7605.853e. - d73b.8093.f6ef.bc88.eb1a.6eac.fa66.ef26. - 3cb1.eea9.8800.4b93.103c.fb0a.eefd.2a68. - 6e01.fa4a.58e8.a363.9ca8.a1e3.f9ae.57e2 + %- expect-eq.tst !> + :- 0x7f9c.2ba4.e88f.827d.6160.4550.7605.853e. + d73b.8093.f6ef.bc88.eb1a.6eac.fa66.ef26. + 3cb1.eea9.8800.4b93.103c.fb0a.eefd.2a68. + 6e01.fa4a.58e8.a363.9ca8.a1e3.f9ae.57e2 + (shake-128 512 0 `@`0) :: ++ test-shake-256 - %+ expect-eq.tst - (shake-256 512 0 `@`0) - 0x46b9.dd2b.0ba8.8d13.233b.3feb.743e.eb24. - 3fcd.52ea.62b8.1b82.b50c.2764.6ed5.762f. - d75d.c4dd.d8c0.f200.cb05.019d.67b5.92f6. - fc82.1c49.479a.b486.4029.2eac.b3b7.c4be + %- expect-eq.tst !> + :- 0x46b9.dd2b.0ba8.8d13.233b.3feb.743e.eb24. + 3fcd.52ea.62b8.1b82.b50c.2764.6ed5.762f. + d75d.c4dd.d8c0.f200.cb05.019d.67b5.92f6. + fc82.1c49.479a.b486.4029.2eac.b3b7.c4be + (shake-256 512 0 `@`0) :: ++ test-rawshake-128 - %+ expect-eq.tst - (rawshake-128 512 0 `@`0) - 0xfa01.9a3b.1763.0df6.0148.53b5.4707.73f1. - 3c3a.b704.4782.11d7.a658.6751.5dea.1cc7. - 926b.2147.e396.076b.22cb.7263.3af5.0647. - c7f2.3d0d.8f00.1d6d.8daf.0f6f.2e92.fc0e + %- expect-eq.tst !> + :- 0xfa01.9a3b.1763.0df6.0148.53b5.4707.73f1. + 3c3a.b704.4782.11d7.a658.6751.5dea.1cc7. + 926b.2147.e396.076b.22cb.7263.3af5.0647. + c7f2.3d0d.8f00.1d6d.8daf.0f6f.2e92.fc0e + (rawshake-128 512 0 `@`0) :: ++ test-rawshake-256 - %+ expect-eq.tst - (rawshake-256 512 0 `@`0) - 0x3a11.08d4.a90a.31b8.5a10.bdce.77f4.bfbd. - cc5b.1d70.dd40.5686.f8bb.de83.4aa1.a410. - db8c.9e1c.166c.3e23.9cd7.6a55.f6a6.92aa. - 2d17.49f2.ec79.cd0b.a3b1.7bb6.5995.9b6e + %- expect-eq.tst !> + :- 0x3a11.08d4.a90a.31b8.5a10.bdce.77f4.bfbd. + cc5b.1d70.dd40.5686.f8bb.de83.4aa1.a410. + db8c.9e1c.166c.3e23.9cd7.6a55.f6a6.92aa. + 2d17.49f2.ec79.cd0b.a3b1.7bb6.5995.9b6e + (rawshake-256 512 0 `@`0) --