ccm/tests/array.ccm

32 lines
797 B
Plaintext

# EQUALITY
assert_eq (true, [1, 2] == [1, 2])
assert_eq (true, [1, 2] <> [1, 3])
assert_eq (false, [1, 2] == [7, 2])
assert_eq (false, [1, 2] <> [1, 2])
# INDEX
assert_eq (1, [1, 2, 3][0])
assert_eq (2, [1, 2, 3][1])
assert_eq (3, [1, 2, 3][2])
assert_eq (1, [1, 2, 3][-3])
assert_eq (2, [1, 2, 3][-2])
assert_eq (3, [1, 2, 3][-1])
assert_eq (2, [1, [2, 3]][-1, 0])
assert_eq (4, [[1, 2], [3, 4]][-1, -1])
assert_eq ([3, 4], [[1, 2], [3, 4]][-1])
# ARITHMETIC
assert_eq ([1, 2, 3], [1, 2, 3])
assert_eq ([1, 2, 3], [1, 2] + [3])
assert_eq ([2, 2, 2], [2] * 3)
assert_eq ([2, 2, 2], 3 * [2])
assert_eq ([2, 6, 2, 6], 2*([2] + [6]))
# MEMBERSHIP
assert_eq (true, 2 in [1, 2, 3])
assert_eq (false, 4 in [1, 2, 3])
assert_eq (true, [2, 3] in [1, [2, 3]])
assert_eq (false, [2, 4] in [1, [2, 3]])