-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtuple.lua
More file actions
67 lines (67 loc) · 3 KB
/
tuple.lua
File metadata and controls
67 lines (67 loc) · 3 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
local t = tuple(merge_kwargs({}, {}), list({}, {_to_null(1, 2, 3, nil)}))
assert(bool({}, (len(merge_kwargs({}, {}), t) == 4)))
assert(bool({}, (t[_to_null(0)] == 1)))
assert(bool({}, (t[_to_null(1)] == 2)))
assert(bool({}, (t[_to_null(2)] == 3)))
assert(bool({}, (t[_to_null(3)] == nil)))
t = tuple(merge_kwargs({}, {}), list({}, {_to_null(1, "a", "z", "pi", "a", "c", "c", nil)}))
assert(bool({}, (t.count(merge_kwargs({}, {}), 1) == 1)))
assert(bool({}, (t.count(merge_kwargs({}, {}), "a") == 2)))
assert(bool({}, (t.count(merge_kwargs({}, {}), "b") == 0)))
assert(bool({}, (t.count(merge_kwargs({}, {}), "c") == 2)))
assert(bool({}, (t.count(merge_kwargs({}, {}), nil) == 1)))
t = tuple(merge_kwargs({}, {}), list({}, {_to_null(1, "a", "z", "pi", "a", "c", "c")}))
assert(bool({}, (t.index(merge_kwargs({}, {}), "a") == 1)))
assert(bool({}, (t.index(merge_kwargs({}, {}), "a", 0) == 1)))
assert(bool({}, (t.index(merge_kwargs({}, {}), "a", 1) == 1)))
assert(bool({}, (t.index(merge_kwargs({}, {}), "a", 2) == 4)))
assert(bool({}, (t.index(merge_kwargs({}, {}), "a", 3) == 4)))
assert(bool({}, (t.index(merge_kwargs({}, {}), "a", 4) == 4)))
assert(bool({}, (t.index(merge_kwargs({}, {}), "a", 1, 4) == 1)))
assert(bool({}, (t.index(merge_kwargs({}, {}), "a", 2, 5) == 4)))
t = tuple(merge_kwargs({}, {}), list({}, {_to_null(4, 1, 2, 0, 3)}))
assert(bool({}, (operator_in(0, t))))
assert(bool({}, (not operator_in(5, t))))
local t1 = tuple(merge_kwargs({}, {}), list({}, {_to_null(4, 1, 2, 0, 3)}))
local t2 = tuple(merge_kwargs({}, {}), list({}, {_to_null(4, 1, 2, 0, 3)}))
t = (t1 + t2)
assert(bool({}, (len(merge_kwargs({}, {}), t) == 10)))
assert(bool({}, (t[_to_null(0)] == 4)))
assert(bool({}, (t[_to_null(1)] == 1)))
assert(bool({}, (t[_to_null(2)] == 2)))
assert(bool({}, (t[_to_null(3)] == 0)))
assert(bool({}, (t[_to_null(4)] == 3)))
assert(bool({}, (t[_to_null(5)] == 4)))
assert(bool({}, (t[_to_null(6)] == 1)))
assert(bool({}, (t[_to_null(7)] == 2)))
assert(bool({}, (t[_to_null(8)] == 0)))
assert(bool({}, (t[_to_null(9)] == 3)))
t1 = tuple(merge_kwargs({}, {}), list({}, {_to_null(4, 1, 2, 0, 3)}))
t = (t1 * 2)
assert(bool({}, (len(merge_kwargs({}, {}), t) == 10)))
assert(bool({}, (t[_to_null(0)] == 4)))
assert(bool({}, (t[_to_null(1)] == 1)))
assert(bool({}, (t[_to_null(2)] == 2)))
assert(bool({}, (t[_to_null(3)] == 0)))
assert(bool({}, (t[_to_null(4)] == 3)))
assert(bool({}, (t[_to_null(5)] == 4)))
assert(bool({}, (t[_to_null(6)] == 1)))
assert(bool({}, (t[_to_null(7)] == 2)))
assert(bool({}, (t[_to_null(8)] == 0)))
assert(bool({}, (t[_to_null(9)] == 3)))
t = tuple(merge_kwargs({}, {}), list({}, {_to_null(4, 1, 2, 0, 3)}))
assert(bool({}, (t[_to_null(0)] == 4)))
local ts = t[slice({}, 1, 2, nil)]
assert(bool({}, (len(merge_kwargs({}, {}), ts) == 1)))
assert(bool({}, (ts[_to_null(0)] == 1)))
local ts2 = t[slice({}, 1, 5, 2)]
assert(bool({}, (len(merge_kwargs({}, {}), ts2) == 2)))
assert(bool({}, (ts2[_to_null(0)] == 1)))
assert(bool({}, (ts2[_to_null(1)] == 0)))
return {
t = t,
t1 = t1,
t2 = t2,
ts = ts,
ts2 = ts2,
}