Open Q Language

Conformance test suite

15,829 single-line assertions, each of which must evaluate to 1b. Run them against any q binary to see what it implements.

Download the suite · 142 KB 54 files — corpus, drivers, harness and the spec chapters

unzip oqspec-conformance-suite.zip && cd oqspec
uv run oqspec run --q "/path/to/your-q"     # every assertion must report 1b
uv run oqspec coverage                      # which spec rules have tests

How a test is written

Each line is self-contained: the expression and its expected value together. Errors assert the class only, never the message wording, because wording is not a property of the language.

(1+2)~3
(0W+0W)~-2                                  / integer infinity wraps on overflow
(@[value;"1 2+1 2 3";{x}]) like "length*"   / asserts the class, not the message

Assertions compare values, not rendered text, so an implementation is never required to print a value the way the reference prints it in order to be judged correct about it. Rendering has its own category, 22_display.

Categories

CategoryAssertionsRules coveredSource
01_atoms_types 95 CORE-0017 CORE-0018 CORE-0019 CORE-0026 01_atoms_types.q
02_casts 84 CORE-0017 CORE-0027 02_casts.q
03_operators 83 CORE-0027 CORE-0026 03_operators.q
04_lists_indexing 110 CORE-0020 CORE-0030 CORE-0032 04_lists_indexing.q
05_adverbs 45 CORE-0013 CORE-0028 05_adverbs.q
06_dicts 48 CORE-0021 06_dicts.q
07_tables_qsql 81 CORE-0022 QSQL-0001 QSQL-0002 QSQL-0003 QSQL-0005 QSQL-0007 07_tables_qsql.q
08_joins 28 QSQL-0016 08_joins.q
09_temporal 64 CORE-0009 09_temporal.q
10_text 61 CORE-0010 CORE-0011 10_text.q
11_functions 49 CORE-0025 CORE-0033 CORE-0037 11_functions.q
12_builtins 68 CORE-0029 12_builtins.q
13_errors 32 CORE-0036 13_errors.q
14_parse_forms 37 Q-0003 Q-0004 Q-0005 14_parse_forms.q
15_serialization 42 IPC-0005 IPC-0006 IPC-0007 IPC-0008 IPC-0009 IPC-0010 IPC-0011 IPC-0012 IPC-0014 15_serialization.q
16_json 39 RT-0006 16_json.q
17_control 39 CORE-0038 CORE-0039 17_control.q
18_qsql_advanced 38 QSQL-0010 QSQL-0011 QSQL-0012 QSQL-0013 QSQL-0014 QSQL-0015 18_qsql_advanced.q
19_math 48 CORE-0029 19_math.q
20_format 41 CORE-0010 CORE-0029 20_format.q
21_linalg 93 CORE-0024 CORE-0027 21_linalg.q
22_display 34 CORE-0043 22_display.q
90_enumerated 14,470 CORE-0027 CORE-0028 90_enumerated.q
k01_glyphs 68 CORE-0002 CORE-0041 k01_glyphs.k
k02_adverbs 32 CORE-0002 CORE-0028 k02_adverbs.k

Script tests

Whole programs rather than expressions: file I/O in a sandbox, IPC loopback with the binary under test acting as both server and client, and system commands. Their entire output is compared.

ScriptRules coveredSource
fileio_flat STOR-0001 fileio_flat.q
fileio_splayed STOR-0002 STOR-0006 STOR-0007 STOR-0008 STOR-0009 fileio_splayed.q
ipc_client IPC-0001 IPC-0003 IPC-0004 ipc_client.q
ipc_server ipc_server.q
system_cmds CORE-0015 Q-0016 system_cmds.q

The tests

01_atoms_types95 assertions

1b
(0b)~0b
(0x00)~0x00
(0xff)~0xff
(5h)~5h
(0Nh)~0Nh
(0Wh)~0Wh
(-0Wh)~-0Wh
(5i)~5i
(0Ni)~0Ni

