uCBQN/test/cases/syntax.bqn
2024-02-01 21:26:08 +02:00

81 lines
5.7 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 jiteq _jiteq {r (1𝔽){𝕊: 0•CurrentError@}¨ 4<𝕩 "TEST FAIL: all results weren't equal" ! 1=r {0e: !e; 1e: e}r}
# body usage
a"zero""one" !aa{𝕩?1𝕨;0𝕨}¨01
!"No header matched argument" % { 𝕊ab: a+b ; d𝕊abc: a+b+c} 3
!"No header matched argument" % {d𝕊ab: a+b ; 𝕊abc: a+b+c} 2
{𝕊ab: a+b ; 𝕊abc: a+b+c} 2 %% 1
{𝕊ab: a+b ; 𝕊abc: a+b+c} 3 %% 3
{4=𝕩? "four" ; "idk: "𝕩}4+3 %% "four"
{4=𝕩? "four" ; "idk: "𝕩}3+3 %% "idk: "3,4,5
{𝕩+1 4=𝕩? 1𝕩 ; 2𝕩}3+3 %% 1,456
{𝕩+1 4=𝕩? 1𝕩 ; 2𝕩}4+3 %% 2,456
{𝕩𝕩+1 4=𝕩? 1𝕩 ; 2𝕩}3+3 %% 1,456
{𝕩𝕩+1 4=𝕩? 1𝕩 ; 2𝕩}4+3 %% 2,456
{1?"abc" ; "def"} %% "abc"
{0?"abc" ; "def"} %% "def"
{123456 1{2} 1 1{1+5}} %% 16
# forks with funky tines
{(𝕩 "ab" 9) {fgh𝕨 TF G H T𝕩 (𝕩𝕩)T𝕩} 3}¨ 222 %% 222012,012,12012,012,012,12012,012,012,012,"ab",12012,012,012,"ab","ab","ab","ab","ab","ab",012,"ab",12012,012,012,"ab","ab","ab","ab","ab","ab","ab","ab"
# body inverses
!"No monadic undo header found for this block" % {𝕩} 1
!"No dyadic F⁼ undo header found for this block" % 1 {𝕩} 1
!"No dyadic F˜⁼ undo header found for this block" % 1 {𝕩}˜ 1
!"No monadic undo header found for this 1-modifier block" % +{𝔽𝕩} 1
!"No dyadic F⁼ undo header found for this 1-modifier block" % 1 +{𝔽𝕩} 1
!"No dyadic F˜⁼ undo header found for this 1-modifier block" % 1 +{𝔽𝕩}˜ 1
!"No monadic undo header found for this 2-modifier block" % +{𝔽𝔾𝕩}+ 1
!"No dyadic F⁼ undo header found for this 2-modifier block" % 1 +{𝔽𝔾𝕩}+ 1
!"No dyadic F˜⁼ undo header found for this 2-modifier block" % 1 +{𝔽𝔾𝕩}+˜ 1
# assignment
!"Attempting to read variable which is not yet defined" % {a} a1
!"Attempting to read variable which is not yet defined" % {a10} a2
!"Assignment: Attempting to modify variable which is not yet defined" % {a10} a2
!"Attempting to read variable which is not yet defined" % {a (10)˙} a2
!"Attempting to read variable which is not yet defined" % a1 {ab2} b2
!"Assignment: Attempting to modify variable which is not yet defined" % a1 {ab2} b2
!"Attempting to read variable which is not yet defined" % a1 {ab (10)˙} b2
!"Assignment: Mismatched shape for spread assignment" % ab1
!"Assignment: Mismatched shape for spread assignment" % ab123
!"Assignment: Mismatched shape for spread assignment" % a<1
!"Assignment: Mismatched shape for spread assignment" % 1
!"Assignment: Mismatched shape for spread assignment" % 1
%%
# mid-update variable behavior
%USE jiteq {𝕊: a"foo" {𝕊:a!@}•CurrentError @ 1} _jiteq @ %% 1
!"Attempting to read variable which isn't available due to incomplete or aborted F↩" % %USE jiteq {𝕊: a"foo" ! "foo" {𝕊:a!@}•CurrentError @ a 1} _jiteq @
!"Attempting to read variable which isn't available due to incomplete or aborted F↩" % %USE jiteq {𝕊: a"foo" a {𝕊: a} 1} _jiteq @
!"Attempting to read variable which isn't available due to incomplete or aborted F↩" % %USE jiteq {𝕊: a1 a {𝕊: a } 1} _jiteq @
# not-yet-defined variable usage
!"Attempting to read variable which is not yet defined" % %USE jiteq {𝕊: {a } a1} _jiteq @
!"Attempting to read variable which is not yet defined" % %USE jiteq {𝕊: {a 1} a1} _jiteq @
!"Attempting to read variable which is not yet defined" % %USE jiteq {𝕊: {a 1} a1} _jiteq @
!"Assignment: Attempting to modify variable which is not yet defined" % %USE jiteq {𝕊: {aa12 1} a1} _jiteq @
# namespaces
a,b•BQN"{x⇐1‿2⋄a⇐3‿4⋄y←5‿6⋄b⇐7‿8}" ab %% 34 78
!"Field named ""b"" not found" % {a1}.b
!"Field named ""y"" not found" % xyz {xz12}
# immediate modifiers
!"Field named ""b"" not found" % X12{a𝕗} bx
X12{a𝕗} ax +´a %% 3
X12{a𝕘-𝕗}34 ax +´a %% 4
a12{a𝕩+𝕗+𝕘}34 1 a %% 57
a12{a𝕩+𝕗} 1 a %% 23
# arguments
{x𝕩𝕩@𝕩x}-10 %% @-10
{𝕊: a"ab" (a"c")"d", a}¨ 4 %% 4<"ab","c""d", "ab","c"
{𝕊: a"ab" (a"c")"d", a}¨ 4 %% 4<"c""d", "c"
{𝕊: a"ab" (b"c")"d", a, b}¨ 4 %% 4<"c""d", "ab", "c"
{𝕊: a"ab" (a"c")"d", a}¨ 4 %% 4<"ab","c""d", "ab","c"
{𝕊: a"ab" (a"c")"d", a}¨ 4 %% 4<"c""d", "c"
{𝕊: a"ab" (b"c")"d", a, b}¨ 4 %% 4<"c""d", "ab", "c"