2018-08-28 00:51:42 +03:00
|
|
|
/+ tester
|
|
|
|
::
|
|
|
|
=, contain
|
|
|
|
::
|
|
|
|
|_ _tester:tester
|
|
|
|
++ test-basic-clock
|
|
|
|
::
|
|
|
|
=| c=(clock @u tape)
|
|
|
|
:: make max-size reasonable for testing
|
|
|
|
::
|
|
|
|
=. max-size.c 3
|
|
|
|
:: specialize type
|
|
|
|
::
|
|
|
|
=+ by-clock=(by-clock @u tape)
|
|
|
|
:: ensure we get a single key we put in
|
|
|
|
::
|
|
|
|
=. c (~(put by-clock c) 1 "one")
|
|
|
|
=^ maybe1 c (~(get by-clock c) 1)
|
|
|
|
=/ results1
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> [~ "one"]
|
|
|
|
!> maybe1
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
|
|
|
=/ results2
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> 1
|
|
|
|
!> size.c
|
2018-08-28 00:51:42 +03:00
|
|
|
:: push that key out of the cache
|
|
|
|
::
|
|
|
|
=. c (~(put by-clock c) 2 "two")
|
|
|
|
=. c (~(put by-clock c) 3 "three")
|
|
|
|
=. c (~(put by-clock c) 4 "four")
|
|
|
|
::
|
|
|
|
=/ results3
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> 3
|
|
|
|
!> size.c
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
|
|
|
=^ maybe2 c (~(get by-clock c) 1)
|
|
|
|
=/ results4
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> ~
|
|
|
|
!> maybe2
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
|
|
|
;: weld
|
|
|
|
results1
|
|
|
|
results2
|
|
|
|
results3
|
|
|
|
results4
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ test-clock-purge
|
|
|
|
::
|
|
|
|
=| c=(clock @u tape)
|
|
|
|
:: make max-size reasonable for testing
|
|
|
|
::
|
|
|
|
=. max-size.c 3
|
|
|
|
:: specialize type
|
|
|
|
::
|
|
|
|
=+ by-clock=(by-clock @u tape)
|
|
|
|
:: fill the clock
|
|
|
|
::
|
|
|
|
=. c (~(put by-clock c) 1 "one")
|
|
|
|
=. c (~(put by-clock c) 2 "two")
|
|
|
|
=. c (~(put by-clock c) 3 "three")
|
|
|
|
:: purge the entire clock
|
|
|
|
::
|
|
|
|
=. c ~(purge by-clock c)
|
|
|
|
::
|
|
|
|
;: weld
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> 0
|
|
|
|
!> size.c
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> 3
|
|
|
|
!> max-size.c
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> ~
|
|
|
|
!> lookup.c
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> ~
|
|
|
|
!> queue.c
|
2018-08-28 00:51:42 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ test-clock-trim
|
|
|
|
::
|
|
|
|
=| c=(clock @u tape)
|
|
|
|
:: make max-size reasonable for testing
|
|
|
|
::
|
|
|
|
=. max-size.c 3
|
|
|
|
:: specialize type
|
|
|
|
::
|
|
|
|
=+ by-clock=(by-clock @u tape)
|
|
|
|
:: fill the clock
|
|
|
|
::
|
|
|
|
=. c (~(put by-clock c) 1 "one")
|
|
|
|
=. c (~(put by-clock c) 2 "two")
|
|
|
|
=. c (~(put by-clock c) 3 "three")
|
|
|
|
:: trim 2/3 of the clock
|
|
|
|
::
|
|
|
|
=. c (~(trim by-clock c) 2)
|
|
|
|
::
|
|
|
|
;: weld
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> 1
|
|
|
|
!> size.c
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
|
|
|
=^ results1 c (~(get by-clock c) 3)
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> [~ "three"]
|
|
|
|
!> results1
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> 1
|
|
|
|
!> ~(wyt by lookup.c)
|
2018-08-28 00:51:42 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ test-clock-resized-to-zero
|
|
|
|
::
|
|
|
|
=| c=(clock @u tape)
|
|
|
|
:: make max-size reasonable for testing
|
|
|
|
::
|
|
|
|
=. max-size.c 3
|
|
|
|
:: specialize type
|
|
|
|
::
|
|
|
|
=+ by-clock=(by-clock @u tape)
|
|
|
|
:: fill the clock
|
|
|
|
::
|
|
|
|
=. c (~(put by-clock c) 1 "one")
|
|
|
|
=. c (~(put by-clock c) 2 "two")
|
|
|
|
=. c (~(put by-clock c) 3 "three")
|
|
|
|
:: resize the clock so it has zero elements
|
|
|
|
::
|
|
|
|
=. c (~(resize by-clock c) 0)
|
|
|
|
::
|
|
|
|
=/ results1
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> 0
|
|
|
|
!> size.c
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
|
|
|
=/ results2
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> ~
|
|
|
|
!> lookup.c
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
|
|
|
=/ results3
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> ~
|
|
|
|
!> queue.c
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
|
|
|
=/ results4
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> 0
|
|
|
|
!> max-size.c
|
2018-08-28 00:51:42 +03:00
|
|
|
:: trying to get an element just returns ~
|
|
|
|
::
|
|
|
|
=^ maybe1 c (~(get by-clock c) 3)
|
|
|
|
=/ results5
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> ~
|
|
|
|
!> maybe1
|
2018-08-28 00:51:42 +03:00
|
|
|
:: trying to put an element in doesn't mutate the clock
|
|
|
|
::
|
|
|
|
=. c (~(put by-clock c) 4 "four")
|
|
|
|
::
|
|
|
|
=/ results6
|
2018-08-29 02:16:37 +03:00
|
|
|
%+ expect-nu-eq
|
|
|
|
!> 0
|
|
|
|
!> size.c
|
2018-08-28 00:51:42 +03:00
|
|
|
::
|
|
|
|
;: weld
|
|
|
|
results1
|
|
|
|
results2
|
|
|
|
results3
|
|
|
|
results4
|
|
|
|
results5
|
|
|
|
results6
|
|
|
|
==
|
|
|
|
--
|