mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 13:54:20 +03:00
Merge branch 'master' of https://github.com/urbit/arvo into constitution
This commit is contained in:
commit
62f18aff31
@ -22,18 +22,4 @@
|
||||
leaf+"can't create a moon from a {?:(?=($earl ran) "moon" "comet")}"
|
||||
=/ mon (mix (lsh 5 1 (end 5 1 eny)) p.bec)
|
||||
=/ tic .^(@ /a/(scot %p p.bec)/tick/(scot %da now)/(scot %p mon))
|
||||
%+ sole-yo
|
||||
leaf+"(see https://github.com/urbit/arvo/issues/327 for details)"
|
||||
%+ sole-yo
|
||||
:- %leaf
|
||||
;: weld
|
||||
"WARNING: linking a moon to your "
|
||||
?-(ran $czar "galaxy", $king "star", $duke "planet")
|
||||
" can cause networking bugs"
|
||||
==
|
||||
%+ sole-lo
|
||||
[& %$ "enter y/yes to continue: "]
|
||||
|= inp/tape
|
||||
?. |(=("y" inp) =("yes" inp))
|
||||
(sole-so [%tang leaf+"canceled" ~])
|
||||
(sole-so [%tang leaf+"moon: {<`@p`mon>}; ticket: {<`@p`tic>}" leaf+"" ~])
|
||||
(sole-so [%tang leaf+"ticket: {<`@p`tic>}" leaf+"moon: {<`@p`mon>}" ~])
|
||||
|
@ -20,8 +20,11 @@
|
||||
?. matches
|
||||
~
|
||||
?- -.q.b
|
||||
%& (run-test [p.b pax] eny p.q.b)
|
||||
%| ^$(pax [p.b pax], a p.q.b)
|
||||
%&
|
||||
(run-test [p.b pax] eny p.q.b)
|
||||
::
|
||||
%|
|
||||
^$(pax [p.b pax], a p.q.b)
|
||||
==
|
||||
::
|
||||
++ run-test
|
||||
|
@ -22,7 +22,7 @@
|
||||
:> combine the current file and subdirectory.
|
||||
:>
|
||||
:> this merges the file {base} with its child files {recur}.
|
||||
|= [base=vase recur=(map @ta tests:tester)]
|
||||
|= [base=vase recur=(map @ta tests)]
|
||||
^- tests
|
||||
=+ a=(gen-tests base)
|
||||
=+ b=(test-map-to-test-list recur)
|
||||
@ -33,43 +33,47 @@
|
||||
++ test-map-to-test-list
|
||||
:> translates ford output to something we can work with.
|
||||
:>
|
||||
:> ford gives us a `(map @ta tests:tester)`, but we actually
|
||||
:> ford gives us a `(map @ta tests)`, but we actually
|
||||
:> want something like ++tests.
|
||||
|= a=(map @ta tests:tester)
|
||||
|= a=(map @ta tests)
|
||||
:: todo: i'd like to sort this, but ++sort has -find.a problems much like
|
||||
:: ++weld does above!?
|
||||
^- tests
|
||||
%+ turn
|
||||
(to-list:dct:new-hoon a)
|
||||
|= {key/@ta value/tests:tester}
|
||||
|= {key/@ta value/tests}
|
||||
[key [%| value]]
|
||||
::
|
||||
++ has-test-prefix
|
||||
|= a=term ^- ?
|
||||
?| =((end 3 5 a) 'test-')
|
||||
=((end 3 6 a) 'check-')
|
||||
==
|
||||
::
|
||||
++ gen-tests
|
||||
:> creates a {tests} list out of a vase of a test suite
|
||||
|= v=vase
|
||||
^- tests
|
||||
=+ arms=(sort (sloe p.v) aor)
|
||||
%+ turn arms
|
||||
%+ turn (skim arms has-test-prefix)
|
||||
|= arm/term
|
||||
::REVIEW fewer asserts? recouple the nock and eat the runtime compile cost?
|
||||
?> (~(nest ut (~(peek ut p.v) %free 6)) & p:!>((init-test)))
|
||||
=/ call (~(mint ut p.v) p:!>(*wall) [%limb arm])
|
||||
?> (~(nest ut p:!>(*wall)) & p.call)
|
||||
::
|
||||
:- arm
|
||||
:- %&
|
||||
|= eny=@uvJ
|
||||
=+ context=(slop !>((init-test eny)) v)
|
||||
=/ r (slap context [%cnsg [arm ~] [%$ 3] [[%$ 2] ~]])
|
||||
((hard (list tape)) q:(slap r [%limb %results]))
|
||||
|= eny=@uvJ ^- wall
|
||||
((hard wall) .*(q.v(+6 (init-test eny)) q.call))
|
||||
::
|
||||
:> # %per-test
|
||||
:> data initialized on a per-test basis.
|
||||
::
|
||||
++ init-test
|
||||
|= {cookie/@uvJ}
|
||||
~(. tester `(list tape)`~ cookie 10 0)
|
||||
::
|
||||
++ tester-type _(init-test `@uvJ`0)
|
||||
++ init-test |=({eny/@uvJ} %*(. tester eny eny, check-iterations 10))
|
||||
::
|
||||
++ tester
|
||||
|_ $: error-lines=(list tape) :< output messages
|
||||
eny=@uvJ :< entropy
|
||||
|_ $: eny=@uvJ :< entropy
|
||||
check-iterations=@u :< # of check trials
|
||||
current-iteration=@u :< current iteration
|
||||
==
|
||||
@ -80,27 +84,21 @@
|
||||
+|
|
||||
+- check
|
||||
|* [generator=$-(@uvJ *) test=$-(* ?)]
|
||||
|-
|
||||
^+ +>.$
|
||||
|- ^- wall
|
||||
?: (gth current-iteration check-iterations)
|
||||
+>.$
|
||||
~
|
||||
:: todo: wrap generator in mule so it can crash.
|
||||
=+ sample=(generator eny)
|
||||
:: todo: wrap test in mule so it can crash.
|
||||
=+ ret=(test sample)
|
||||
?: ret
|
||||
?: (test sample)
|
||||
%= $
|
||||
eny (shaf %huh eny) :: xxx: better random?
|
||||
current-iteration (add current-iteration 1)
|
||||
==
|
||||
=+ case=(add 1 current-iteration)
|
||||
=+ case-plural=?:(=(case 1) "case" "cases")
|
||||
%= +>.$
|
||||
error-lines :*
|
||||
"falsified after {(noah !>(case))} {case-plural} by '{(noah !>(sample))}'"
|
||||
error-lines
|
||||
==
|
||||
==
|
||||
=/ case +(current-iteration)
|
||||
=/ pl ?+(case "" %1 "s")
|
||||
::XXX sample is a noun
|
||||
["falsified after {<case>} case{pl} by '{<`*`sample>}', seed {<eny>}"]~
|
||||
::
|
||||
:: todo: a generate function that takes an arbitrary span.
|
||||
::
|
||||
@ -139,27 +137,23 @@
|
||||
+|
|
||||
:: todo: unit testing libraries have a lot more to them than just eq.
|
||||
++ expect-eq
|
||||
|* [a=* b=* c=tape]
|
||||
^+ +>
|
||||
?: =(a b)
|
||||
+>.$
|
||||
%= +>.$
|
||||
error-lines :*
|
||||
"failure: '{c}'"
|
||||
" actual: '{(noah !>(a))}'"
|
||||
" expected: '{(noah !>(b))}'"
|
||||
error-lines
|
||||
==
|
||||
|= a=vase
|
||||
^- wall
|
||||
?@ q.a ["ex-expected-pair: '{(text a)}'"]~
|
||||
?: =(-.q.a +.q.a)
|
||||
~
|
||||
:~ "expected: '{(text (slot 2 a))}'"
|
||||
"actual: '{(text (slot 3 a))}'"
|
||||
==
|
||||
::
|
||||
:> #
|
||||
:> # %output
|
||||
:> # %formatting
|
||||
:> #
|
||||
:> called by the test harness
|
||||
::
|
||||
++ results
|
||||
:> returns results.
|
||||
^- (list tape)
|
||||
error-lines
|
||||
:> test result presentation
|
||||
+|
|
||||
++ category
|
||||
|= [a=tape b=wall]
|
||||
?: =(~ b) ~ :: test OK
|
||||
:- "in: '{a}'"
|
||||
(turn b |=(c=tape " {c}"))
|
||||
--
|
||||
--
|
||||
|
309
sys/zuse.hoon
309
sys/zuse.hoon
@ -2966,6 +2966,315 @@
|
||||
:: alice decrypts with same key
|
||||
`@t`(dy.ali secret-key crypted-msg)
|
||||
-- ::test
|
||||
:: ::
|
||||
:::: ++keccak:crypto :: (2b7) keccak family
|
||||
:: ::::
|
||||
++ keccak
|
||||
|%
|
||||
::
|
||||
:: keccak
|
||||
::
|
||||
++ keccak-224 |=(a=octs (keccak 1.152 448 224 a))
|
||||
++ keccak-256 |=(a=octs (keccak 1.088 512 256 a))
|
||||
++ keccak-384 |=(a=octs (keccak 832 768 384 a))
|
||||
++ keccak-512 |=(a=octs (keccak 576 1.024 512 a))
|
||||
::
|
||||
++ keccak (cury (cury hash keccak-f) padding-keccak)
|
||||
::
|
||||
++ padding-keccak (multirate-padding 0x1)
|
||||
::
|
||||
:: sha3
|
||||
::
|
||||
++ sha3-224 |=(a=octs (sha3 1.152 448 224 a))
|
||||
++ sha3-256 |=(a=octs (sha3 1.088 512 256 a))
|
||||
++ sha3-384 |=(a=octs (sha3 832 768 384 a))
|
||||
++ sha3-512 |=(a=octs (sha3 576 1.024 512 a))
|
||||
::
|
||||
++ sha3 (cury (cury hash keccak-f) padding-sha3)
|
||||
::
|
||||
++ padding-sha3 (multirate-padding 0x6)
|
||||
::
|
||||
:: shake
|
||||
::
|
||||
++ shake-128 |=([o=@ud i=octs] (shake 1.344 256 o i))
|
||||
++ shake-256 |=([o=@ud i=octs] (shake 1.088 512 o i))
|
||||
::
|
||||
++ shake (cury (cury hash keccak-f) padding-shake)
|
||||
::
|
||||
++ padding-shake (multirate-padding 0x1f)
|
||||
::
|
||||
:: rawshake
|
||||
::
|
||||
++ rawshake-128 |=([o=@ud i=octs] (rawshake 1.344 256 o i))
|
||||
++ rawshake-256 |=([o=@ud i=octs] (rawshake 1.088 512 o i))
|
||||
::
|
||||
++ rawshake (cury (cury hash keccak-f) padding-rawshake)
|
||||
::
|
||||
++ padding-rawshake (multirate-padding 0x7)
|
||||
::
|
||||
:: core
|
||||
::
|
||||
++ hash
|
||||
:> per: permutation function with configurable width.
|
||||
:> pad: padding function.
|
||||
:> rat: bitrate, size in bits of blocks to operate on.
|
||||
:> cap: capacity, bits of sponge padding.
|
||||
:> out: length of desired output, in bits.
|
||||
:> inp: input to hash.
|
||||
|= $: per=$-(@ud $-(@ @))
|
||||
pad=$-([octs @ud] octs)
|
||||
rat=@ud
|
||||
cap=@ud
|
||||
out=@ud
|
||||
inp=octs
|
||||
==
|
||||
^- @
|
||||
:: urbit's little-endian to keccak's big-endian.
|
||||
=. q.inp
|
||||
=+ (swp 3 q.inp)
|
||||
(lsh 3 (sub p.inp (met 3 q.inp)) -)
|
||||
%. [inp out]
|
||||
(sponge per pad rat cap)
|
||||
::
|
||||
::NOTE if ++keccak ever needs to be made to operate
|
||||
:: on bits rather than bytes, all that needs to
|
||||
:: be done is updating the way this padding
|
||||
:: function works. (and also "octs" -> "bits")
|
||||
++ multirate-padding
|
||||
:> dsb: domain separation byte, reverse bit order.
|
||||
|= dsb=@ux
|
||||
?> (lte dsb 0xff)
|
||||
|= [inp=octs mut=@ud]
|
||||
^- octs
|
||||
=. mut (div mut 8)
|
||||
=+ pal=(sub mut (mod p.inp mut))
|
||||
=? pal =(pal 0) mut
|
||||
=. pal (dec pal)
|
||||
:- (add p.inp +(pal))
|
||||
:: padding is provided in lane bit ordering,
|
||||
:: ie, LSB = left.
|
||||
(cat 3 (con (lsh 3 pal dsb) 0x80) q.inp)
|
||||
::
|
||||
++ sponge
|
||||
:> sponge construction
|
||||
::
|
||||
:> preperm: permutation function with configurable width.
|
||||
:> padding: padding function.
|
||||
:> bitrate: size of blocks to operate on.
|
||||
:> capacity: sponge padding.
|
||||
|= $: preperm=$-(@ud $-(@ @))
|
||||
padding=$-([octs @ud] octs)
|
||||
bitrate=@ud
|
||||
capacity=@ud
|
||||
==
|
||||
::
|
||||
:: preparing
|
||||
=+ bitrate-bytes=(div bitrate 8)
|
||||
=+ blockwidth=(add bitrate capacity)
|
||||
=+ permute=(preperm blockwidth)
|
||||
::
|
||||
|= [input=octs output=@ud]
|
||||
|^ ^- @
|
||||
::
|
||||
:: padding
|
||||
=. input (padding input bitrate)
|
||||
::
|
||||
:: absorbing
|
||||
=/ pieces=(list @)
|
||||
:: amount of bitrate-sized blocks.
|
||||
?> =(0 (mod p.input bitrate-bytes))
|
||||
=+ i=(div p.input bitrate-bytes)
|
||||
|-
|
||||
?: =(i 0) ~
|
||||
:_ $(i (dec i))
|
||||
:: get the bitrate-sized block of bytes
|
||||
:: that ends with the byte at -.
|
||||
=- (cut 3 [- bitrate-bytes] q.input)
|
||||
(mul (dec i) bitrate-bytes)
|
||||
=/ state=@
|
||||
:: for every piece,
|
||||
%+ roll pieces
|
||||
|= [p=@ s=@]
|
||||
:: pad with capacity,
|
||||
=. p (lsh 0 capacity p)
|
||||
:: xor it into the state and permute it.
|
||||
(permute (mix s (bytes-to-lanes p)))
|
||||
::
|
||||
:: squeezing
|
||||
=| res=@
|
||||
=| len=@ud
|
||||
|-
|
||||
:: append a bitrate-sized head of state to the
|
||||
:: result.
|
||||
=. res
|
||||
%+ con (lsh 0 bitrate res)
|
||||
(rsh 0 capacity (lanes-to-bytes state))
|
||||
=. len (add len bitrate)
|
||||
?: (gte len output)
|
||||
:: produce the requested bits of output.
|
||||
(rsh 0 (sub len output) res)
|
||||
$(res res, state (permute state))
|
||||
::
|
||||
++ bytes-to-lanes
|
||||
:> flip byte order in blocks of 8 bytes.
|
||||
|= a=@
|
||||
%+ can 6
|
||||
%+ turn (rip 6 a)
|
||||
|= b=@
|
||||
:- 1
|
||||
(lsh 3 (sub 8 (met 3 b)) (swp 3 b))
|
||||
::
|
||||
++ lanes-to-bytes
|
||||
:> unflip byte order in blocks of 8 bytes.
|
||||
|= a=@
|
||||
%+ can 6
|
||||
%+ turn
|
||||
=+ (rip 6 a)
|
||||
(weld - (reap (sub 25 (lent -)) 0x0))
|
||||
|= a=@
|
||||
:- 1
|
||||
%+ can 3
|
||||
=- (turn - |=(a=@ [1 a]))
|
||||
=+ (flop (rip 3 a))
|
||||
(weld (reap (sub 8 (lent -)) 0x0) -)
|
||||
--
|
||||
::
|
||||
++ keccak-f
|
||||
:> keccak permutation function
|
||||
|= [width=@ud]
|
||||
:: assert valid blockwidth.
|
||||
?> =- (~(has in -) width)
|
||||
(sy 25 50 100 200 400 800 1.600 ~)
|
||||
:: assumes 5x5 lanes state, as is the keccak
|
||||
:: standard.
|
||||
=+ size=5
|
||||
=+ lanes=(mul size size)
|
||||
=+ lane-bloq=(dec (xeb (div width lanes)))
|
||||
=+ lane-size=(bex lane-bloq)
|
||||
=+ rounds=(add 12 (mul 2 lane-bloq))
|
||||
|= [input=@]
|
||||
^- @
|
||||
=* a input
|
||||
=+ round=0
|
||||
|^
|
||||
?: =(round rounds) a
|
||||
::
|
||||
:: theta
|
||||
=/ c=@
|
||||
%+ roll (gulf 0 (dec size))
|
||||
|= [x=@ud c=@]
|
||||
%+ con (lsh lane-bloq 1 c)
|
||||
%+ roll (gulf 0 (dec size))
|
||||
|= [y=@ud c=@]
|
||||
(mix c (get-lane x y a))
|
||||
=/ d=@
|
||||
%+ roll (gulf 0 (dec size))
|
||||
|= [x=@ud d=@]
|
||||
%+ con (lsh lane-bloq 1 d)
|
||||
%+ mix
|
||||
=- (get-word - size c)
|
||||
?:(=(x 0) (dec size) (dec x))
|
||||
%^ ~(rol fe lane-bloq) 0 1
|
||||
(get-word (mod +(x) size) size c)
|
||||
=. a
|
||||
%+ roll (gulf 0 (dec lanes))
|
||||
|= [i=@ud a=_a]
|
||||
%+ mix a
|
||||
%^ lsh lane-bloq
|
||||
(sub lanes +(i))
|
||||
(get-word i size d)
|
||||
::
|
||||
:: rho and pi
|
||||
=/ b=@
|
||||
%+ roll (gulf 0 (dec lanes))
|
||||
|= [i=@ b=@]
|
||||
=+ x=(mod i 5)
|
||||
=+ y=(div i 5)
|
||||
%+ con b
|
||||
%^ lsh lane-bloq
|
||||
%+ sub lanes
|
||||
%+ add +(y)
|
||||
%+ mul size
|
||||
(mod (add (mul 2 x) (mul 3 y)) size)
|
||||
%^ ~(rol fe lane-bloq) 0
|
||||
(rotation-offset i)
|
||||
(get-word i lanes a)
|
||||
::
|
||||
:: chi
|
||||
=. a
|
||||
%+ roll (gulf 0 (dec lanes))
|
||||
|= [i=@ud a=@]
|
||||
%+ con (lsh lane-bloq 1 a)
|
||||
=+ x=(mod i 5)
|
||||
=+ y=(div i 5)
|
||||
%+ mix (get-lane x y b)
|
||||
%+ dis
|
||||
=- (get-lane - y b)
|
||||
(mod (add x 2) size)
|
||||
%^ not lane-bloq 1
|
||||
(get-lane (mod +(x) size) y b)
|
||||
::
|
||||
:: iota
|
||||
=. a
|
||||
=+ (round-constant round)
|
||||
(mix a (lsh lane-bloq (dec lanes) -))
|
||||
::
|
||||
:: next round
|
||||
$(round +(round))
|
||||
::
|
||||
++ get-lane
|
||||
:> get the lane with coordinates
|
||||
|= [x=@ud y=@ud a=@]
|
||||
=+ i=(add x (mul size y))
|
||||
(get-word i lanes a)
|
||||
::
|
||||
++ get-word
|
||||
:> get word {n} from atom {a} of {m} words.
|
||||
|= [n=@ud m=@ud a=@]
|
||||
(cut lane-bloq [(sub m +((mod n m))) 1] a)
|
||||
::
|
||||
++ round-constant
|
||||
|= c=@ud
|
||||
=- (snag (mod c 24) -)
|
||||
^- (list @ux)
|
||||
:~ 0x1
|
||||
0x8082
|
||||
0x8000.0000.0000.808a
|
||||
0x8000.0000.8000.8000
|
||||
0x808b
|
||||
0x8000.0001
|
||||
0x8000.0000.8000.8081
|
||||
0x8000.0000.0000.8009
|
||||
0x8a
|
||||
0x88
|
||||
0x8000.8009
|
||||
0x8000.000a
|
||||
0x8000.808b
|
||||
0x8000.0000.0000.008b
|
||||
0x8000.0000.0000.8089
|
||||
0x8000.0000.0000.8003
|
||||
0x8000.0000.0000.8002
|
||||
0x8000.0000.0000.0080
|
||||
0x800a
|
||||
0x8000.0000.8000.000a
|
||||
0x8000.0000.8000.8081
|
||||
0x8000.0000.0000.8080
|
||||
0x8000.0001
|
||||
0x8000.0000.8000.8008
|
||||
==
|
||||
::
|
||||
++ rotation-offset
|
||||
|= x=@ud
|
||||
=- (snag x -)
|
||||
^- (list @ud)
|
||||
:~ 0 1 62 28 27
|
||||
36 44 6 55 20
|
||||
3 10 43 25 39
|
||||
41 45 15 21 8
|
||||
18 2 61 56 14
|
||||
==
|
||||
--
|
||||
-- ::keccak
|
||||
-- ::crypto
|
||||
:: ::::
|
||||
:::: ++unity :: (2c) unit promotion
|
||||
|
@ -1,280 +1,242 @@
|
||||
/+ new-hoon, tester
|
||||
=, ls:new-hoon
|
||||
|_ tester-type:tester
|
||||
|_ _tester:tester
|
||||
++ test-head
|
||||
(expect-eq (head [1 ~]) 1 "head")
|
||||
(expect-eq !>([1 (head [1 ~])]))
|
||||
::
|
||||
++ test-last
|
||||
(expect-eq (last:ls [1 2 ~]) 2 "last")
|
||||
(expect-eq !>([2 (last:ls [1 2 ~])]))
|
||||
::
|
||||
++ test-tail
|
||||
(expect-eq (tail [1 2 3 ~]) [2 3 ~] "tail")
|
||||
(expect-eq !>([[2 3 ~] (tail [1 2 3 ~])]))
|
||||
::
|
||||
++ test-init
|
||||
(expect-eq (init [1 2 3 ~]) [1 2 ~] "init")
|
||||
(expect-eq !>([[1 2 ~] (init [1 2 3 ~])]))
|
||||
::
|
||||
++ test-size
|
||||
(expect-eq (size ['a' 'b' 'c' ~]) 3 "size")
|
||||
(expect-eq !>([3 (size ['a' 'b' 'c' ~])]))
|
||||
::
|
||||
++ test-map
|
||||
(expect-eq (map:ls [1 2 ~] |=(a/@ (add 1 a))) [2 3 ~] "map")
|
||||
(expect-eq !>([[2 3 ~] (map:ls [1 2 ~] |=(a/@ (add 1 a)))]))
|
||||
::
|
||||
++ test-reverse
|
||||
(expect-eq (reverse [1 2 3 ~]) [3 2 1 ~] "reverse")
|
||||
(expect-eq !>([[3 2 1 ~] (reverse [1 2 3 ~])]))
|
||||
::
|
||||
++ test-intersperse
|
||||
(expect-eq (intersperse 1 [5 5 5 ~]) [5 1 5 1 5 ~] "intersperse")
|
||||
(expect-eq !>([[5 1 5 1 5 ~] (intersperse 1 [5 5 5 ~])]))
|
||||
::
|
||||
++ test-intercalate
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- ["one,two,three"]
|
||||
(intercalate "," ["one" "two" "three" ~])
|
||||
["one,two,three"]
|
||||
"intercalate"
|
||||
::
|
||||
++ test-transpose
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- ~[~[1 4] ~[2 5] ~[3 6]]
|
||||
(transpose ~[~[1 2 3] ~[4 5 6]])
|
||||
~[~[1 4] ~[2 5] ~[3 6]]
|
||||
"transpose"
|
||||
::
|
||||
++ test-foldl
|
||||
(expect-eq (foldl [1 2 3 ~] 3 |=({a/@ b/@} (add a b))) 9 "foldl")
|
||||
(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 "foldr")
|
||||
(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] "concat")
|
||||
(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"] "weld")
|
||||
(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 "any true")
|
||||
(expect-eq !>([%.y (any [1 2 3 ~] |=(a/@ =(a 2)))]))
|
||||
::
|
||||
++ test-any-false
|
||||
(expect-eq (any [1 2 3 ~] |=(a/@ =(a 8))) %.n "any false")
|
||||
(expect-eq !>([%.n (any [1 2 3 ~] |=(a/@ =(a 8)))]))
|
||||
::
|
||||
++ test-all-true
|
||||
(expect-eq (all [1 1 1 ~] |=(a/@ =(a 1))) %.y "all true")
|
||||
(expect-eq !>([%.y (all [1 1 1 ~] |=(a/@ =(a 1)))]))
|
||||
::
|
||||
++ test-all-false
|
||||
(expect-eq (all [1 3 1 ~] |=(a/@ =(a 1))) %.n "all false")
|
||||
(expect-eq !>([%.n (all [1 3 1 ~] |=(a/@ =(a 1)))]))
|
||||
::
|
||||
++ test-scanl
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- ~[0 1 3 6]
|
||||
(scanl ~[1 2 3] 0 |=({a/@ b/@} (add a b)))
|
||||
~[0 1 3 6]
|
||||
"scanl"
|
||||
::
|
||||
++ test-scanl1
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- ~[1 3 6]
|
||||
(scanl1 ~[1 2 3] |=({a/@ b/@} (add a b)))
|
||||
~[1 3 6]
|
||||
"scanl1"
|
||||
::
|
||||
++ test-scanr
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- ~[6 5 3 0]
|
||||
(scanr ~[1 2 3] 0 |=({a/@ b/@} (add a b)))
|
||||
~[6 5 3 0]
|
||||
"scanr"
|
||||
::
|
||||
++ test-scanr1
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- ~[6 5 3]
|
||||
(scanr1 ~[1 2 3] |=({a/@ b/@} (add a b)))
|
||||
~[6 5 3]
|
||||
"scanr1"
|
||||
::
|
||||
++ test-map-foldl
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [7 ~[2 3 5]]
|
||||
(map-foldl ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)]))
|
||||
[7 ~[2 3 5]]
|
||||
"map-foldl"
|
||||
::
|
||||
++ test-map-foldr
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [7 ~[7 5 2]]
|
||||
(map-foldr ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)]))
|
||||
[7 ~[7 5 2]]
|
||||
"map-foldr"
|
||||
::
|
||||
++ test-unfoldr
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [5 4 3 2 1 ~]
|
||||
(unfoldr 5 |=(a/@ ?:(=(a 0) ~ `[a (dec a)])))
|
||||
[5 4 3 2 1 ~]
|
||||
"unfoldr"
|
||||
::
|
||||
++ test-take
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [1 2 3 ~]
|
||||
(take 3 ~[1 2 3 4 5])
|
||||
[1 2 3 ~]
|
||||
"take"
|
||||
::
|
||||
++ test-drop
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [4 5 ~]
|
||||
(drop:ls 3 ~[1 2 3 4 5])
|
||||
[4 5 ~]
|
||||
"drop"
|
||||
::
|
||||
++ test-split-at
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [[1 2 3 ~] [4 5 ~]]
|
||||
(split-at 3 ~[1 2 3 4 5])
|
||||
[[1 2 3 ~] [4 5 ~]]
|
||||
"split-at"
|
||||
::
|
||||
++ test-take-while
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [1 2 ~]
|
||||
(take-while ~[1 2 3 4 5] |=(a/@ (lth a 3)))
|
||||
[1 2 ~]
|
||||
"take-while"
|
||||
::
|
||||
++ test-drop-while
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [3 4 5 ~]
|
||||
(drop-while ~[1 2 3 4 5] |=(a/@ (lth a 3)))
|
||||
[3 4 5 ~]
|
||||
"drop-while"
|
||||
::
|
||||
++ test-drop-while-end
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [5 5 1 ~]
|
||||
(drop-while-end ~[5 5 1 5 5] |=(a/@ =(a 5)))
|
||||
[5 5 1 ~]
|
||||
"drop-while-end"
|
||||
::
|
||||
++ test-split-on
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [[1 2 ~] [3 4 1 2 3 4 ~]]
|
||||
(split-on ~[1 2 3 4 1 2 3 4] |=(a/@ (lth a 3)))
|
||||
[[1 2 ~] [3 4 1 2 3 4 ~]]
|
||||
"split-on"
|
||||
::
|
||||
++ test-break
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [[1 2 3 ~] [4 1 2 3 4 ~]]
|
||||
(break ~[1 2 3 4 1 2 3 4] |=(a/@ (gth a 3)))
|
||||
[[1 2 3 ~] [4 1 2 3 4 ~]]
|
||||
"break"
|
||||
::
|
||||
++ test-strip-prefix
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [~ "bar"]
|
||||
(strip-prefix "foo" "foobar")
|
||||
[~ "bar"]
|
||||
"break"
|
||||
::
|
||||
++ test-inits
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- ["a" "ab" "abc" ~]
|
||||
(inits "abc")
|
||||
["a" "ab" "abc" ~]
|
||||
"inits"
|
||||
::
|
||||
++ test-tails
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- ["abc" "bc" "c" ~]
|
||||
(tails "abc")
|
||||
["abc" "bc" "c" ~]
|
||||
"tails"
|
||||
::
|
||||
++ test-is-prefix-of
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- %.y
|
||||
(is-prefix-of "foo" "foobar")
|
||||
%.y
|
||||
"is-prefix-of"
|
||||
::
|
||||
++ test-is-suffix-of
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- %.y
|
||||
(is-suffix-of "bar" "foobar")
|
||||
%.y
|
||||
"is-suffix-of"
|
||||
::
|
||||
++ test-is-infix-of
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- %.y
|
||||
(is-infix-of "ob" "foobar")
|
||||
%.y
|
||||
"is-infix-of"
|
||||
::
|
||||
++ test-elem
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- %.y
|
||||
(elem 5 [1 2 3 4 5 ~])
|
||||
%.y
|
||||
"elem"
|
||||
::
|
||||
++ test-lookup
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [~ 2]
|
||||
(lookup "two" [["one" 1] ["two" 2] ["three" 3] ~])
|
||||
[~ 2]
|
||||
"lookup"
|
||||
::
|
||||
++ test-find
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [~ 5]
|
||||
(find:ls [3 2 1 5 1 2 3 ~] |=(a/@ (gth a 3)))
|
||||
[~ 5]
|
||||
"find"
|
||||
::
|
||||
++ test-filter
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [1 1 1 ~]
|
||||
(filter [1 2 1 2 1 ~] |=(a/@ =(a 2)))
|
||||
[1 1 1 ~]
|
||||
"filter"
|
||||
::
|
||||
++ test-partition
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [[2 2 ~] [1 1 1 ~]]
|
||||
(partition [1 2 1 2 1 ~] |=(a/@ =(a 2)))
|
||||
[[2 2 ~] [1 1 1 ~]]
|
||||
"partition"
|
||||
::
|
||||
++ test-elem-index
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- `1
|
||||
(elem-index 2 [1 2 3 4 ~])
|
||||
`1
|
||||
"elem-index"
|
||||
::
|
||||
++ test-elem-indices
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [1 3 ~]
|
||||
(elem-indices 2 [1 2 1 2 ~])
|
||||
[1 3 ~]
|
||||
"elem-indices"
|
||||
::
|
||||
++ test-find-index
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- `1
|
||||
(find-index [1 2 3 ~] |=(a/@ =(a 2)))
|
||||
`1
|
||||
"find-index"
|
||||
::
|
||||
++ test-find-indices
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [1 3 ~]
|
||||
(find-indices [1 2 1 2 ~] |=(a/@ =(a 2)))
|
||||
[1 3 ~]
|
||||
"find-indices"
|
||||
::
|
||||
++ test-zip
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [[1 4 7 ~] [2 5 8 ~] [3 6 9 ~] ~]
|
||||
(zip [[1 2 3 ~] [4 5 6 ~] [7 8 9 ~] ~])
|
||||
[[1 4 7 ~] [2 5 8 ~] [3 6 9 ~] ~]
|
||||
"zip"
|
||||
::
|
||||
++ test-unique
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [1 2 3 ~]
|
||||
(unique [1 2 3 1 2 3 ~])
|
||||
[1 2 3 ~]
|
||||
"unique"
|
||||
::
|
||||
++ test-delete
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [1 3 2 ~]
|
||||
(delete 2 [1 2 3 2 ~])
|
||||
[1 3 2 ~]
|
||||
"delete"
|
||||
::
|
||||
++ test-delete-firsts
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [1 2 3 4 ~]
|
||||
(delete-firsts [1 2 2 2 3 4 5 ~] [2 2 5 ~])
|
||||
[1 2 3 4 ~]
|
||||
"delete-firsts"
|
||||
::
|
||||
++ test-union
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [1 2 3 4 5 ~]
|
||||
(union [1 2 3 ~] [4 2 5 ~])
|
||||
[1 2 3 4 5 ~]
|
||||
"union"
|
||||
::
|
||||
++ test-intersect
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [6 6 8 ~]
|
||||
(intersect [5 6 6 7 8 ~] [9 8 8 6 ~])
|
||||
[6 6 8 ~]
|
||||
"intersect"
|
||||
--
|
||||
|
||||
|
@ -2,108 +2,88 @@
|
||||
=, dct:new-hoon
|
||||
=+ four=(from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] ~])
|
||||
=+ three=(from-list [[1 "one"] [2 "two"] [3 "three"] ~])
|
||||
|_ tester-type:tester
|
||||
|_ _tester:tester
|
||||
++ test-empty
|
||||
(expect-eq (empty four) %.n "empty")
|
||||
(expect-eq !>([%.n (empty four)]))
|
||||
::
|
||||
++ test-size
|
||||
(expect-eq (size four) 4 "size")
|
||||
(expect-eq !>([4 (size four)]))
|
||||
::
|
||||
++ test-member
|
||||
(expect-eq (member four 4) %.y "member")
|
||||
(expect-eq !>([%.y (member four 4)]))
|
||||
::
|
||||
++ test-put-with
|
||||
=+ ints=(from-list [["one" 1] ["two" 2] ["three" 3] ["four" 4] ~])
|
||||
%^ expect-eq
|
||||
%- 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)
|
||||
(from-list [["one" 1] ["two" 2] ["three" 5] ["four" 4] ~])
|
||||
"put-with"
|
||||
::
|
||||
++ test-put-with-key
|
||||
%^ expect-eq
|
||||
%- 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)))
|
||||
(from-list [[1 "one"] [2 "two"] [3 "three"] [4 "4four"] ~])
|
||||
"put-with-key"
|
||||
::
|
||||
++ 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"] ~])
|
||||
"put-lookup-with-key"
|
||||
%- 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
|
||||
%- expect-eq !>
|
||||
:- three
|
||||
(delete four 4)
|
||||
three
|
||||
"delete"
|
||||
::
|
||||
++ test-adjust
|
||||
%^ expect-eq
|
||||
%^ adjust
|
||||
four
|
||||
%- expect-eq !>
|
||||
:- (from-list [[1 "one"] [2 "two"] [3 "thisthree"] [4 "four"] ~])
|
||||
%^ adjust four
|
||||
3
|
||||
|=(a/tape (weld "this" a))
|
||||
(from-list [[1 "one"] [2 "two"] [3 "thisthree"] [4 "four"] ~])
|
||||
"adjust"
|
||||
|=(a/tape (weld "this" a))
|
||||
::
|
||||
++ test-adjust-with-key
|
||||
%^ expect-eq
|
||||
%^ adjust-with-key
|
||||
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))
|
||||
(from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~])
|
||||
"adjust-with-key"
|
||||
|=({a/@ud b/tape} (weld (scow %ud a) b))
|
||||
::
|
||||
++ test-update
|
||||
%^ expect-eq
|
||||
%^ update
|
||||
four
|
||||
%- expect-eq !>
|
||||
:- (from-list [[1 "one"] [2 "two"] [4 "four"] ~])
|
||||
%^ update four
|
||||
3
|
||||
|=(a/tape `(maybe tape)`~)
|
||||
(from-list [[1 "one"] [2 "two"] [4 "four"] ~])
|
||||
"update"
|
||||
|=(a/tape `(maybe tape)`~)
|
||||
::
|
||||
++ test-update-with-key
|
||||
%^ expect-eq
|
||||
%^ update-with-key
|
||||
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)])
|
||||
(from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~])
|
||||
"update-with-key"
|
||||
|=({a/@u b/tape} `(maybe tape)`[~ (weld (scow %ud a) b)])
|
||||
::
|
||||
++ test-alter-as-add
|
||||
%^ expect-eq
|
||||
%^ alter
|
||||
four
|
||||
%- expect-eq !>
|
||||
:- (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] [5 "five"] ~])
|
||||
%^ alter four
|
||||
5
|
||||
|=(a/(maybe tape) `(maybe tape)`[~ "five"])
|
||||
(from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] [5 "five"] ~])
|
||||
"alter (as add)"
|
||||
|=(a/(maybe tape) `(maybe tape)`[~ "five"])
|
||||
::
|
||||
++ test-alter-as-delete
|
||||
%^ expect-eq
|
||||
%^ alter
|
||||
four
|
||||
%- expect-eq !>
|
||||
:- (from-list [[1 "one"] [3 "three"] [4 "four"] ~])
|
||||
%^ alter four
|
||||
2
|
||||
|=(a/(maybe tape) `(maybe tape)`~)
|
||||
(from-list [[1 "one"] [3 "three"] [4 "four"] ~])
|
||||
"alter (as delete)"
|
||||
|=(a/(maybe tape) `(maybe tape)`~)
|
||||
::
|
||||
++ test-alter-as-change
|
||||
%^ expect-eq
|
||||
%^ alter
|
||||
four
|
||||
%- expect-eq !>
|
||||
:- (from-list [[1 "one"] [2 "dos"] [3 "three"] [4 "four"] ~])
|
||||
%^ alter four
|
||||
2
|
||||
|=(a/(maybe tape) `(maybe tape)`[~ "dos"])
|
||||
(from-list [[1 "one"] [2 "dos"] [3 "three"] [4 "four"] ~])
|
||||
"alter (as change)"
|
||||
|=(a/(maybe tape) `(maybe tape)`[~ "dos"])
|
||||
::
|
||||
++ check-alter
|
||||
:: check random dicts of 50 items with 40 random operations done on them
|
||||
@ -133,228 +113,192 @@
|
||||
$(i +(i))
|
||||
::
|
||||
++ test-union
|
||||
%^ expect-eq
|
||||
%+ union
|
||||
%- expect-eq !>
|
||||
:- (from-list [[1 "left"] [2 "left"] [3 "right"] ~])
|
||||
%+ union
|
||||
(from-list [[1 "left"] [2 "left"] ~])
|
||||
(from-list [[2 "right"] [3 "right"] ~])
|
||||
(from-list [[1 "left"] [2 "left"] [3 "right"] ~])
|
||||
"union"
|
||||
(from-list [[2 "right"] [3 "right"] ~])
|
||||
::
|
||||
++ test-union-with
|
||||
%^ expect-eq
|
||||
%^ union-with
|
||||
(from-list [[1 "left"] [2 "left"] ~])
|
||||
%- 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))
|
||||
(from-list [[1 "left"] [2 "leftright"] [3 "right"] ~])
|
||||
"union-with"
|
||||
|=({a/tape b/tape} (weld a b))
|
||||
::
|
||||
++ test-union-with-key
|
||||
%^ expect-eq
|
||||
%^ union-with-key
|
||||
(from-list [[1 "left"] [2 "left"] ~])
|
||||
%- 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))
|
||||
(from-list [[1 "left"] [2 "2leftright"] [3 "right"] ~])
|
||||
"union-with-key"
|
||||
|=({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'] ~])
|
||||
"map"
|
||||
%- 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"] ~])
|
||||
"map-with-key"
|
||||
%- 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: twoonethree"
|
||||
(from-list [[1 "oneX"] [2 "twoX"] [3 "threeX"] ~])
|
||||
"map-fold"
|
||||
%- 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"] ~])
|
||||
"map-keys"
|
||||
%- 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
|
||||
%- expect-eq !>
|
||||
:- (from-list [[42 "twothreeone"] ~])
|
||||
%^ map-keys-with three
|
||||
|=(a/@u 42)
|
||||
weld
|
||||
(from-list [[42 "twothreeone"] ~])
|
||||
"map-keys-with"
|
||||
weld
|
||||
::
|
||||
++ test-fold
|
||||
%^ expect-eq
|
||||
%^ fold
|
||||
three
|
||||
%- 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)
|
||||
"Everything: twoonethree"
|
||||
"map-fold"
|
||||
:: 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
|
||||
%- expect-eq !>
|
||||
:- "Everything: 2two1one3three"
|
||||
%^ fold-with-keys three
|
||||
"Everything: "
|
||||
|= {accumulator/tape key/@u value/tape}
|
||||
^- tape
|
||||
:(weld accumulator (scow %ud key) value)
|
||||
"Everything: 2two1one3three"
|
||||
"map-fold-with-keys"
|
||||
|= {accumulator/tape key/@u value/tape}
|
||||
^- tape
|
||||
:(weld accumulator (scow %ud key) value)
|
||||
::
|
||||
++ test-elems
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- ["two" "three" "one" ~]
|
||||
(elems three)
|
||||
["two" "three" "one" ~]
|
||||
"elems"
|
||||
::
|
||||
++ test-keys
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [2 3 1 ~]
|
||||
(keys three)
|
||||
[2 3 1 ~]
|
||||
"keys"
|
||||
::
|
||||
++ test-keys-set
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- (si:nl [2 3 1 ~])
|
||||
(keys-set three)
|
||||
(si:nl [2 3 1 ~])
|
||||
"keys-set"
|
||||
::
|
||||
++ test-from-set
|
||||
%^ expect-eq
|
||||
%+ from-set
|
||||
%- expect-eq !>
|
||||
:- (from-list [[1 "1"] [2 "2"] [3 "3"] ~])
|
||||
%+ from-set
|
||||
(si:nl [1 2 3 ~])
|
||||
|= a/@u
|
||||
(scow %ud a)
|
||||
(from-list [[1 "1"] [2 "2"] [3 "3"] ~])
|
||||
"from-set"
|
||||
|=(a/@u (scow %ud a))
|
||||
::
|
||||
++ test-from-list-with
|
||||
%^ expect-eq
|
||||
%+ from-list-with
|
||||
%- expect-eq !>
|
||||
:- (from-list [[1 1] [2 2] [3 3] ~])
|
||||
%+ from-list-with
|
||||
[[1 1] [2 1] [2 1] [3 3] ~]
|
||||
add
|
||||
(from-list [[1 1] [2 2] [3 3] ~])
|
||||
"from-list-with"
|
||||
add
|
||||
::
|
||||
++ test-filter
|
||||
%^ expect-eq
|
||||
%+ filter
|
||||
%- 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))
|
||||
(from-list [[1 1] [2 1] [4 1] ~])
|
||||
"filter"
|
||||
|=(a/@u !=(a 1))
|
||||
::
|
||||
++ test-filter-with-key
|
||||
%^ expect-eq
|
||||
%+ filter-with-key
|
||||
%- 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))
|
||||
(from-list [[1 1] [3 2] [4 1] ~])
|
||||
"filter-with-key"
|
||||
|=({a/@u b/@u} =(a 2))
|
||||
::
|
||||
++ test-restrict-keys
|
||||
%^ expect-eq
|
||||
%+ restrict-keys
|
||||
%- 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 ~])
|
||||
(from-list [[1 1] [3 3] [5 5] ~])
|
||||
"restrict-keys"
|
||||
(si:nl [1 3 5 ~])
|
||||
::
|
||||
++ test-without-keys
|
||||
%^ expect-eq
|
||||
%+ without-keys
|
||||
%- 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 ~])
|
||||
(from-list [[2 2] [4 4] ~])
|
||||
"restrict-keys"
|
||||
(si:nl [1 3 5 ~])
|
||||
::
|
||||
++ test-partition
|
||||
%^ expect-eq
|
||||
%+ partition
|
||||
%- 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)))
|
||||
:- (from-list [[1 1] [3 3] ~])
|
||||
(from-list [[2 2] [4 4] [5 5] ~])
|
||||
"partition"
|
||||
|=(a/@u |(=(a 1) =(a 3)))
|
||||
::
|
||||
++ test-map-maybe
|
||||
%^ expect-eq
|
||||
%+ map-maybe
|
||||
%- 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))
|
||||
(from-list [[1 1] [2 2] [4 4] [5 5] ~])
|
||||
"map-maybe"
|
||||
|=(a/@u ?:(=(a 3) ~ `a))
|
||||
::
|
||||
++ test-map-maybe-with-key
|
||||
%^ expect-eq
|
||||
%+ map-maybe-with-key
|
||||
%- 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))
|
||||
(from-list [[1 2] [2 3] [4 5] [5 6] ~])
|
||||
"map-maybe-with-key"
|
||||
|=({k/@u v/@u} ?:(=(k 3) ~ `v))
|
||||
::
|
||||
++ test-map-either
|
||||
%^ expect-eq
|
||||
%- 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] ~])
|
||||
"map-either"
|
||||
::
|
||||
++ test-map-either-with-key
|
||||
%^ expect-eq
|
||||
%- 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]
|
||||
:- (from-list [[2 "even"] [4 "even"] ~])
|
||||
(from-list [[1 1] [3 1] [5 1] ~])
|
||||
"map-either"
|
||||
|= {key/@u value/@u}
|
||||
?: =(0 (mod key 2))
|
||||
[%& "even"]
|
||||
[%| 1]
|
||||
::
|
||||
++ test-is-subdict
|
||||
%^ expect-eq
|
||||
%^ is-subdict-by
|
||||
(from-list [[1 1] [4 4] ~])
|
||||
%- 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
|
||||
"is-subdict"
|
||||
|=({a/* b/*} =(a b))
|
||||
::
|
||||
++ test-valid
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- &
|
||||
(valid (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] [6 6] [7 7] [8 8] [9 9] ~]))
|
||||
%.y
|
||||
"valid"
|
||||
--
|
||||
|
||||
|
@ -1,32 +1,31 @@
|
||||
/+ new-hoon, tester
|
||||
=, myb:new-hoon
|
||||
|_ tester-type:tester
|
||||
|_ _tester:tester
|
||||
++ test-from-list-null
|
||||
(expect-eq (from-list ~) ~ "from-list")
|
||||
(expect-eq !>([~ (from-list ~)]))
|
||||
::
|
||||
++ test-from-list-real
|
||||
(expect-eq (from-list [5 ~]) [~ 5] "from-list")
|
||||
(expect-eq !>([[~ 5] (from-list [5 ~])]))
|
||||
::
|
||||
++ test-to-list-null
|
||||
(expect-eq (to-list ~) ~ "to-list")
|
||||
(expect-eq !>([~ (to-list ~)]))
|
||||
::
|
||||
++ test-to-list-real
|
||||
(expect-eq (to-list [~ 5]) [5 ~] "to-list")
|
||||
(expect-eq !>([[5 ~] (to-list [~ 5])]))
|
||||
::
|
||||
++ test-concat-null
|
||||
(expect-eq (concat ~) ~ "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 ~] "concat")
|
||||
(expect-eq !>([[1 2 ~] (concat `(list (maybe @ud))`[~ [~ 1] ~ [~ 2] ~])]))
|
||||
::
|
||||
++ test-map
|
||||
%^ expect-eq
|
||||
%+ map:myb
|
||||
%- expect-eq !>
|
||||
:- [2 2 ~]
|
||||
%+ map:myb
|
||||
[1 2 3 2 ~]
|
||||
|=(a/@u ?:(=(2 a) [~ 2] ~))
|
||||
[2 2 ~]
|
||||
"map"
|
||||
|=(a/@u ?:(=(2 a) [~ 2] ~))
|
||||
--
|
||||
|
||||
|
@ -2,31 +2,26 @@
|
||||
/+ new-hoon, tester
|
||||
=, thr:new-hoon
|
||||
=/ data/(list (either @u tape)) [[%& 1] [%| "one"] [%& 2] [%| "two"] ~]
|
||||
|_ tester-type:tester
|
||||
|_ _tester:tester
|
||||
++ test-apply
|
||||
%^ expect-eq
|
||||
%^ apply
|
||||
`(either @u tape)`[%| "one"]
|
||||
%- expect-eq !>
|
||||
:- "right"
|
||||
%^ apply `(either @u tape)`[%| "one"]
|
||||
|=(a/@u "left")
|
||||
|=(b/tape "right")
|
||||
"right"
|
||||
"apply"
|
||||
|=(b/tape "right")
|
||||
::
|
||||
++ test-firsts
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [1 2 ~]
|
||||
(firsts data)
|
||||
[1 2 ~]
|
||||
"firsts"
|
||||
::
|
||||
++ test-seconds
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- ["one" "two" ~]
|
||||
(seconds data)
|
||||
["one" "two" ~]
|
||||
"seconds"
|
||||
::
|
||||
++ test-partition
|
||||
%^ expect-eq
|
||||
%- expect-eq !>
|
||||
:- [[1 2 ~] ["one" "two" ~]]
|
||||
(partition data)
|
||||
[[1 2 ~] ["one" "two" ~]]
|
||||
"partition"
|
||||
--
|
||||
|
303
tests/zuse/crypto/keccak.hoon
Normal file
303
tests/zuse/crypto/keccak.hoon
Normal file
@ -0,0 +1,303 @@
|
||||
:: tests for the keccak hashing algorithms
|
||||
::
|
||||
:: answers for keccak from the keccak team:
|
||||
:: https://keccak.team/archives.html
|
||||
:: (we swp the inputs because ++keccak wants to work with @t's, which are in
|
||||
:: reverse byte order)
|
||||
::
|
||||
:: since all other hashing algorithms are implemented as keccak, their only
|
||||
:: difference a single padding byte, we can safely test just one input.
|
||||
:: answers for those pulled from the nist website:
|
||||
:: https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
|
||||
::
|
||||
:: answer for rawshake-256 was found here:
|
||||
:: https://github.com/maandree/libkeccak/blob/master/test.c
|
||||
:: for rawshake-128, the implementation was assumed to be correct at the time
|
||||
:: these tests were written.
|
||||
::
|
||||
::
|
||||
/+ tester
|
||||
=, keccak:crypto
|
||||
::
|
||||
:: per bytelength, an example input.
|
||||
=/ keccak-inputs=(map @ud @)
|
||||
=- (~(run by -) (cury swp 3))
|
||||
%- ~(gas by *(map @ud @))
|
||||
^- (list (pair @ud @))
|
||||
:~
|
||||
:- 0
|
||||
0x0
|
||||
::
|
||||
:- 1
|
||||
0xcc
|
||||
::
|
||||
:- 4
|
||||
0xc1ec.fdfc
|
||||
::
|
||||
:- 8
|
||||
0x4a4f.2024.8451.2526
|
||||
::
|
||||
:- 64
|
||||
0xe926.ae8b.0af6.e531.76db.ffcc.2a6b.88c6.
|
||||
bd76.5f93.9d3d.178a.9bde.9ef3.aa13.1c61.
|
||||
e31c.1e42.cdfa.f4b4.dcde.579a.37e1.50ef.
|
||||
bef5.555b.4c1c.b404.39d8.35a7.24e2.fae7
|
||||
::
|
||||
:- 128
|
||||
0x2b6d.b7ce.d866.5ebe.9deb.0802.9521.8426.
|
||||
bdaa.7c6d.a9ad.d208.8932.cdff.baa1.c141.
|
||||
29bc.cdd7.0f36.9efb.1492.8585.8d2b.1d15.
|
||||
5d14.de2f.db68.0a8b.0272.8405.5182.a0ca.
|
||||
e275.234c.c9c9.2863.c1b4.ab66.f304.cf06.
|
||||
21cd.5456.5f5b.ff46.1d3b.461b.d40d.f281.
|
||||
98e3.7325.01b4.860e.add5.03d2.6d6e.6933.
|
||||
8f4e.0456.e9e9.baf3.d827.ae68.5fb1.d817
|
||||
::
|
||||
:- 255
|
||||
0x3a.3a81.9c48.efde.2ad9.14fb.f00e.18ab.
|
||||
6bc4.f145.13ab.27d0.c178.a188.b614.31e7.
|
||||
f562.3cb6.6b23.3467.75d3.86b5.0e98.2c49.
|
||||
3adb.bfc5.4b9a.3cd3.8338.2336.a1a0.b215.
|
||||
0a15.358f.336d.03ae.18f6.66c7.573d.55c4.
|
||||
fd18.1c29.e6cc.fde6.3ea3.5f0a.df58.85cf.
|
||||
c0a3.d84a.2b2e.4dd2.4496.db78.9e66.3170.
|
||||
cef7.4798.aa1b.bcd4.574e.a0bb.a404.89d7.
|
||||
64b2.f83a.adc6.6b14.8b4a.0cd9.5246.c127.
|
||||
d587.1c4f.1141.8690.a5dd.f012.46a0.c80a.
|
||||
43c7.0088.b618.3639.dcfd.a412.5bd1.13a8.
|
||||
f49e.e23e.d306.faac.576c.3fb0.c1e2.5667.
|
||||
1d81.7fc2.534a.52f5.b439.f72e.424d.e376.
|
||||
f4c5.65cc.a823.07dd.9ef7.6da5.b7c4.eb7e.
|
||||
0851.72e3.2880.7c02.d011.ffbf.3378.5378.
|
||||
d79d.c266.f6a5.be6b.b0e4.a92e.ceeb.aeb1
|
||||
==
|
||||
::
|
||||
|_ tst=_tester:tester
|
||||
::
|
||||
:: check a list of bytelength-answer pairs to see if
|
||||
:: they match the output given by {hash} for the
|
||||
:: corresponding example input from {keccak-inputs}.
|
||||
++ verify-known-answers
|
||||
|= $: hash=$-(octs @)
|
||||
name=tape
|
||||
answers=(list (pair @ud @))
|
||||
==
|
||||
^- wall
|
||||
?~ answers ~
|
||||
%+ weld $(answers t.answers)
|
||||
=+ `[bytes=@ud answer=@]`i.answers
|
||||
%+ category.tst name
|
||||
%- expect-eq.tst !>
|
||||
:- answer
|
||||
(hash bytes (~(got by keccak-inputs) bytes))
|
||||
::
|
||||
:: keccak
|
||||
::
|
||||
++ test-keccak-224
|
||||
%^ verify-known-answers keccak-224 "keccak-224"
|
||||
:~ :- 0
|
||||
0xf718.3750.2ba8.e108.37bd.d8d3.65ad.b855.
|
||||
9189.5602.fc55.2b48.b739.0abd
|
||||
::
|
||||
:- 1
|
||||
0xa9ca.b59e.b40a.10b2.4629.0f2d.6086.e32e.
|
||||
3689.faf1.d26b.470c.899f.2802
|
||||
::
|
||||
:- 4
|
||||
0xe405.869d.a146.4a70.5700.a3cb.ce13.1aab.
|
||||
eeba.9c8d.2fe6.576b.21bc.be16
|
||||
::
|
||||
:- 8
|
||||
0x7a5c.2cb3.f999.dd00.eff7.3999.6331.4ca6.
|
||||
47dd.0e5a.e1bd.dec6.11f8.338d
|
||||
::
|
||||
:- 64
|
||||
0xc533.dcf8.8cd1.a5df.f22b.914d.3875.bd57.
|
||||
fc17.b2e1.f474.ae36.0c38.77d2
|
||||
::
|
||||
:- 128
|
||||
0xaf3e.0cc6.e645.01f1.0fd3.9722.e852.355f.
|
||||
d6d8.0d32.1906.31e2.f06c.22ad
|
||||
::
|
||||
:- 255
|
||||
0x5af5.6987.ea9c.f11f.cd0e.ac5e.bc14.b037.
|
||||
365e.9b11.23e3.1cb2.dfc7.929a
|
||||
==
|
||||
::
|
||||
++ test-keccak-256
|
||||
%^ verify-known-answers keccak-256 "keccak-256"
|
||||
:~ :- 0
|
||||
0xc5d2.4601.86f7.233c.927e.7db2.dcc7.03c0.
|
||||
e500.b653.ca82.273b.7bfa.d804.5d85.a470
|
||||
::
|
||||
:- 1
|
||||
0xeead.6dbf.c734.0a56.caed.c044.696a.1688.
|
||||
7054.9a6a.7f6f.5696.1e84.a54b.d997.0b8a
|
||||
::
|
||||
:- 4
|
||||
0xb149.e766.d761.2eaf.7d55.f74e.1a4f.dd63.
|
||||
709a.8115.b14f.61fc.d22a.a4ab.c8b8.e122
|
||||
::
|
||||
:- 8
|
||||
0xe620.d8f2.982b.24fe.daaa.3baa.9b46.c3f9.
|
||||
ce20.4ee3.5666.6553.ecb3.5e15.c3ff.9bf9
|
||||
::
|
||||
:- 64
|
||||
0x5742.71cd.1395.9e8d.deae.5bfb.db02.a3fd.
|
||||
f54f.2bab.fd0c.beb8.9308.2a97.4957.d0c1
|
||||
::
|
||||
:- 128
|
||||
0xd82e.257d.000d.c9fa.279a.00e2.961e.3286.
|
||||
d2fe.1c02.ef59.833a.b8a6.a710.1bc2.5054
|
||||
::
|
||||
:- 255
|
||||
0x348f.b774.adc9.70a1.6b11.0566.9442.625e.
|
||||
6ada.a825.7a89.effd.b5a8.02f1.61b8.62ea
|
||||
==
|
||||
::
|
||||
++ test-keccak-384
|
||||
%^ verify-known-answers keccak-384 "keccak-384"
|
||||
:~ :- 0
|
||||
0x2c23.146a.63a2.9acf.99e7.3b88.f8c2.4eaa.
|
||||
7dc6.0aa7.7178.0ccc.006a.fbfa.8fe2.479b.
|
||||
2dd2.b213.6233.7441.ac12.b515.9119.57ff
|
||||
::
|
||||
:- 1
|
||||
0x1b84.e62a.46e5.a201.8617.54af.5dc9.5c4a.
|
||||
1a69.caf4.a796.ae40.5680.161e.2957.2641.
|
||||
f5fa.1e86.41d7.9583.36ee.7b11.c58f.73e9
|
||||
::
|
||||
:- 4
|
||||
0xf185.0b2a.bb24.f3fd.683c.7015.8278.9d9e.
|
||||
92b6.a45f.9c34.5f9d.ae7f.7997.c8c9.10e8.
|
||||
8003.e592.e592.81cf.92c9.2d6b.51a1.afd1
|
||||
::
|
||||
:- 8
|
||||
0x638e.6575.8a29.7cb0.9ded.1ac5.b9e8.f779.
|
||||
8020.00ab.791f.67f3.3c60.be36.4437.93ad.
|
||||
cc8a.4a58.e986.8815.7a41.784f.02a4.bcb2
|
||||
::
|
||||
:- 64
|
||||
0x14aa.679b.0c11.f9c3.63f5.4933.0261.b45e.
|
||||
1e90.ce31.f4a1.b0ce.5cb9.eb81.bd60.79a3.
|
||||
742d.8602.356c.5098.5d0d.3e54.0fdf.dcfb
|
||||
::
|
||||
:- 128
|
||||
0x3ade.b7ee.ecf9.069f.143a.1015.1fd4.506a.
|
||||
eef3.a0ef.94ca.65d4.448a.cf1e.892b.8ebb.
|
||||
0887.6318.04dd.64e1.53ad.41fa.e012.7a85
|
||||
::
|
||||
:- 255
|
||||
0x6bff.1c84.05a3.fe59.4e36.0e3b.ccea.1ebc.
|
||||
d509.310d.c79b.9e45.c263.783d.7a5d.d662.
|
||||
c678.9b18.bd56.7dbd.da15.54f5.bee6.a860
|
||||
==
|
||||
::
|
||||
++ test-keccak-512
|
||||
%^ verify-known-answers keccak-512 "keccak-512"
|
||||
:~ :- 0
|
||||
0xeab.42de.4c3c.eb92.35fc.91ac.ffe7.46b2.
|
||||
9c29.a8c3.66b7.c60e.4e67.c466.f36a.4304.
|
||||
c00f.a9ca.f9d8.7976.ba46.9bcb.e067.13b4.
|
||||
35f0.91ef.2769.fb16.0cda.b33d.3670.680e
|
||||
::
|
||||
:- 1
|
||||
0x8630.c13c.bd06.6ea7.4bbe.7fe4.68fe.c1de.
|
||||
e10e.dc12.54fb.4c1b.7c5f.d69b.646e.4416.
|
||||
0b8c.e01d.05a0.908c.a790.dfb0.80f4.b513.
|
||||
bc3b.6225.ece7.a810.3714.41a5.ac66.6eb9
|
||||
::
|
||||
:- 4
|
||||
0x952d.4c0a.6f0e.f5ce.438c.52e3.edd3.45ea.
|
||||
00f9.1cf5.da80.97c1.168a.1606.9e95.8fc0.
|
||||
5bad.90a0.c5fb.4dd9.ec28.e84b.226b.94a8.
|
||||
47d6.bb89.2356.92ef.4c97.12f0.c703.0fae
|
||||
::
|
||||
:- 8
|
||||
0xf326.c7c1.26dd.c277.9227.60fe.ef77.c9ba.
|
||||
b6fb.5d34.30f6.5259.3703.d7c5.e301.35cd.
|
||||
0b05.7525.7509.a624.1843.30d6.ab1f.508a.
|
||||
6663.91b5.d469.0426.b4e0.5301.891d.f897
|
||||
::
|
||||
:- 64
|
||||
0xc0a4.d8dc.a967.772d.bf6e.5508.c913.e7be.
|
||||
ba1b.749a.2b1a.c963.d067.6e6f.1dcd.4eba.
|
||||
a3f9.09ef.87dd.8498.82dc.8253.347a.5f65.
|
||||
20b5.b9f5.1097.3f44.3976.455f.923c.fcb9
|
||||
::
|
||||
:- 128
|
||||
0xaebb.a57c.8ed5.af6e.c93f.4aa4.5772.ff51.
|
||||
67b7.ea88.dfa7.1364.f37d.8fc5.fdb7.dc3b.
|
||||
2c83.31a0.8023.f21d.110b.7d82.1e2d.c7e8.
|
||||
6082.6235.e7e6.2919.12ac.5213.8474.7354
|
||||
::
|
||||
:- 255
|
||||
0x8195.0e70.96d3.1d4f.22e3.db71.cac7.25bf.
|
||||
59e8.1af5.4c7c.a9e6.aeee.71c0.10fc.5467.
|
||||
4663.12a0.1aa5.c137.cfb1.4064.6941.5567.
|
||||
96f6.12c9.3512.6873.7c7e.9a2b.9631.d1fa
|
||||
==
|
||||
::
|
||||
:: sha3
|
||||
::
|
||||
++ test-sha3-224
|
||||
%- 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 !>
|
||||
:- 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 !>
|
||||
:- 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 !>
|
||||
:- 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)
|
||||
::
|
||||
:: shake
|
||||
::
|
||||
++ test-shake-128
|
||||
%- 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 !>
|
||||
:- 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 !>
|
||||
:- 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 !>
|
||||
:- 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)
|
||||
--
|
@ -1041,7 +1041,7 @@ Member = require('./MemberComponent.coffee');
|
||||
|
||||
SHIPSHAPE = /^~?([a-z]{3}|[a-z]{6}(-[a-z]{6}){0,3}|[a-z]{6}(-[a-z]{6}){3}(--[a-z]{6}(-[a-z]{6}){3})+)$/;
|
||||
|
||||
PO = 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\nrigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\nholpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\nlosdilforpilramtirwintadbicdifrocwidbisdasmidlop\nrilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\nritpodmottamtolsavposnapnopsomfinfonbanporworsip\nronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\nsivtagpadsaldivdactansidfabtarmonranniswolmispal\nlasdismaprabtobrollatlonnodnavfignomnibpagsopral\nbilhaddocridmocpacravripfaltodtiltinhapmicfanpat\ntaclabmogsimsonpinlomrictapfirhasbosbatpochactid\nhavsaplindibhosdabbitbarracparloddosbortochilmac\ntomdigfilfasmithobharmighinradmashalraglagfadtop\nmophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\nnimlarfitwalrapsarnalmoslandondanladdovrivbacpol\nlaptalpitnambonrostonfodponsovnocsorlavmatmipfap\n\nzodnecbudwessevpersutletfulpensytdurwepserwylsun\nrypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\nlunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\npyldulhetmevruttylwydtepbesdexsefwycburderneppur\nrysrebdennutsubpetrulsynregtydsupsemwynrecmegnet\nsecmulnymtevwebsummutnyxrextebfushepbenmuswyxsym\nselrucdecwexsyrwetdylmynmesdetbetbeltuxtugmyrpel\nsyptermebsetdutdegtexsurfeltudnuxruxrenwytnubmed\nlytdusnebrumtynseglyxpunresredfunrevrefmectedrus\nbexlebduxrynnumpyxrygryxfeptyrtustyclegnemfermer\ntenlusnussyltecmexpubrymtucfyllepdebbermughuttun\nbylsudpemdevlurdefbusbeprunmelpexdytbyttyplevmyl\nwedducfurfexnulluclennerlexrupnedlecrydlydfenwel\nnydhusrelrudneshesfetdesretdunlernyrsebhulryllud\nremlysfynwerrycsugnysnyllyndyndemluxfedsedbecmun\nlyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes';
|
||||
PO = 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\nrigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\nholpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\nlosdilforpilramtirwintadbicdifrocwidbisdasmidlop\nrilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\nritpodmottamtolsavposnapnopsomfinfonbanmorworsip\nronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\nsivtagpadsaldivdactansidfabtarmonranniswolmispal\nlasdismaprabtobrollatlonnodnavfignomnibpagsopral\nbilhaddocridmocpacravripfaltodtiltinhapmicfanpat\ntaclabmogsimsonpinlomrictapfirhasbosbatpochactid\nhavsaplindibhosdabbitbarracparloddosbortochilmac\ntomdigfilfasmithobharmighinradmashalraglagfadtop\nmophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\nnimlarfitwalrapsarnalmoslandondanladdovrivbacpol\nlaptalpitnambonrostonfodponsovnocsorlavmatmipfip\n\nzodnecbudwessevpersutletfulpensytdurwepserwylsun\nrypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\nlunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\npyldulhetmevruttylwydtepbesdexsefwycburderneppur\nrysrebdennutsubpetrulsynregtydsupsemwynrecmegnet\nsecmulnymtevwebsummutnyxrextebfushepbenmuswyxsym\nselrucdecwexsyrwetdylmynmesdetbetbeltuxtugmyrpel\nsyptermebsetdutdegtexsurfeltudnuxruxrenwytnubmed\nlytdusnebrumtynseglyxpunresredfunrevrefmectedrus\nbexlebduxrynnumpyxrygryxfeptyrtustyclegnemfermer\ntenlusnussyltecmexpubrymtucfyllepdebbermughuttun\nbylsudpemdevlurdefbusbeprunmelpexdytbyttyplevmyl\nwedducfurfexnulluclennerlexrupnedlecrydlydfenwel\nnydhusrelrudneshesfetdesretdunlernyrsebhulryllud\nremlysfynwerrycsugnysnyllyndyndemluxfedsedbecmun\nlyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes';
|
||||
|
||||
textToHTML = function(txt) {
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user