02_casts84 assertions

(`long$1b)~1
(`long$0x2a)~42
(`long$5h)~5
(`long$5i)~5
(`long$5e)~5
(`long$5.7)~6
(`long$-5.7)~-6
(`long$"5")~53
(`long$0N)~0N
(`int$5)~5i

03_operators83 assertions

(1+2)~3
(1 2 3+10)~11 12 13
(1 2 3+10 20 30)~11 22 33
(1+0N)~0N
(1+0W)~0N
(0W+1)~0N
(0N+0N)~0N
(0W+0W)~-2
(-0W+-1)~0N
(1f+0n)~0n

04_lists_indexing110 assertions

(til 5)~0 1 2 3 4
(til 0)~`long$()
(1 2 3)~1 2 3
((1;2;3))~1 2 3
((1;`a;2.5))~(1;`a;2.5)
(())~()
(enlist 5)~enlist 5
(enlist `a)~enlist `a
(enlist 1 2 3)~enlist 1 2 3
(count 1 2 3)~3

05_adverbs45 assertions

({x*x} each 1 2 3)~1 4 9
(neg each 1 2 3)~-1 -2 -3
(count each (1 2;3 4 5;()))~2 3 0
({x+y} over 1 2 3 4)~10
({x+y} scan 1 2 3 4)~1 3 6 10
(@[value;"0 {x+y} over 1 2 3";{x}]) like "type*"
(@[value;"100 {x+y} scan 1 2 3";{x}]) like "Cannot*"
((+) over 1 2 3)~6
((+) scan 1 2 3)~1 3 6
((*) over 1 2 3 4)~24

06_dicts48 assertions

(`a`b`c!1 2 3)~(`a`b`c)!1 2 3
(`a`b!1 2)~(`a`b)!1 2
(()!())~(())!()
((enlist `a)!enlist 1)~(enlist `a)!enlist 1
(1 2!`x`y)~(1 2)!`x`y
((`a`b!1 2)`a)~1
((`a`b!1 2)`c)~0N
((`a`b!1 2)`a`b`a)~1 2 1
(key `a`b!1 2)~`a`b
(value `a`b!1 2)~1 2

07_tables_qsql81 assertions

