aboutsummaryrefslogtreecommitdiff
path: root/test/cases/bytecode.bqn
blob: 70c71b7e567d6f6bac52bf2361561900e5714802 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Tests of bytecode operations.
# These use no primitives, so that compiled code can be run directly in
# a correct VM even if it has no runtime.
# Compile with a command such as $ src/cjs.bqn "a←2⋄b←3⋄a"

# Tests are meant to be run in order; comments indicate new instructions
# introduced by each.

5  % 5                     #  0 PUSH, 25 RETN
3  % 43                   # 14 POPS
5  % a5                   # 22 LOCM, 11 SETN
4  % a5a4               # 12 SETU
2  % a2b3a             # 21 LOCO
1  % a1A 4               # 16 FN1O
2  % a23 A 4             # 17 FN2O
6  % {𝕩}6                  # 15 DFND
3  % A{𝕨}3 A 4           #    dyadic block function
7  % ab72a             #  3 ARRO,  4 ARRM
4  % 4{𝔽}6                 #  7 OP1D
6  % 4{𝔽𝕩}6               #    deferred modifier
1  % 3{𝔾}{𝕩} 1             #  8 OP2D
2  % (2{𝔽}{𝕩})3            #  9 TR2D
3  % 3({ab𝕩a}{𝕨𝕩})4    #    dyadic 2-train
4  % 4({𝕨𝕩}{𝕩}{𝕨})5       # 19 TR3O
2  % ab(2{𝕨𝕩}{𝕩})5a    #    monadic, data in left branch
2  % ({a2𝕩}{𝕩a}{a3𝕩})a4 # ordering
8  % a3a{𝕩}8a          # 13 SETM
4  % ab21ab{𝕩𝕨}4a  #    lists