uCBQN/test/cases/hash.bqn
dzaima 5c2ac27410 modernize tests
also remove leftover tests that don't pass with EACH_FILLS
2025-05-30 01:52:31 +03:00

68 lines
4.8 KiB
BQN
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

%DEF eqvar _eqvar•args
# some checks for behavior around ¯0; not strictly necessary to stay, but other tests will probably become meaningless without these!
1641•bit._cast ˘ •ParseFloat¨ "1.2""-0" %% 631/01
! (40) ( (641•bit._cast)) 1¯1×π40
! ˝641•bit._cast ˘05(¯1×) (3)0÷0
# ¯0
! ´ {•Hash •ParseFloat¨ 𝕩"1.2"}¨ "0""-0"
! 10 {•ParseFloat¨ 𝕩"1.2"}¨ "0""-0"
a(•ParseFloat¨ "1.2""-0""0")-0÷0 1•Hash¨ a %% 11010
a(•ParseFloat¨ "1.2""-0""0")-0÷0 b0+--a ! a •internal.EEqual b ! a (3) b ! 0a •Cmp b ! a (1•Hash¨) b ! a (1•Hash) b
a(•ParseFloat¨ "1.2""-0""0")-0÷0 ! (0333a) •Hash (0444a)
# functions
, , +, +, +, , , +, 1+, 1+, 2+, 1+, 1×, +, , +, +˘, ע, +˘, +˝ %% , +, +, +, , +, 1+, 2+, 1+, 1×, +˘, ע, +˝
# various
[11, 01, 10, 00, 11, 00] [00, 01, 10] %% 011101
[[00, 01, 10, 11], [11, 01, 10, 00]] [00, 01, 10] %% 2411100111
[11, 01, 10, 00, 11, 00] (0) [00, 01, 10] %% 011101
[[00, 01, 10, 11], [11, 01, 10, 00]] (0) [00, 01, 10] %% 2411100111
˜˜"ihxtIddKLp"'r'÷"EXiRowcDXx"'a'"ZNtqFbDCYZ"0.053691254943265545 %% ˜10
01˜"ab","cd" %% 00
01 "ab","cd" %% 22
(<"ab")"ab""cd" %% <1
(<"cd")"ab""cd" %% <1
(<"ef")"ab""cd" %% <0
(127"abc")"abcd" %% 012127
(128"abc")"abcd" %% 012128
(32767"abc")"abcd" %% 01232767
(32768"abc")"abcd" %% 01232768
(127"abc")100"ababacadabacaba" %% (1000101020 1270102010)
(128"abc")100"ababacadabacaba" %% (1000101020 1280102010)
(32767"abc")100"ababacadabacaba" %% (1000101020327670102010)
(32768"abc")100"ababacadabacaba" %% (1000101020327680102010)
•internal.Variation(1)¨ "Ab""Ai8" %% 0
%USE eqvar 0•Hash _eqvar 5
%USE eqvar 0•Hash _eqvar "hello"
%USE eqvar 0•Hash _eqvar 10
{b•internal.Unshare a"Ai8"•internal.Variation 160000000¯128, 80, 82 c864•bit._cast a ! 1001c •internal.Keep •Hash c ! ab} # make sure sign bit doesn't mutate away
# error messages
!"𝕨∊𝕩: 𝕩 cannot have rank 0" % 1230
!"𝕨⊐𝕩: 𝕨 cannot have rank 0" % 0123
!"𝕨⊒𝕩: 𝕨 cannot have rank 0" % 0123
!"𝕨∊𝕩: Rank of 𝕨 must be at least the cell rank of 𝕩 (⟨2⟩ ≡ ≢𝕨, 2‿2‿2 ≡ ≢𝕩)" % 1222212
!"𝕨⊐𝕩: Rank of 𝕩 must be at least the cell rank of 𝕨 (2‿2‿2 ≡ ≢𝕨, ⟨2⟩ ≡ ≢𝕩)" % (22212)12
!"𝕨⊒𝕩: Rank of 𝕩 must be at least the cell rank of 𝕨 (2‿2‿2 ≡ ≢𝕨, ⟨2⟩ ≡ ≢𝕩)" % (22212)12
# hashmap
("abc""de""fgh" •HashMap ¨3).Get "fgh" %% 2
("abc""de""fgh" •HashMap ¨3).Get "fghi" %%
("abc""de""fgh" •HashMap ¨3).Count"xy" %% 3
("b" ("a""b" •HashMap "A""C").Set "B").Get "b" %% "B"
((•HashMap˜4).Set´ 1"one").Keys2 %% 4
(((•HashMap˜4).Delete 1).Set´ 1"one").Keys@ %% 0231
(((•HashMap˜4).Delete 1).Set´ 1"one").Values@ %% 023"one"
({𝕩.Set´"xy"}4•HashMap˜0).Count@ %% 1
!"𝕨 •HashMap 𝕩: Arguments must be lists (⟨⟩≡≢𝕨, ⟨3⟩≡≢𝕩)" % 'a' •HashMap "str"
!"𝕨 •HashMap 𝕩: 𝕨 and 𝕩 must have the same length (4≡≠𝕨, 3≡≠𝕩)" % "stri" •HashMap "str"
!"•HashMap: 𝕨 contained duplicate keys" % "strs" •HashMap "stri"
!"(hashmap).Get: key not found" % ("abc""de""fgh" •HashMap ¨3).Get "fg"
!"(hashmap).Delete: key not found" % ("abc""de""fgh" •HashMap ¨3).Delete 'a'
m 12 •HashMap v•internal.Unshare 'a'4 1 m.Set 9 v, m.Keys@, m.Values@ %% 'a'4, 12, 94
m 12 •HashMap •internal.Unshare 'a'4 vm.Values@ 1 m.Set 9 v, m.Keys@, m.Values@ %% 'a'4, 12, 94