(([] a:1 2 3; b:`x`y`z))~([]a:1 2 3;b:`x`y`z)
(([] a:enlist 1; b:enlist `x))~([]a:enlist 1;b:enlist `x)
(([k:`a`b] v:1 2))~([k:`a`b]v:1 2)
(flip `a`b!(1 2 3;`x`y`z))~([]a:1 2 3;b:`x`y`z)
(cols t)~`sym`price`size
(count t)~6
(meta t)~([c:`sym`price`size]t:"sfj";f:```;a:```)
(type t)~98h
(type kt)~99h
(keys t)~`symbol$()

08_joins28 assertions

(t lj `sym xkey s)~([]sym:`a`b`a`c`b`a;price:10.5 20.25 11 30 19.5 12.75;size:100 200 150 300 250 175;region:`east`west`east`east`west`east)
(select sym,region from t lj `sym xkey s)~([]sym:`a`b`a`c`b`a;region:`east`west`east`east`west`east)
(t ij `sym xkey s)~([]sym:`a`b`a`c`b`a;price:10.5 20.25 11 30 19.5 12.75;size:100 200 150 300 250 175;region:`east`west`east`east`west`east)
(count t ij `sym xkey s)~6
(ej[`sym;t;s])~([]sym:`a`b`a`c`b`a;price:10.5 20.25 11 30 19.5 12.75;size:100 200 150 300 250 175;region:`east`west`east`east`west`east)
(count ej[`sym;t;s])~6
(t uj s)~([]sym:`a`b`a`c`b`a`a`b`c`d;price:10.5 20.25 11 30 19.5 12.75 0n 0n 0n 0n;size:100 200 150 300 250 175 0N 0N 0N 0N;region:```````east`west`east`west)
(count t uj s)~10
(cols t uj s)~`sym`price`size`region
(@[value;"([] a:1 2; b:`x`y) uj ([] b:`z; c:10)";{x}]) like "rank*"

09_temporal64 assertions

(2020.01.02+1)~2020.01.03
(2020.01.02-1)~2020.01.01
(2020.01.02-2019.12.31)~2i
(2020.01m+1)~2020.02m
(2020.03m-2020.01m)~2i
(12:34+1)~12:35
(12:34:56+4)~12:35:00
(12:34:56.789+211)~12:34:57.000
(2020.01.02D03:04:05+1)~2020.01.02D03:04:05.000000001
(2020.01.02D00:00:00+0D01:00:00)~2020.01.02D01:00:00.000000000

10_text61 assertions

("abc","def")~"abcdef"
"abc"~"abc"
("abc"="abc")~111b
("abc"<"abd")~001b
(upper "aBc")~"ABC"
(lower "AbC")~"abc"
(upper `abc)~`ABC
(trim "  ab  ")~"ab"
(ltrim "  ab")~"ab"
(rtrim "ab  ")~"ab"

11_functions49 assertions

({x+y}[2;3])~5
({x*x} 5)~25
({x+y+z}[1;2;3])~6
({[a;b] a-b}[10;4])~6
({x+y}[2])~({x+y}[2])
({x+y}[2] 3)~5
({x+y}[;3] 2)~5
((+)[2;3])~5
((+)[2] 3)~5
(+[2;3])~5

12_builtins68 assertions

(sum 1 2 3)~6
(sum ())~()
(sum 1 0N 3)~4
(sum 1.5 0n 2.5)~4f
(sum 101b)~2i
(prd 1 2 3 4)~24
(prd ())~()
(avg 1 2 3)~2f
(avg 1 0N 3)~2f
(avg ())~0n

13_errors32 assertions

(@[value;"1 2+1 2 3";{x}]) like "length*"
(@[value;"1 2,'1 2 3";{x}]) like "length*"
(@[value;"`a+1";{x}]) like "type*"
(@[value;"\"a\"+`b";{x}]) like "type*"
(@[value;"{x+y}[1;2;3]";{x}]) like "rank*"
(@[value;"(+)[1;2;3]";{x}]) like "rank*"
(@[value;"{x}[1;2]";{x}]) like "rank*"
(@[value;"til -1";{x}]) like "domain*"
(@[value;"asc {x}";{x}]) like "type*"
(@[value;"undefined_name_xyz";{x}]) like "undefined_name_xyz*"

14_parse_forms37 assertions

(parse "1+2")~((+);1;2)
(parse "neg 3")~((-:);3)
(parse "a:5")~((:);`a;5)
(parse "{x*x}")~({x*x})
(parse "f[1;2]")~(`f;1;2)
(parse "1 2 3")~1 2 3
(parse "(1;2;3)")~((enlist);1;2;3)
(parse "`a`b!1 2")~((!);enlist `a`b;1 2)
(parse "select a from t")~((?);`t;();0b;(enlist `a)!enlist `a)
(parse "select sum a by b from t where c>0")~((?);`t;enlist enlist ((>);`c;0);(enlist `b)!enlist `b;(enlist `a)!enlist ((sum);`a))

15_serialization42 assertions

(-8!0b)~0x010000000a000000ff00
(-8!1b)~0x010000000a000000ff01
(-8!42)~0x0100000011000000f92a00000000000000
(-8!5i)~0x010000000d000000fa05000000
(-8!5h)~0x010000000b000000fb0500
(-8!2.5)~0x0100000011000000f70000000000000440
(-8!5e)~0x010000000d000000f80000a040
(-8!"a")~0x010000000a000000f661
(-8!`abc)~0x010000000d000000f561626300
(-8!`)~0x010000000a000000f500

16_json39 assertions

(.j.j 1 2 3)~"[1,2,3]"
(.j.j 1.5 2.5)~"[1.5,2.5]"
(.j.j `a`b`c)~"[\"a\",\"b\",\"c\"]"
(.j.j "hello")~"\"hello\""
(.j.j 1b)~"true"
(.j.j 01b)~"[false,true]"
(.j.j `a`b!1 2)~"{\"a\":1,\"b\":2}"
(.j.j `a`b!(1 2;3 4))~"{\"a\":[1,2],\"b\":[3,4]}"
(.j.j ([] a:1 2 3; b:`x`y`z))~"[{\"a\":1,\"b\":\"x\"},{\"a\":2,\"b\":\"y\"},{\"a\":3,\"b\":\"z\"}]"
(.j.j ([] a:1 2; b:("hi";"yo")))~"[{\"a\":1,\"b\":\"hi\"},{\"a\":2,\"b\":\"yo\"}]"

17_control39 assertions

($[1b;`yes;`no])~`yes
($[0b;`yes;`no])~`no
($[0;10;20])~20
($[1;10;20])~10
($[1b;10;0b;20;30])~10
($[0b;10;0b;20;30])~30
(@[value;"$[();`empty;`full]";{x}]) like "type*"
(?[101b;`a`b`c;`x`y`z])~`a`y`c
(@[value;"?[1 0 1b;1 2 3;10 20 30]";{x}]) like "type*"
(?[10101b;til 5;5+til 5])~0 6 2 8 4

18_qsql_advanced38 assertions

(select from t where price=(max;price) fby sym)~([]sym:`b`c`a;price:20.25 30 12.75;size:200 300 175)
(select from t where price>(avg;price) fby sym)~([]sym:`b`a;price:20.25 12.75;size:200 175)
(select from t where size=(min;size) fby sym)~([]sym:`a`b`c;price:10.5 20.25 30;size:100 200 300)
(update mx:(max;price) fby sym from t)~([]sym:`a`b`a`c`b`a;price:10.5 20.25 11 30 19.5 12.75;size:100 200 150 300 250 175;mx:12.75 20.25 12.75 30 20.25 12.75)
(select sym, mx:(max;price) fby sym from t)~([]sym:`a`b`a`c`b`a;mx:12.75 20.25 12.75 30 20.25 12.75)
(select first price, last price by sym from t)~([sym:`s#`a`b`c]price:10.5 20.25 30;price1:12.75 19.5 30)
(select count i, sum size by sym from t)~([sym:`s#`a`b`c]x:3 2 1;size:425 450 300)
(select avg price, max size by sym from t)~([sym:`s#`a`b`c]price:11.416666666666666 19.875 30;size:175 250 300)
(select price, running:sums price by sym from t)~([sym:`s#`a`b`c]price:(10.5 11 12.75;20.25 19.5;enlist 30f);running:(10.5 21.5 34.25;20.25 39.75;enlist 30f))
(0!select sum price by sym from t)~([]sym:`s#`a`b`c;price:34.25 39.75 30)

19_math48 assertions

(2 msum 1 2 3 4 5)~1 3 5 7 9
(3 msum 1 2 3 4 5)~1 3 6 9 12
(2 mavg 1 2 3 4)~1 1.5 2.5 3.5
(3 mavg 1.0 2 3 4 5)~1 1.5 2 3 4
(2 mmax 1 4 2 5 3)~1 4 4 5 5
(2 mmin 5 2 4 1 3)~5 2 2 1 1
(2 mcount 1 0N 3 0N 5)~1 1 1 1 1i
(3 mdev 1 2 3 4 5)~0 0.5 0.81649658092772626 0.8164965809277257 0.81649658092772681
(bin[1 3 5 7 9;4])~1
(bin[1 3 5 7 9;5])~2

20_format41 assertions

(.Q.f[2;3.14159])~"3.14"
(.Q.f[0;3.14159])~"3."
(.Q.f[4;3.14159])~"3.1416"
(.Q.f[2;3.145])~"3.15"
(.Q.f[2;3.155])~"3.16"
(.Q.f[2;-2.5])~"-2.50"
(.Q.f[3;1000.0])~"1000.000"
(.Q.f[2;0.005])~"0.01"
(@[value;".Q.f[2;1 2 3f]";{x}]) like "type*"
(.Q.fmt[10;2;3.14159])~"      3.14"

21_linalg93 assertions

(mmu[(1 2f;3 4f);(5 6f;7 8f)])~(19 22f;43 50f)
(mmu[(0 1f;1 0f);(5 6f;7 8f)])~(7 8f;5 6f)
(mmu[(1 0f;0 1f);(5 6f;7 8f)])~(5 6f;7 8f)
(mmu[(1 2 3f;4 5 6f;7 8 9f);(1 0 0f;0 1 0f;0 0 1f)])~(1 2 3f;4 5 6f;7 8 9f)
(mmu[(1 2 3f;4 5 6f);(1 0f;0 1f;1 1f)])~(4 5f;10 11f)
(mmu[(1 0f;0 1f;1 1f);(1 2 3f;4 5 6f)])~(1 2 3f;4 5 6f;5 7 9f)
(mmu[enlist 1 2 3f;(1f;2f;3f)])~enlist 14f
(@[value;"mmu[(1f;2f;3f);enlist 1 2 3f]";{x}]) like "length*"
(mmu[(1 2f;3 4f);(0 0f;0 0f)])~(0 0f;0 0f)
(mmu[(2 0 0 0f;0 2 0 0f;0 0 2 0f;0 0 0 2f);(1 2 3 4f;5 6 7 8f;9 10 11 12f;13 14 15 16f)])~(2 4 6 8f;10 12 14 16f;18 20 22 24f;26 28 30 32f)

22_display34 assertions

(-3!enlist 1)~",1"
(-3!enlist `a)~",`a"
(-3!enlist "x")~",\"x\""
(-3!1 2 3)~"1 2 3"
(-3!())~"()"
(-3!(1;`a;"x"))~"(1;`a;\"x\")"
(-3!`a`b!1 2)~"`a`b!1 2"
(-3!flip `a`b!(1 2;3 4))~"+`a`b!(1 2;3 4)"
(-3!([] a:1 2; b:`x`y))~"+`a`b!(1 2;`x`y)"
(-3!([k:`a`b] v:1 2))~"(+(,`k)!,`a`b)!+(,`v)!,1 2"

90_enumerated14,470 assertions

(neg (1b))~-1i
(neg (0b))~0i
(neg (0x05))~-5i
(neg (5h))~-5h
(neg (0Nh))~0Nh
(neg (5i))~-5i
(neg (0Ni))~0Ni
(neg (5))~-5
(neg (-5))~5
(neg (0N))~0N

k01_glyphs68 assertions

(#:1 2 3)~3
(#:"abc")~3
(#:())~0
(^:1 2 0N)~001b
(^:`a``b)~010b
(|:1 2 3)~3 2 1
(|:"abc")~"cba"
(&:1 0 1 1)~0 2 3
(&:101b)~0 2
(4#@[.:;"k)&3";{x}])~"type"

k02_adverbs32 assertions

(+/1 2 3)~6
(*/1 2 3 4)~24
(|/3 1 4 1 5)~5
(&/3 1 4 1 5)~1
(+\1 2 3)~1 3 6
(*\1 2 3)~1 2 6
(,/(1 2;3 4;5 6))~1 2 3 4 5 6
(,//(1 2;(3 4;(5;6))))~1 2 3 4 5 6
({x+y}/1 2 3 4)~10
({x+y}\1 2 3 4)~1 3 6 10