Merge pull request #1411 from urbit/slam-wa

add +slam:wa and tests
This commit is contained in:
ixv 2019-08-02 11:31:11 -07:00 committed by GitHub
commit 6c9c6e1a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 6 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e0db2000c69c5e325413d3483183f2d87c810b9596ed68f0e5eb1755525668b8
size 6972895
oid sha256:98e1fb68057cdb96e6f44620b6090a761872f0909c0ce4fdbf50bc981774b7db
size 7047735

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a8d28b096db251b3abffb2d96cf243274ba377e19d71dbfce87bb38d3cd88a9f
size 4609208
oid sha256:8b2dcc3e03801d98a2c7ffc33ce8f2225c459da4a7f415ecf8bf61a68d1d1b72
size 4686987

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:210786877b2436c005e70f67ce929d3f56d624b4497f3476f3f0dcbadbcbb084
size 9692780
oid sha256:4dbd84a26d0f440e8a7a1bd195472d188ab75c2f7f45b302a7dee101f3f062ee
size 9775281

View File

@ -17290,6 +17290,14 @@
=+ new=(~(mint ut sut) %noun gen)
[new +>+<.$(mit (~(put by mit) [sut gen] new))]
::
++ slam :: ++slam, cached
|= [gat=vase sam=vase]
^- [vase worm]
=/ sut=type [%cell p.gat p.sam]
=/ gen=hoon [%cnsg [%$ ~] [%$ 2] [%$ 3] ~]
=^ new=type +>+<.$ (play sut gen)
[[new (slum q.gat q.sam)] +>+<.$]
::
++ slap :: ++slap, cached
|= {vax/vase gen/hoon}
^- {vase worm}

View File

@ -0,0 +1,37 @@
/+ *test
|%
++ test-slam-wa-dry ^- tang
::
%+ expect-eq
!>(7)
-:(~(slam wa *worm) !>(add) !>([3 4]))
:: +test-slam-wa-wet: does +slam:wa perform correct wet type inference?
::
:: Also test that the cache doesn't gain any new entries when given a
:: sample of a previously seen type.
::
++ test-slam-wa-wet ^- tang
:: use the same .list-type for both calls
::
:: Types defined on different lines won't be noun-equal, and so
:: won't test that the cache kicked in on the second entry.
::
=/ list-type=type -:!>(*(list @))
=| worm0=worm
=+ [res1 worm1]=(~(slam wa worm0) !>(flop) [list-type ~[1 2 3]])
=+ [res2 worm2]=(~(slam wa worm1) !>(flop) [list-type ~[4 5 6]])
::
;: weld
%+ expect-eq
res1
[list-type ~[3 2 1]]
::
%+ expect-eq
res2
[list-type ~[6 5 4]]
::
%+ expect-eq
!> worm1
!> worm2
==
--