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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
desc: Tests conversion to and from the RQL array type
tests:
- cd:
- r.expr([])
- r([])
py: r.expr([])
ot: []
- py: r.expr([1])
js: r([1])
rb: r([1])
ot: [1]
- py: r.expr([1,2,3,4,5])
js: r([1,2,3,4,5])
rb: r.expr([1,2,3,4,5])
ot: [1,2,3,4,5]
- cd: r.expr([]).type_of()
ot: 'ARRAY'
# test coercions
- cd:
- r.expr([1, 2]).coerce_to('string')
- r.expr([1, 2]).coerce_to('STRING')
ot: '[1,2]'
- cd: r.expr([1, 2]).coerce_to('array')
ot: [1, 2]
- cd: r.expr([1, 2]).coerce_to('number')
ot: err('ReqlQueryLogicError', 'Cannot coerce ARRAY to NUMBER.', [0])
- cd: r.expr([['a', 1], ['b', 2]]).coerce_to('object')
ot: {'a':1,'b':2}
- cd: r.expr([[]]).coerce_to('object')
ot: err('ReqlQueryLogicError', 'Expected array of size 2, but got size 0.')
- cd: r.expr([['1',2,3]]).coerce_to('object')
ot: err('ReqlQueryLogicError', 'Expected array of size 2, but got size 3.')
# Nested expression
- cd: r.expr([r.expr(1)])
ot: [1]
- cd: r.expr([1,3,4]).insert_at(1, 2)
ot: [1,2,3,4]
- cd: r.expr([2,3]).insert_at(0, 1)
ot: [1,2,3]
- cd: r.expr([1,2,3]).insert_at(-1, 4)
ot: [1,2,3,4]
- cd: r.expr([1,2,3]).insert_at(3, 4)
ot: [1,2,3,4]
- py: r.expr(3).do(lambda x: r.expr([1,2,3]).insert_at(x, 4))
- js: r.expr(3).do(function (x) { return r.expr([1,2,3]).insert_at(x, 4); })
- rb: r.expr(3).do{|x| r.expr([1,2,3]).insert_at(x, 4)}
ot: [1,2,3,4]
- cd: r.expr([1,2,3]).insert_at(4, 5)
ot: err('ReqlNonExistenceError', 'Index `4` out of bounds for array of size: `3`.', [0])
- cd: r.expr([1,2,3]).insert_at(-5, -1)
ot: err('ReqlNonExistenceError', 'Index out of bounds: -5', [0])
- cd: r.expr([1,2,3]).insert_at(1.5, 1)
ot: err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0])
- cd: r.expr([1,2,3]).insert_at(null, 1)
ot: err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0])
- cd: r.expr([1,4]).splice_at(1, [2,3])
ot: [1,2,3,4]
- cd: r.expr([3,4]).splice_at(0, [1,2])
ot: [1,2,3,4]
- cd: r.expr([1,2]).splice_at(2, [3,4])
ot: [1,2,3,4]
- cd: r.expr([1,2]).splice_at(-1, [3,4])
ot: [1,2,3,4]
- py: r.expr(2).do(lambda x: r.expr([1,2]).splice_at(x, [3,4]))
- js: r.expr(2).do(function (x) { return r.expr([1,2]).splice_at(x, [3,4]); })
- rb: r.expr(2).do{|x| r.expr([1,2]).splice_at(x, [3,4])}
ot: [1,2,3,4]
- cd: r.expr([1,2]).splice_at(3, [3,4])
ot: err('ReqlNonExistenceError', 'Index `3` out of bounds for array of size: `2`.', [0])
- cd: r.expr([1,2]).splice_at(-4, [3,4])
ot: err('ReqlNonExistenceError', 'Index out of bounds: -4', [0])
- cd: r.expr([1,2,3]).splice_at(1.5, [1])
ot: err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0])
- cd: r.expr([1,2,3]).splice_at(null, [1])
ot: err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0])
- cd: r.expr([1,4]).splice_at(1, 2)
ot: err('ReqlQueryLogicError', 'Expected type ARRAY but found NUMBER.', [0])
- cd: r.expr([1,2,3,4]).delete_at(0)
ot: [2,3,4]
- py: r.expr(0).do(lambda x: r.expr([1,2,3,4]).delete_at(x))
- js: r.expr(0).do(function (x) { return r.expr([1,2,3,4]).delete_at(x); })
- rb: r.expr(0).do{|x| r.expr([1,2,3,4]).delete_at(x)}
ot: [2,3,4]
- cd: r.expr([1,2,3,4]).delete_at(-1)
ot: [1,2,3]
- cd: r.expr([1,2,3,4]).delete_at(1,3)
ot: [1,4]
- cd: r.expr([1,2,3,4]).delete_at(4,4)
ot: [1,2,3,4]
- cd: r.expr([]).delete_at(0,0)
ot: []
- cd: r.expr([1,2,3,4]).delete_at(1,-1)
ot: [1,4]
- cd: r.expr([1,2,3,4]).delete_at(4)
ot: err('ReqlNonExistenceError', 'Index `4` out of bounds for array of size: `4`.', [0])
- cd: r.expr([1,2,3,4]).delete_at(-5)
ot: err('ReqlNonExistenceError', 'Index out of bounds: -5', [0])
- cd: r.expr([1,2,3]).delete_at(1.5)
ot: err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0])
- cd: r.expr([1,2,3]).delete_at(null)
ot: err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0])
- cd: r.expr([0,2,3]).change_at(0, 1)
ot: [1,2,3]
- py: r.expr(1).do(lambda x: r.expr([0,2,3]).change_at(0,x))
- js: r.expr(1).do(function (x) { return r.expr([0,2,3]).change_at(0,x); })
- rb: r.expr(1).do{|x| r.expr([0,2,3]).change_at(0,x)}
ot: [1,2,3]
- cd: r.expr([1,0,3]).change_at(1, 2)
ot: [1,2,3]
- cd: r.expr([1,2,0]).change_at(2, 3)
ot: [1,2,3]
- cd: r.expr([1,2,3]).change_at(3, 4)
ot: err('ReqlNonExistenceError', 'Index `3` out of bounds for array of size: `3`.', [0])
- cd: r.expr([1,2,3,4]).change_at(-5, 1)
ot: err('ReqlNonExistenceError', 'Index out of bounds: -5', [0])
- cd: r.expr([1,2,3]).change_at(1.5, 1)
ot: err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0])
- cd: r.expr([1,2,3]).change_at(null, 1)
ot: err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0])
|