hoon: adds new +mug (as +gum)

This commit is contained in:
Joe Bryan 2020-11-24 23:48:54 -08:00
parent d80e608b8a
commit fc30df7401
2 changed files with 61 additions and 0 deletions

View File

@ -1081,6 +1081,23 @@
=+ ham=(mix (rsh 0 31 haz) (end 0 31 haz))
?.(=(0 ham) ham $(syd +(syd)))
--
++ gum
~/ %gum
|= a=*
|^ ?@ a (mum 0xcafe.babe 0x7fff a)
=/ b (cat 5 $(a -.a) $(a +.a))
(mum 0xdead.beef 0xfffe b)
::
++ mum
|= [syd=@uxF fal=@F key=@]
=/ wyd (met 3 key)
=| i=@ud
|- ^- @F
?: =(8 i) fal
=/ haz=@F (muk syd wyd key)
=/ ham=@F (mix (rsh 0 31 haz) (end 0 31 haz))
?.(=(0 ham) ham $(i +(i), syd +(syd)))
--
:: ::
:::: 2f: noun ordering ::
:: ::

View File

@ -53,6 +53,50 @@
!> 0x2ad3.9968
!> (mug [(dec (bex 128)) 1])
==
::
++ test-gum
;: weld
%+ expect-eq
!> 0x4d44.1035
!> (gum 'Hello, world!')
::
%+ expect-eq
!> 0x79ff.04e8
!> (gum 0)
::
%+ expect-eq
!> 0x715c.2a60
!> (gum 1)
::
%+ expect-eq
!> 0x64df.da5c
!> (gum (crip (reap 28 'x')))
::
%+ expect-eq
!> 0x192f.5588
!> (gum [0 0])
::
%+ expect-eq
!> 0x6b32.ec46
!> (gum [1 1])
::
%+ expect-eq
!> 0x2ef.fe10
!> (gum [2 2])
::
%+ expect-eq
!> 0x3a81.1aec
!> (gum [1 2 3])
::
%+ expect-eq
!> 0x7ce.fb7f
!> (gum [0 (bex 32)])
::
%+ expect-eq
!> 0x2aa0.6bfc
!> (gum [(dec (bex 128)) 1])
==
::
:: SHA tests
:: For references see FIPS180-4 and related test vectors
:: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf