cast 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/CHANGELOG +50 -0
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.markdown +1948 -0
- data/Rakefile +22 -0
- data/cast.gemspec +20 -0
- data/ext/cast.c +6 -0
- data/ext/extconf.rb +1 -1
- data/ext/parser.c +2 -2
- data/ext/yylex.c +2592 -4171
- data/ext/yylex.re +20 -26
- data/lib/cast.rb +11 -16
- data/lib/cast/c.tab.rb +2252 -2231
- data/lib/cast/c.y +185 -161
- data/lib/cast/c_nodes.rb +181 -391
- data/lib/cast/inspect.rb +8 -10
- data/lib/cast/node.rb +362 -365
- data/lib/cast/node_list.rb +156 -165
- data/lib/cast/parse.rb +86 -65
- data/lib/cast/preprocessor.rb +72 -0
- data/lib/cast/tempfile.rb +33 -0
- data/lib/cast/to_s.rb +83 -75
- data/lib/cast/version.rb +11 -0
- data/test/all.rb +5 -0
- data/test/{test_c_nodes.rb → c_nodes_test.rb} +91 -23
- data/test/lexer_test.rb +323 -0
- data/test/{test_node_list.rb → node_list_test.rb} +367 -396
- data/test/{test_node.rb → node_test.rb} +142 -160
- data/test/{test_parse.rb → parse_test.rb} +63 -17
- data/test/{test_parser.rb → parser_test.rb} +62 -22
- data/test/preprocessor_test.rb +87 -0
- data/test/render_test.rb +2086 -0
- data/test/{run.rb → test_helper.rb} +76 -88
- metadata +100 -54
- data/README +0 -6
- data/doc/index.html +0 -2505
- data/ext/cast_ext.c +0 -10
@@ -1,50 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
######################################################################
|
2
|
+
#
|
3
|
+
# Tests for NodeList classes.
|
4
|
+
#
|
5
|
+
######################################################################
|
6
|
+
|
7
|
+
require 'test/test_helper'
|
8
|
+
|
9
|
+
#
|
10
|
+
# NodeListTest classes are abstract, inherited by classes which define
|
11
|
+
# List() to return a NodeList class. The tests defined in
|
12
|
+
# NodeListTest subclasses are therefore used to test all NodeList
|
13
|
+
# classes.
|
14
|
+
#
|
15
15
|
module NodeListTest
|
16
16
|
@@submodules = []
|
17
17
|
def self.submodules
|
18
18
|
@@submodules
|
19
19
|
end
|
20
|
-
def self.included
|
20
|
+
def self.included(m)
|
21
21
|
@@submodules << m
|
22
22
|
end
|
23
23
|
def setup
|
24
|
-
|
24
|
+
# []
|
25
25
|
@empty = _List[]
|
26
26
|
|
27
|
-
|
27
|
+
# [a]
|
28
28
|
a = C::Int.new
|
29
29
|
@one = _List[a]
|
30
30
|
@one_els = [a]
|
31
31
|
|
32
|
-
|
32
|
+
# [a, b]
|
33
33
|
a, b = 2.of{C::Int.new}
|
34
34
|
@two = _List[a, b]
|
35
35
|
@two_els = [a, b]
|
36
36
|
|
37
|
-
|
37
|
+
# [a, b, c]
|
38
38
|
a, b, c = 3.of{C::Int.new}
|
39
39
|
@three = _List[a, b, c]
|
40
40
|
@three_els = [a, b, c]
|
41
41
|
|
42
|
-
|
42
|
+
# [a, b, c, d]
|
43
43
|
a, b, c, d = 4.of{C::Int.new}
|
44
44
|
@four = _List[a, b, c, d]
|
45
45
|
@four_els = [a, b, c, d]
|
46
46
|
|
47
|
-
|
47
|
+
# [[a,b], [c,d], [e,f], [g,h]]
|
48
48
|
a, b, c, d, e, f, g, h = 8.of{C::Int.new}
|
49
49
|
l0 = _List[a,b]
|
50
50
|
l1 = _List[c,d]
|
@@ -53,7 +53,7 @@ module NodeListTest
|
|
53
53
|
@two_by_four = _List[l0, l1, l2, l3]
|
54
54
|
@two_by_four_els = [l0, l1, l2, l3, a, b, c, d, e, f, g, h]
|
55
55
|
|
56
|
-
|
56
|
+
# [a, [b,c], [d, [e], [], [[]]]]
|
57
57
|
a, b, c, d, e = 5.of{C::Int.new}
|
58
58
|
l1 = _List[b,c]
|
59
59
|
l21 = _List[e]
|
@@ -96,82 +96,82 @@ module NodeListInitializeTest
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
#
|
100
|
+
# Tests dup, clone.
|
101
|
+
#
|
102
102
|
module NodeListCopyTest
|
103
103
|
include NodeListTest
|
104
104
|
def test_copy
|
105
|
-
|
105
|
+
# empty
|
106
106
|
a = empty
|
107
107
|
b = empty.dup
|
108
108
|
c = empty.clone
|
109
|
-
|
109
|
+
#
|
110
110
|
assert_copy a, b
|
111
|
-
|
111
|
+
#
|
112
112
|
assert_copy a, c
|
113
113
|
|
114
|
-
|
114
|
+
# one
|
115
115
|
a = one
|
116
116
|
b = one.dup
|
117
117
|
c = one.clone
|
118
|
-
|
118
|
+
#
|
119
119
|
assert_copy a, b
|
120
120
|
assert_copy a[0], b[0]
|
121
|
-
|
121
|
+
#
|
122
122
|
assert_copy a, c
|
123
123
|
assert_copy a[0], c[0]
|
124
124
|
|
125
|
-
|
125
|
+
# two
|
126
126
|
a = two
|
127
127
|
b = two.dup
|
128
128
|
c = two.clone
|
129
|
-
|
129
|
+
#
|
130
130
|
assert_copy a, b
|
131
131
|
assert_copy a[0], b[0]
|
132
132
|
assert_copy a[1], b[1]
|
133
|
-
|
133
|
+
#
|
134
134
|
assert_copy a, c
|
135
135
|
assert_copy a[0], c[0]
|
136
136
|
assert_copy a[1], c[1]
|
137
137
|
|
138
|
-
|
138
|
+
# three
|
139
139
|
a = three
|
140
140
|
b = three.dup
|
141
141
|
c = three.clone
|
142
|
-
|
142
|
+
#
|
143
143
|
assert_copy a, b
|
144
144
|
assert_copy a[0], b[0]
|
145
145
|
assert_copy a[1], b[1]
|
146
146
|
assert_copy a[2], b[2]
|
147
|
-
|
147
|
+
#
|
148
148
|
assert_copy a, c
|
149
149
|
assert_copy a[0], c[0]
|
150
150
|
assert_copy a[1], c[1]
|
151
151
|
assert_copy a[2], c[2]
|
152
152
|
|
153
|
-
|
153
|
+
# four
|
154
154
|
a = four
|
155
155
|
b = four.dup
|
156
156
|
c = four.clone
|
157
|
-
|
157
|
+
#
|
158
158
|
assert_copy a, b
|
159
159
|
assert_copy a[0], b[0]
|
160
160
|
assert_copy a[1], b[1]
|
161
161
|
assert_copy a[2], b[2]
|
162
162
|
assert_copy a[3], b[3]
|
163
|
-
|
163
|
+
#
|
164
164
|
assert_copy a, c
|
165
165
|
assert_copy a[0], c[0]
|
166
166
|
assert_copy a[1], c[1]
|
167
167
|
assert_copy a[2], c[2]
|
168
168
|
assert_copy a[3], c[3]
|
169
169
|
|
170
|
-
|
170
|
+
# two_by_four
|
171
171
|
a = two_by_four
|
172
172
|
b = two_by_four.dup
|
173
173
|
c = two_by_four.clone
|
174
|
-
|
174
|
+
#
|
175
175
|
assert_copy a, b
|
176
176
|
assert_copy a[0], b[0]
|
177
177
|
assert_copy a[1], b[1]
|
@@ -185,7 +185,7 @@ module NodeListCopyTest
|
|
185
185
|
assert_copy a[2][1], b[2][1]
|
186
186
|
assert_copy a[3][0], b[3][0]
|
187
187
|
assert_copy a[3][1], b[3][1]
|
188
|
-
|
188
|
+
#
|
189
189
|
assert_copy a, c
|
190
190
|
assert_copy a[0], c[0]
|
191
191
|
assert_copy a[1], c[1]
|
@@ -200,11 +200,11 @@ module NodeListCopyTest
|
|
200
200
|
assert_copy a[3][0], c[3][0]
|
201
201
|
assert_copy a[3][1], c[3][1]
|
202
202
|
|
203
|
-
|
203
|
+
# big -- [a, [b,c], [d, [e], [], [[]]]]
|
204
204
|
a = big
|
205
205
|
b = big.dup
|
206
206
|
c = big.clone
|
207
|
-
|
207
|
+
#
|
208
208
|
assert_copy a, b
|
209
209
|
assert_copy a[0], b[0]
|
210
210
|
assert_copy a[1], b[1]
|
@@ -217,7 +217,7 @@ module NodeListCopyTest
|
|
217
217
|
assert_copy a[2][2], b[2][2]
|
218
218
|
assert_copy a[2][3], b[2][3]
|
219
219
|
assert_copy a[2][3][0], b[2][3][0]
|
220
|
-
|
220
|
+
#
|
221
221
|
assert_copy a, c
|
222
222
|
assert_copy a[0], c[0]
|
223
223
|
assert_copy a[1], c[1]
|
@@ -233,17 +233,17 @@ module NodeListCopyTest
|
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
|
-
|
237
|
-
|
238
|
-
|
236
|
+
#
|
237
|
+
# Tests ==, eql?, hash.
|
238
|
+
#
|
239
239
|
module NodeListEqualTest
|
240
240
|
include NodeListTest
|
241
|
-
def assert_eq
|
241
|
+
def assert_eq(a, b)
|
242
242
|
assert(a == b)
|
243
243
|
assert(a.eql?(b))
|
244
244
|
assert(a.hash == b.hash)
|
245
245
|
end
|
246
|
-
def assert_not_eq
|
246
|
+
def assert_not_eq(a, b)
|
247
247
|
assert(!(a == b))
|
248
248
|
assert(!a.eql?(b))
|
249
249
|
end
|
@@ -263,31 +263,31 @@ module NodeListEqualTest
|
|
263
263
|
assert_not_eq(two, three)
|
264
264
|
assert_not_eq(three, two)
|
265
265
|
|
266
|
-
|
266
|
+
# []
|
267
267
|
empty2 = _List[]
|
268
268
|
assert_eq(empty, empty2)
|
269
269
|
|
270
|
-
|
270
|
+
# [a]
|
271
271
|
a = C::Int.new
|
272
272
|
one2 = _List[a]
|
273
273
|
assert_eq(one, one2)
|
274
274
|
|
275
|
-
|
275
|
+
# [a, b]
|
276
276
|
a, b = 2.of{C::Int.new}
|
277
277
|
two2 = _List[a, b]
|
278
278
|
assert_eq(two, two2)
|
279
279
|
|
280
|
-
|
280
|
+
# [a, b, c]
|
281
281
|
a, b, c = 3.of{C::Int.new}
|
282
282
|
three2 = _List[a, b, c]
|
283
283
|
assert_eq(three, three2)
|
284
284
|
|
285
|
-
|
285
|
+
# [a, b, c, d]
|
286
286
|
a, b, c, d = 4.of{C::Int.new}
|
287
287
|
four2 = _List[a, b, c, d]
|
288
288
|
assert_eq(four, four2)
|
289
289
|
|
290
|
-
|
290
|
+
# [[a,b], [c,d], [e,f], [g,h]]
|
291
291
|
a, b, c, d, e, f, g, h = 8.of{C::Int.new}
|
292
292
|
l0 = _List[a,b]
|
293
293
|
l1 = _List[c,d]
|
@@ -296,7 +296,7 @@ module NodeListEqualTest
|
|
296
296
|
two_by_four2 = _List[l0, l1, l2, l3]
|
297
297
|
assert_eq(two_by_four, two_by_four2)
|
298
298
|
|
299
|
-
|
299
|
+
# [a, [b,c], [d, [e], [], [[]]]]
|
300
300
|
a, b, c, d, e = 5.of{C::Int.new}
|
301
301
|
l1 = _List[b,c]
|
302
302
|
l21 = _List[e]
|
@@ -311,11 +311,11 @@ end
|
|
311
311
|
|
312
312
|
module NodeListWalkTest
|
313
313
|
include NodeListTest
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
def yields
|
314
|
+
#
|
315
|
+
# Collect and return the args yielded to `node.send(method)' as an
|
316
|
+
# Array, each element of which is an array of args yielded.
|
317
|
+
#
|
318
|
+
def yields(method, node, exp)
|
319
319
|
ret = []
|
320
320
|
out = node.send(method) do |*args|
|
321
321
|
ret << args
|
@@ -324,18 +324,18 @@ module NodeListWalkTest
|
|
324
324
|
return ret
|
325
325
|
end
|
326
326
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
def assert_equal_yields
|
327
|
+
#
|
328
|
+
# Assert exp and out are equal, where elements are compared with
|
329
|
+
# Array#same_list?. That is, exp[i].same_list?(out[i]) for all i.
|
330
|
+
#
|
331
|
+
def assert_equal_yields(exp, out)
|
332
332
|
if exp.zip(out).all?{|a,b| a.same_list?(b)}
|
333
333
|
assert(true)
|
334
334
|
else
|
335
335
|
flunk("walk not equal: #{walk_str(out)} (expected #{walk_str(exp)})")
|
336
336
|
end
|
337
337
|
end
|
338
|
-
def walk_str
|
338
|
+
def walk_str(walk)
|
339
339
|
walk.is_a? ::Array or
|
340
340
|
raise "walk_str: expected ::Array"
|
341
341
|
if walk.empty?
|
@@ -355,12 +355,11 @@ module NodeListWalkTest
|
|
355
355
|
end
|
356
356
|
end
|
357
357
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
def iter_str iter
|
358
|
+
# ------------------------------------------------------------------
|
359
|
+
# each, reverse_each
|
360
|
+
# ------------------------------------------------------------------
|
361
|
+
|
362
|
+
def iter_str(iter)
|
364
363
|
iter.is_a? ::Array or
|
365
364
|
raise "iter_str: expected ::Array"
|
366
365
|
if iter.empty?
|
@@ -379,7 +378,7 @@ module NodeListWalkTest
|
|
379
378
|
return s.string
|
380
379
|
end
|
381
380
|
end
|
382
|
-
def check_iter
|
381
|
+
def check_iter(node, exp)
|
383
382
|
exp.map!{|n| [n]}
|
384
383
|
|
385
384
|
out = yields(:each, node, node)
|
@@ -391,69 +390,68 @@ module NodeListWalkTest
|
|
391
390
|
end
|
392
391
|
|
393
392
|
def test_each
|
394
|
-
|
393
|
+
# empty
|
395
394
|
check_iter(empty, [])
|
396
395
|
|
397
|
-
|
398
|
-
a = *one_els
|
396
|
+
# one
|
397
|
+
a, = *one_els
|
399
398
|
check_iter(one, [a])
|
400
399
|
|
401
|
-
|
400
|
+
# two
|
402
401
|
a, b = *two_els
|
403
402
|
check_iter(two, [a, b])
|
404
403
|
|
405
|
-
|
404
|
+
# three
|
406
405
|
a, b, c = *three_els
|
407
406
|
check_iter(three, [a, b, c])
|
408
407
|
|
409
|
-
|
408
|
+
# four
|
410
409
|
a, b, c, d = *four_els
|
411
410
|
check_iter(four, [a, b, c, d])
|
412
411
|
|
413
|
-
|
412
|
+
# two_by_four
|
414
413
|
l0, l1, l2, l3, a, b, c, d, e, f, g, h = *two_by_four_els
|
415
414
|
check_iter(two_by_four, [l0, l1, l2, l3])
|
416
415
|
|
417
|
-
|
416
|
+
# big
|
418
417
|
l1, l2, l21, l22, l23, l230, a, b, c, d, e = *big_els
|
419
418
|
check_iter(big, [a, l1, l2])
|
420
419
|
end
|
421
420
|
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
###
|
421
|
+
# ------------------------------------------------------------------
|
422
|
+
# each_index
|
423
|
+
# ------------------------------------------------------------------
|
424
|
+
|
427
425
|
def test_each_index
|
428
|
-
|
426
|
+
# empty
|
429
427
|
assert_equal([], yields(:each_index, empty, empty))
|
430
428
|
|
431
|
-
|
429
|
+
# one
|
432
430
|
assert_equal([[0]], yields(:each_index, one, one))
|
433
431
|
|
434
|
-
|
432
|
+
# two
|
435
433
|
assert_equal([[0], [1]], yields(:each_index, two, two))
|
436
434
|
|
437
|
-
|
435
|
+
# two_by_four
|
438
436
|
assert_equal([[0], [1], [2], [3]], yields(:each_index, two_by_four, two_by_four))
|
439
437
|
|
440
|
-
|
438
|
+
# big
|
441
439
|
assert_equal([[0], [1], [2]], yields(:each_index, big, big))
|
442
440
|
end
|
443
441
|
end
|
444
442
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
443
|
+
#
|
444
|
+
# Tests:
|
445
|
+
# -- node_before
|
446
|
+
# -- node_after
|
447
|
+
# -- remove_node
|
448
|
+
# -- insert_before
|
449
|
+
# -- insert_after
|
450
|
+
# -- replace_node
|
451
|
+
#
|
454
452
|
module NodeListChildManagementTests
|
455
453
|
include NodeListTest
|
456
|
-
def check_not_child
|
454
|
+
def check_not_child(list, node)
|
457
455
|
n = C::Int.new
|
458
456
|
assert_raise(ArgumentError, list.node_before(node))
|
459
457
|
assert_raise(ArgumentError, list.node_after(node))
|
@@ -463,7 +461,7 @@ module NodeListChildManagementTests
|
|
463
461
|
assert_raise(ArgumentError, list.replace_node(node, n))
|
464
462
|
end
|
465
463
|
|
466
|
-
def check_list
|
464
|
+
def check_list(list, *nodes)
|
467
465
|
afters = nodes.dup
|
468
466
|
afters.shift
|
469
467
|
afters.push(nil)
|
@@ -476,18 +474,16 @@ module NodeListChildManagementTests
|
|
476
474
|
nodes.each_index do |i|
|
477
475
|
assert_same(nodes[i], list[i], "at index #{i}")
|
478
476
|
assert_same(list, nodes[i].parent, "at index #{i}")
|
479
|
-
|
477
|
+
# node_after
|
480
478
|
assert_same(afters[i], list.node_after(nodes[i]), "at index #{i} (expected id=#{afters[i].object_id}, got id=#{list.node_after(nodes[i]).object_id})")
|
481
|
-
|
479
|
+
# node_before
|
482
480
|
assert_same(befores[i], list.node_before(nodes[i]), "at index #{i}")
|
483
481
|
end
|
484
482
|
end
|
485
483
|
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
### ----------------------------------------------------------------
|
490
|
-
###
|
484
|
+
# ------------------------------------------------------------------
|
485
|
+
# insert_before, insert_after
|
486
|
+
# ------------------------------------------------------------------
|
491
487
|
|
492
488
|
def test_insert_one_into_one
|
493
489
|
a1, a2 = 2.of{C::Int.new}
|
@@ -495,11 +491,11 @@ module NodeListChildManagementTests
|
|
495
491
|
a = _List[a1]
|
496
492
|
b = _List[b1]
|
497
493
|
|
498
|
-
|
494
|
+
# beginning
|
499
495
|
assert_same(b, b.insert_before(b1, b2))
|
500
496
|
check_list(b, b2, b1)
|
501
497
|
|
502
|
-
|
498
|
+
# end
|
503
499
|
assert_same(a, a.insert_after(a1, a2))
|
504
500
|
check_list(a, a1, a2)
|
505
501
|
end
|
@@ -510,11 +506,11 @@ module NodeListChildManagementTests
|
|
510
506
|
a = _List[a1]
|
511
507
|
b = _List[b1]
|
512
508
|
|
513
|
-
|
509
|
+
# beginning
|
514
510
|
assert_same(a, a.insert_before(a1, a2, a3))
|
515
511
|
check_list(a, a2, a3, a1)
|
516
512
|
|
517
|
-
|
513
|
+
# end
|
518
514
|
assert_same(b, b.insert_after(b1, b2, b3))
|
519
515
|
check_list(b, b1, b2, b3)
|
520
516
|
end
|
@@ -525,11 +521,11 @@ module NodeListChildManagementTests
|
|
525
521
|
a = _List[a1]
|
526
522
|
b = _List[b1]
|
527
523
|
|
528
|
-
|
524
|
+
# beginning
|
529
525
|
assert_same(a, a.insert_before(a1, a2, a3, a4))
|
530
526
|
check_list(a, a2, a3, a4, a1)
|
531
527
|
|
532
|
-
|
528
|
+
# end
|
533
529
|
assert_same(b, b.insert_after(b1, b2, b3, b4))
|
534
530
|
check_list(b, b1, b2, b3, b4)
|
535
531
|
end
|
@@ -540,16 +536,16 @@ module NodeListChildManagementTests
|
|
540
536
|
a = _List[a1]
|
541
537
|
b = _List[b1]
|
542
538
|
|
543
|
-
|
539
|
+
# beginning
|
544
540
|
assert_same(a, a.insert_before(a1, a2, a3, a4, a5))
|
545
541
|
check_list(a, a2, a3, a4, a5, a1)
|
546
542
|
|
547
|
-
|
543
|
+
# end
|
548
544
|
assert_same(b, b.insert_after(b1, b2, b3, b4, b5))
|
549
545
|
check_list(b, b1, b2, b3, b4, b5)
|
550
546
|
end
|
551
547
|
|
552
|
-
def
|
548
|
+
def test_insert_one_into_two
|
553
549
|
a1, a2, a3 = 3.of{C::Int.new}
|
554
550
|
b1, b2, b3 = 3.of{C::Int.new}
|
555
551
|
c1, c2, c3 = 3.of{C::Int.new}
|
@@ -559,19 +555,19 @@ module NodeListChildManagementTests
|
|
559
555
|
c = _List[c1, c2]
|
560
556
|
d = _List[d1, d2]
|
561
557
|
|
562
|
-
|
558
|
+
# beginning
|
563
559
|
assert_same(a, a.insert_before(a1, a3))
|
564
560
|
check_list(a, a3, a1, a2)
|
565
561
|
|
566
|
-
|
562
|
+
# end
|
567
563
|
assert_same(b, b.insert_after(b2, b3))
|
568
564
|
check_list(b, b1, b2, b3)
|
569
565
|
|
570
|
-
|
566
|
+
# middle (after)
|
571
567
|
assert_same(c, c.insert_after(c1, c3))
|
572
568
|
check_list(c, c1, c3, c2)
|
573
569
|
|
574
|
-
|
570
|
+
# middle (before)
|
575
571
|
assert_same(d, d.insert_before(d2, d3))
|
576
572
|
check_list(d, d1, d3, d2)
|
577
573
|
end
|
@@ -586,19 +582,19 @@ module NodeListChildManagementTests
|
|
586
582
|
c = _List[c1, c2]
|
587
583
|
d = _List[d1, d2]
|
588
584
|
|
589
|
-
|
585
|
+
# beginning
|
590
586
|
assert_same(a, a.insert_before(a1, a3, a4))
|
591
587
|
check_list(a, a3, a4, a1, a2)
|
592
588
|
|
593
|
-
|
589
|
+
# end
|
594
590
|
assert_same(b, b.insert_after(b2, b3, b4))
|
595
591
|
check_list(b, b1, b2, b3, b4)
|
596
592
|
|
597
|
-
|
593
|
+
# middle (after)
|
598
594
|
assert_same(c, c.insert_after(c1, c3, c4))
|
599
595
|
check_list(c, c1, c3, c4, c2)
|
600
596
|
|
601
|
-
|
597
|
+
# middle (before)
|
602
598
|
assert_same(d, d.insert_before(d2, d3, d4))
|
603
599
|
check_list(d, d1, d3, d4, d2)
|
604
600
|
end
|
@@ -613,19 +609,19 @@ module NodeListChildManagementTests
|
|
613
609
|
c = _List[c1, c2]
|
614
610
|
d = _List[d1, d2]
|
615
611
|
|
616
|
-
|
612
|
+
# beginning
|
617
613
|
assert_same(a, a.insert_before(a1, a3, a4, a5))
|
618
614
|
check_list(a, a3, a4, a5, a1, a2)
|
619
615
|
|
620
|
-
|
616
|
+
# end
|
621
617
|
assert_same(b, b.insert_after(b2, b3, b4, b5))
|
622
618
|
check_list(b, b1, b2, b3, b4, b5)
|
623
619
|
|
624
|
-
|
620
|
+
# middle (after)
|
625
621
|
assert_same(c, c.insert_after(c1, c3, c4, c5))
|
626
622
|
check_list(c, c1, c3, c4, c5, c2)
|
627
623
|
|
628
|
-
|
624
|
+
# middle (before)
|
629
625
|
assert_same(d, d.insert_before(d2, d3, d4, d5))
|
630
626
|
check_list(d, d1, d3, d4, d5, d2)
|
631
627
|
end
|
@@ -640,25 +636,25 @@ module NodeListChildManagementTests
|
|
640
636
|
c = _List[c1, c2]
|
641
637
|
d = _List[d1, d2]
|
642
638
|
|
643
|
-
|
639
|
+
# beginning
|
644
640
|
assert_same(a, a.insert_before(a1, a3, a4, a5, a6))
|
645
641
|
check_list(a, a3, a4, a5, a6, a1, a2)
|
646
642
|
|
647
|
-
|
643
|
+
# end
|
648
644
|
assert_same(b, b.insert_after(b2, b3, b4, b5, b6))
|
649
645
|
check_list(b, b1, b2, b3, b4, b5, b6)
|
650
646
|
|
651
|
-
|
647
|
+
# middle (after)
|
652
648
|
assert_same(c, c.insert_after(c1, c3, c4, c5, c6))
|
653
649
|
check_list(c, c1, c3, c4, c5, c6, c2)
|
654
650
|
|
655
|
-
|
651
|
+
# middle (before)
|
656
652
|
assert_same(d, d.insert_before(d2, d3, d4, d5, d6))
|
657
653
|
check_list(d, d1, d3, d4, d5, d6, d2)
|
658
654
|
end
|
659
655
|
|
660
656
|
def test_insert_attached
|
661
|
-
|
657
|
+
# one (before)
|
662
658
|
a1 = C::Int.new
|
663
659
|
b1 = C::Int.new
|
664
660
|
a = _List[a1]
|
@@ -669,7 +665,7 @@ module NodeListChildManagementTests
|
|
669
665
|
assert_copy(b1, a[0])
|
670
666
|
assert_same(a1, a[1])
|
671
667
|
|
672
|
-
|
668
|
+
# one (after)
|
673
669
|
a1 = C::Int.new
|
674
670
|
b1 = C::Int.new
|
675
671
|
a = _List[a1]
|
@@ -680,7 +676,7 @@ module NodeListChildManagementTests
|
|
680
676
|
assert_same(a1, a[0])
|
681
677
|
assert_copy(b1, a[1])
|
682
678
|
|
683
|
-
|
679
|
+
# many (before)
|
684
680
|
a1 = C::Int.new
|
685
681
|
b1, b2, b3, b4 = 4.of{C::Int.new}
|
686
682
|
a = _List[a1]
|
@@ -694,7 +690,7 @@ module NodeListChildManagementTests
|
|
694
690
|
assert_copy(b4, a[3])
|
695
691
|
assert_same(a1, a[4])
|
696
692
|
|
697
|
-
|
693
|
+
# many (after)
|
698
694
|
a1 = C::Int.new
|
699
695
|
b1, b2, b3, b4 = 4.of{C::Int.new}
|
700
696
|
a = _List[a1]
|
@@ -709,11 +705,9 @@ module NodeListChildManagementTests
|
|
709
705
|
assert_copy(b4, a[4])
|
710
706
|
end
|
711
707
|
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
### ----------------------------------------------------------------
|
716
|
-
###
|
708
|
+
# ------------------------------------------------------------------
|
709
|
+
# remove_node
|
710
|
+
# ------------------------------------------------------------------
|
717
711
|
|
718
712
|
def test_remove_one_from_one
|
719
713
|
a1 = C::Int.new
|
@@ -730,12 +724,12 @@ module NodeListChildManagementTests
|
|
730
724
|
a = _List[a1, a2]
|
731
725
|
b = _List[b1, b2]
|
732
726
|
|
733
|
-
|
727
|
+
# beginning
|
734
728
|
assert_same(a, a.remove_node(a1))
|
735
729
|
check_list(a, a2)
|
736
730
|
assert_nil(a1.parent)
|
737
731
|
|
738
|
-
|
732
|
+
# end
|
739
733
|
assert_same(b, b.remove_node(b2))
|
740
734
|
check_list(b, b1)
|
741
735
|
assert_nil(b2.parent)
|
@@ -749,17 +743,17 @@ module NodeListChildManagementTests
|
|
749
743
|
b = _List[b1, b2, b3]
|
750
744
|
c = _List[c1, c2, c3]
|
751
745
|
|
752
|
-
|
746
|
+
# beginning
|
753
747
|
assert_same(a, a.remove_node(a1))
|
754
748
|
check_list(a, a2, a3)
|
755
749
|
assert_nil(a1.parent)
|
756
750
|
|
757
|
-
|
751
|
+
# end
|
758
752
|
assert_same(b, b.remove_node(b3))
|
759
753
|
check_list(b, b1, b2)
|
760
754
|
assert_nil(b3.parent)
|
761
755
|
|
762
|
-
|
756
|
+
# middle
|
763
757
|
assert_same(c, c.remove_node(c2))
|
764
758
|
check_list(c, c1, c3)
|
765
759
|
assert_nil(c2.parent)
|
@@ -774,27 +768,25 @@ module NodeListChildManagementTests
|
|
774
768
|
b = _List[b1, b2, b3, b4]
|
775
769
|
c = _List[c1, c2, c3, c4]
|
776
770
|
|
777
|
-
|
771
|
+
# beginning
|
778
772
|
assert_same(a, a.remove_node(a1))
|
779
773
|
check_list(a, a2, a3, a4)
|
780
774
|
assert_nil(a1.parent)
|
781
775
|
|
782
|
-
|
776
|
+
# end
|
783
777
|
assert_same(b, b.remove_node(b4))
|
784
778
|
check_list(b, b1, b2, b3)
|
785
779
|
assert_nil(b4.parent)
|
786
780
|
|
787
|
-
|
781
|
+
# middle
|
788
782
|
assert_same(c, c.remove_node(c2))
|
789
783
|
check_list(c, c1, c3, c4)
|
790
784
|
assert_nil(c2.parent)
|
791
785
|
end
|
792
786
|
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
### ----------------------------------------------------------------
|
797
|
-
###
|
787
|
+
# ------------------------------------------------------------------
|
788
|
+
# replace_node
|
789
|
+
# ------------------------------------------------------------------
|
798
790
|
|
799
791
|
def test_replace_with_none_in_one
|
800
792
|
a1 = C::Int.new
|
@@ -810,12 +802,12 @@ module NodeListChildManagementTests
|
|
810
802
|
a = _List[a1, a2]
|
811
803
|
b = _List[b1, b2]
|
812
804
|
|
813
|
-
|
805
|
+
# beginning
|
814
806
|
assert_same(a, a.replace_node(a1))
|
815
807
|
check_list(a, a2)
|
816
808
|
assert_nil(a1.parent)
|
817
809
|
|
818
|
-
|
810
|
+
# end
|
819
811
|
assert_same(b, b.replace_node(b2))
|
820
812
|
check_list(b, b1)
|
821
813
|
assert_nil(b2.parent)
|
@@ -829,17 +821,17 @@ module NodeListChildManagementTests
|
|
829
821
|
b = _List[b1, b2, b3]
|
830
822
|
c = _List[c1, c2, c3]
|
831
823
|
|
832
|
-
|
824
|
+
# beginning
|
833
825
|
assert_same(a, a.replace_node(a1))
|
834
826
|
check_list(a, a2, a3)
|
835
827
|
assert_nil(a1.parent)
|
836
828
|
|
837
|
-
|
829
|
+
# end
|
838
830
|
assert_same(b, b.replace_node(b3))
|
839
831
|
check_list(b, b1, b2)
|
840
832
|
assert_nil(b3.parent)
|
841
833
|
|
842
|
-
|
834
|
+
# middle
|
843
835
|
assert_same(c, c.replace_node(c2))
|
844
836
|
check_list(c, c1, c3)
|
845
837
|
assert_nil(c2.parent)
|
@@ -860,12 +852,12 @@ module NodeListChildManagementTests
|
|
860
852
|
a = _List[a1, a2]
|
861
853
|
b = _List[b1, b2]
|
862
854
|
|
863
|
-
|
855
|
+
# beginning
|
864
856
|
assert_same(a, a.replace_node(a1, a3))
|
865
857
|
check_list(a, a3, a2)
|
866
858
|
assert_nil(a1.parent)
|
867
859
|
|
868
|
-
|
860
|
+
# end
|
869
861
|
assert_same(b, b.replace_node(b2, b3))
|
870
862
|
check_list(b, b1, b3)
|
871
863
|
assert_nil(b2.parent)
|
@@ -879,17 +871,17 @@ module NodeListChildManagementTests
|
|
879
871
|
b = _List[b1, b2, b3]
|
880
872
|
c = _List[c1, c2, c3]
|
881
873
|
|
882
|
-
|
874
|
+
# beginning
|
883
875
|
assert_same(a, a.replace_node(a1, a4))
|
884
876
|
check_list(a, a4, a2, a3)
|
885
877
|
assert_nil(a1.parent)
|
886
878
|
|
887
|
-
|
879
|
+
# end
|
888
880
|
assert_same(b, b.replace_node(b3, b4))
|
889
881
|
check_list(b, b1, b2, b4)
|
890
882
|
assert_nil(b3.parent)
|
891
883
|
|
892
|
-
|
884
|
+
# middle
|
893
885
|
assert_same(c, c.replace_node(c2, c4))
|
894
886
|
check_list(c, c1, c4, c3)
|
895
887
|
assert_nil(c2.parent)
|
@@ -910,12 +902,12 @@ module NodeListChildManagementTests
|
|
910
902
|
a = _List[a1, a2]
|
911
903
|
b = _List[b1, b2]
|
912
904
|
|
913
|
-
|
905
|
+
# beginning
|
914
906
|
assert_same(a, a.replace_node(a1, a3, a4))
|
915
907
|
check_list(a, a3, a4, a2)
|
916
908
|
assert_nil(a1.parent)
|
917
909
|
|
918
|
-
|
910
|
+
# end
|
919
911
|
assert_same(b, b.replace_node(b2, b3, b4))
|
920
912
|
check_list(b, b1, b3, b4)
|
921
913
|
assert_nil(b2.parent)
|
@@ -929,17 +921,17 @@ module NodeListChildManagementTests
|
|
929
921
|
b = _List[b1, b2, b3]
|
930
922
|
c = _List[c1, c2, c3]
|
931
923
|
|
932
|
-
|
924
|
+
# beginning
|
933
925
|
assert_same(a, a.replace_node(a1, a4, a5))
|
934
926
|
check_list(a, a4, a5, a2, a3)
|
935
927
|
assert_nil(a1.parent)
|
936
928
|
|
937
|
-
|
929
|
+
# end
|
938
930
|
assert_same(b, b.replace_node(b3, b4, b5))
|
939
931
|
check_list(b, b1, b2, b4, b5)
|
940
932
|
assert_nil(b3.parent)
|
941
933
|
|
942
|
-
|
934
|
+
# middle
|
943
935
|
assert_same(c, c.replace_node(c2, c4, c5))
|
944
936
|
check_list(c, c1, c4, c5, c3)
|
945
937
|
assert_nil(c2.parent)
|
@@ -960,12 +952,12 @@ module NodeListChildManagementTests
|
|
960
952
|
a = _List[a1, a2]
|
961
953
|
b = _List[b1, b2]
|
962
954
|
|
963
|
-
|
955
|
+
# beginning
|
964
956
|
assert_same(a, a.replace_node(a1, a3, a4, a5))
|
965
957
|
check_list(a, a3, a4, a5, a2)
|
966
958
|
assert_nil(a1.parent)
|
967
959
|
|
968
|
-
|
960
|
+
# end
|
969
961
|
assert_same(b, b.replace_node(b2, b3, b4, b5))
|
970
962
|
check_list(b, b1, b3, b4, b5)
|
971
963
|
assert_nil(b2.parent)
|
@@ -979,17 +971,17 @@ module NodeListChildManagementTests
|
|
979
971
|
b = _List[b1, b2, b3]
|
980
972
|
c = _List[c1, c2, c3]
|
981
973
|
|
982
|
-
|
974
|
+
# beginning
|
983
975
|
assert_same(a, a.replace_node(a1, a4, a5, a6))
|
984
976
|
check_list(a, a4, a5, a6, a2, a3)
|
985
977
|
assert_nil(a1.parent)
|
986
978
|
|
987
|
-
|
979
|
+
# end
|
988
980
|
assert_same(b, b.replace_node(b3, b4, b5, b6))
|
989
981
|
check_list(b, b1, b2, b4, b5, b6)
|
990
982
|
assert_nil(b3.parent)
|
991
983
|
|
992
|
-
|
984
|
+
# middle
|
993
985
|
assert_same(c, c.replace_node(c2, c4, c5, c6))
|
994
986
|
check_list(c, c1, c4, c5, c6, c3)
|
995
987
|
assert_nil(c2.parent)
|
@@ -1010,12 +1002,12 @@ module NodeListChildManagementTests
|
|
1010
1002
|
a = _List[a1, a2]
|
1011
1003
|
b = _List[b1, b2]
|
1012
1004
|
|
1013
|
-
|
1005
|
+
# beginning
|
1014
1006
|
assert_same(a, a.replace_node(a1, a3, a4, a5, a6))
|
1015
1007
|
check_list(a, a3, a4, a5, a6, a2)
|
1016
1008
|
assert_nil(a1.parent)
|
1017
1009
|
|
1018
|
-
|
1010
|
+
# end
|
1019
1011
|
assert_same(b, b.replace_node(b2, b3, b4, b5, b6))
|
1020
1012
|
check_list(b, b1, b3, b4, b5, b6)
|
1021
1013
|
assert_nil(b2.parent)
|
@@ -1029,24 +1021,24 @@ module NodeListChildManagementTests
|
|
1029
1021
|
b = _List[b1, b2, b3]
|
1030
1022
|
c = _List[c1, c2, c3]
|
1031
1023
|
|
1032
|
-
|
1024
|
+
# beginning
|
1033
1025
|
assert_same(a, a.replace_node(a1, a4, a5, a6, a7))
|
1034
1026
|
check_list(a, a4, a5, a6, a7, a2, a3)
|
1035
1027
|
assert_nil(a1.parent)
|
1036
1028
|
|
1037
|
-
|
1029
|
+
# end
|
1038
1030
|
assert_same(b, b.replace_node(b3, b4, b5, b6, b7))
|
1039
1031
|
check_list(b, b1, b2, b4, b5, b6, b7)
|
1040
1032
|
assert_nil(b3.parent)
|
1041
1033
|
|
1042
|
-
|
1034
|
+
# middle
|
1043
1035
|
assert_same(c, c.replace_node(c2, c4, c5, c6, c7))
|
1044
1036
|
check_list(c, c1, c4, c5, c6, c7, c3)
|
1045
1037
|
assert_nil(c2.parent)
|
1046
1038
|
end
|
1047
1039
|
|
1048
1040
|
def test_replace_with_attached
|
1049
|
-
|
1041
|
+
# one
|
1050
1042
|
a1 = C::Int.new
|
1051
1043
|
a = _List[a1]
|
1052
1044
|
b1 = C::Int.new
|
@@ -1055,7 +1047,7 @@ module NodeListChildManagementTests
|
|
1055
1047
|
assert_copy(b1, a[0])
|
1056
1048
|
assert_nil(a1.parent)
|
1057
1049
|
|
1058
|
-
|
1050
|
+
# many
|
1059
1051
|
a1 = C::Int.new
|
1060
1052
|
a = _List[a1]
|
1061
1053
|
b1, b2, b3, b4 = 4.of{C::Int.new}
|
@@ -1069,7 +1061,7 @@ module NodeListChildManagementTests
|
|
1069
1061
|
end
|
1070
1062
|
|
1071
1063
|
def test_replace_with_duplicated
|
1072
|
-
|
1064
|
+
# one
|
1073
1065
|
a1, a2 = 2.of{C::Int.new}
|
1074
1066
|
a = _List[a1]
|
1075
1067
|
assert_same(a, a.replace_node(a1, a2, a2))
|
@@ -1077,7 +1069,7 @@ module NodeListChildManagementTests
|
|
1077
1069
|
assert_same(a2, a[0])
|
1078
1070
|
assert_copy(a2, a[1])
|
1079
1071
|
|
1080
|
-
|
1072
|
+
# many
|
1081
1073
|
a1, a2, a3, a4 = 4.of{C::Int.new}
|
1082
1074
|
a = _List[a1, a2, a3]
|
1083
1075
|
assert_same(a, a.replace_node(a1, a2, a4, a2, a4))
|
@@ -1091,13 +1083,13 @@ module NodeListChildManagementTests
|
|
1091
1083
|
end
|
1092
1084
|
|
1093
1085
|
def test_replace_with_replaced
|
1094
|
-
|
1086
|
+
# one
|
1095
1087
|
a1 = C::Int.new
|
1096
1088
|
a = _List[a1]
|
1097
1089
|
assert_same(a, a.replace_node(a1, a1))
|
1098
1090
|
assert_same_list([a1], a)
|
1099
1091
|
|
1100
|
-
|
1092
|
+
# many -- some are the replaced node
|
1101
1093
|
a1, a2, a3 = 3.of{C::Int.new}
|
1102
1094
|
a = _List[a1]
|
1103
1095
|
assert_same(a, a.replace_node(a1, a1, a2, a3, a1))
|
@@ -1107,7 +1099,7 @@ module NodeListChildManagementTests
|
|
1107
1099
|
assert_same(a3, a[2])
|
1108
1100
|
assert_copy(a1, a[3])
|
1109
1101
|
|
1110
|
-
|
1102
|
+
# many -- all are the replaced node
|
1111
1103
|
a1 = C::Int.new
|
1112
1104
|
a = _List[a1]
|
1113
1105
|
assert_same(a, a.replace_node(a1, a1, a1, a1))
|
@@ -1120,18 +1112,17 @@ end
|
|
1120
1112
|
|
1121
1113
|
module NodeListArrayQueryTests
|
1122
1114
|
include NodeListTest
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
###
|
1115
|
+
|
1116
|
+
# ------------------------------------------------------------------
|
1117
|
+
# first, last
|
1118
|
+
# ------------------------------------------------------------------
|
1128
1119
|
|
1129
1120
|
def test_first
|
1130
|
-
|
1121
|
+
# empty
|
1131
1122
|
a = _List[]
|
1132
1123
|
assert_nil(a.first)
|
1133
1124
|
|
1134
|
-
|
1125
|
+
# one
|
1135
1126
|
a1 = C::Int.new
|
1136
1127
|
a = _List[a1]
|
1137
1128
|
assert_same(a1, a.first)
|
@@ -1139,7 +1130,7 @@ module NodeListArrayQueryTests
|
|
1139
1130
|
assert_same_list([a1], a.first(1))
|
1140
1131
|
assert_same_list([a1], a.first(2))
|
1141
1132
|
|
1142
|
-
|
1133
|
+
# two
|
1143
1134
|
a1, a2 = 2.of{C::Int.new}
|
1144
1135
|
a = _List[a1, a2]
|
1145
1136
|
assert_same(a1, a.first)
|
@@ -1148,7 +1139,7 @@ module NodeListArrayQueryTests
|
|
1148
1139
|
assert_same_list([a1, a2], a.first(2))
|
1149
1140
|
assert_same_list([a1, a2], a.first(3))
|
1150
1141
|
|
1151
|
-
|
1142
|
+
# three
|
1152
1143
|
ret = a.first(3)
|
1153
1144
|
a1, a2, a3 = 3.of{C::Int.new}
|
1154
1145
|
a = _List[a1, a2, a3]
|
@@ -1159,16 +1150,16 @@ module NodeListArrayQueryTests
|
|
1159
1150
|
assert_same_list([a1, a2, a3], a.first(3))
|
1160
1151
|
assert_same_list([a1, a2, a3], a.first(4))
|
1161
1152
|
|
1162
|
-
|
1153
|
+
# negative array size
|
1163
1154
|
assert_raise(ArgumentError){a.first(-1)}
|
1164
1155
|
end
|
1165
1156
|
|
1166
1157
|
def test_last
|
1167
|
-
|
1158
|
+
# empty
|
1168
1159
|
a = _List[]
|
1169
1160
|
assert_nil(a.last)
|
1170
1161
|
|
1171
|
-
|
1162
|
+
# one
|
1172
1163
|
a1 = C::Int.new
|
1173
1164
|
a = _List[a1]
|
1174
1165
|
assert_same(a1, a.last)
|
@@ -1176,7 +1167,7 @@ module NodeListArrayQueryTests
|
|
1176
1167
|
assert_same_list([a1], a.last(1))
|
1177
1168
|
assert_same_list([a1], a.last(2))
|
1178
1169
|
|
1179
|
-
|
1170
|
+
# two
|
1180
1171
|
a1, a2 = 2.of{C::Int.new}
|
1181
1172
|
a = _List[a1, a2]
|
1182
1173
|
assert_same(a2, a.last)
|
@@ -1185,7 +1176,7 @@ module NodeListArrayQueryTests
|
|
1185
1176
|
assert_same_list([a1, a2], a.last(2))
|
1186
1177
|
assert_same_list([a1, a2], a.last(3))
|
1187
1178
|
|
1188
|
-
|
1179
|
+
# three
|
1189
1180
|
ret = a.last(3)
|
1190
1181
|
a1, a2, a3 = 3.of{C::Int.new}
|
1191
1182
|
a = _List[a1, a2, a3]
|
@@ -1196,15 +1187,13 @@ module NodeListArrayQueryTests
|
|
1196
1187
|
assert_same_list([a1, a2, a3], a.last(3))
|
1197
1188
|
assert_same_list([a1, a2, a3], a.last(4))
|
1198
1189
|
|
1199
|
-
|
1190
|
+
# negative array size
|
1200
1191
|
assert_raise(ArgumentError){a.last(-1)}
|
1201
1192
|
end
|
1202
1193
|
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
### ----------------------------------------------------------------
|
1207
|
-
###
|
1194
|
+
# ------------------------------------------------------------------
|
1195
|
+
# empty?
|
1196
|
+
# ------------------------------------------------------------------
|
1208
1197
|
|
1209
1198
|
def test_empty
|
1210
1199
|
assert(_List[].empty?)
|
@@ -1212,104 +1201,100 @@ module NodeListArrayQueryTests
|
|
1212
1201
|
assert(!_List[_List[]].empty?)
|
1213
1202
|
end
|
1214
1203
|
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
### ----------------------------------------------------------------
|
1219
|
-
###
|
1204
|
+
# ------------------------------------------------------------------
|
1205
|
+
# to_a
|
1206
|
+
# ------------------------------------------------------------------
|
1220
1207
|
|
1221
1208
|
def test_to_a
|
1222
|
-
|
1209
|
+
# empty
|
1223
1210
|
r = empty.to_a
|
1224
1211
|
assert_same(::Array, r.class)
|
1225
1212
|
assert_same_list([], r)
|
1226
1213
|
|
1227
|
-
|
1228
|
-
a = *one_els
|
1214
|
+
# one
|
1215
|
+
a, = *one_els
|
1229
1216
|
r = one.to_a
|
1230
1217
|
assert_same(::Array, r.class)
|
1231
1218
|
assert_same_list([a], r)
|
1232
1219
|
|
1233
|
-
|
1220
|
+
# two
|
1234
1221
|
a, b = *two_els
|
1235
1222
|
r = two.to_a
|
1236
1223
|
assert_same(::Array, r.class)
|
1237
1224
|
assert_same_list([a, b], r)
|
1238
1225
|
|
1239
|
-
|
1226
|
+
# three
|
1240
1227
|
a, b, c = *three_els
|
1241
1228
|
r = three.to_a
|
1242
1229
|
assert_same(::Array, r.class)
|
1243
1230
|
assert_same_list([a, b, c], r)
|
1244
1231
|
|
1245
|
-
|
1232
|
+
# four
|
1246
1233
|
a, b, c, d = *four_els
|
1247
1234
|
r = four.to_a
|
1248
1235
|
assert_same(::Array, r.class)
|
1249
1236
|
assert_same_list([a, b, c, d], r)
|
1250
1237
|
|
1251
|
-
|
1238
|
+
# two_by_four
|
1252
1239
|
l0, l1, l2, l3, a, b, c, d, e, f, g, h = *two_by_four_els
|
1253
1240
|
r = two_by_four.to_a
|
1254
1241
|
assert_same(::Array, r.class)
|
1255
1242
|
assert_same_list([l0, l1, l2, l3], r)
|
1256
1243
|
|
1257
|
-
|
1244
|
+
# big
|
1258
1245
|
l1, l2, l21, l22, l23, l230, a, b, c, d, e = *big_els
|
1259
1246
|
r = big.to_a
|
1260
1247
|
assert_same(::Array, r.class)
|
1261
1248
|
assert_same_list([a, l1, l2], r)
|
1262
1249
|
end
|
1263
1250
|
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
### ----------------------------------------------------------------
|
1268
|
-
###
|
1251
|
+
# ------------------------------------------------------------------
|
1252
|
+
# index, rindex
|
1253
|
+
# ------------------------------------------------------------------
|
1269
1254
|
|
1270
1255
|
def test_index
|
1271
|
-
|
1256
|
+
# empty
|
1272
1257
|
empty = _List[]
|
1273
1258
|
assert_nil(empty.index(C::Int.new))
|
1274
1259
|
assert_nil(empty.index(nil))
|
1275
|
-
|
1260
|
+
#
|
1276
1261
|
assert_nil(empty.rindex(C::Int.new))
|
1277
1262
|
assert_nil(empty.rindex(nil))
|
1278
1263
|
|
1279
|
-
|
1264
|
+
# one
|
1280
1265
|
a = C::Int.new(1)
|
1281
1266
|
list = _List[a]
|
1282
|
-
|
1267
|
+
#
|
1283
1268
|
assert_equal(0, list.index(a))
|
1284
1269
|
assert_equal(0, list.index(C::Int.new(1)))
|
1285
1270
|
assert_nil(list.index(C::Int.new))
|
1286
1271
|
assert_nil(list.index(nil))
|
1287
|
-
|
1272
|
+
#
|
1288
1273
|
assert_equal(0, list.rindex(a))
|
1289
1274
|
assert_nil(list.rindex(C::Int.new))
|
1290
1275
|
assert_nil(list.rindex(nil))
|
1291
1276
|
|
1292
|
-
|
1277
|
+
# two
|
1293
1278
|
a = C::Int.new(1)
|
1294
1279
|
b = C::Int.new(2)
|
1295
1280
|
list = _List[a, b]
|
1296
|
-
|
1281
|
+
#
|
1297
1282
|
assert_equal(0, list.index(a))
|
1298
1283
|
assert_equal(1, list.index(b))
|
1299
1284
|
assert_nil(list.index(C::Int.new))
|
1300
1285
|
assert_nil(list.index(nil))
|
1301
|
-
|
1286
|
+
#
|
1302
1287
|
assert_equal(0, list.rindex(a))
|
1303
1288
|
assert_equal(1, list.rindex(b))
|
1304
1289
|
assert_nil(list.rindex(C::Int.new))
|
1305
1290
|
assert_nil(list.rindex(nil))
|
1306
1291
|
|
1307
|
-
|
1292
|
+
# nested -- [a, [b]]
|
1308
1293
|
a = C::Int.new(1)
|
1309
1294
|
b = C::Int.new(2)
|
1310
1295
|
l1 = _List[b]
|
1311
1296
|
list = _List[a, l1]
|
1312
|
-
|
1297
|
+
#
|
1313
1298
|
assert_equal(0, list.index(a))
|
1314
1299
|
assert_equal(1, list.index(l1))
|
1315
1300
|
assert_equal(1, list.index(_List[C::Int.new(2)]))
|
@@ -1317,7 +1302,7 @@ module NodeListArrayQueryTests
|
|
1317
1302
|
assert_nil(list.index([a]))
|
1318
1303
|
assert_nil(list.index(C::Int.new))
|
1319
1304
|
assert_nil(list.index(nil))
|
1320
|
-
|
1305
|
+
#
|
1321
1306
|
assert_equal(0, list.rindex(a))
|
1322
1307
|
assert_equal(1, list.rindex(l1))
|
1323
1308
|
assert_equal(1, list.rindex(_List[b]))
|
@@ -1325,11 +1310,11 @@ module NodeListArrayQueryTests
|
|
1325
1310
|
assert_nil(list.rindex(C::Int.new))
|
1326
1311
|
assert_nil(list.rindex(nil))
|
1327
1312
|
|
1328
|
-
|
1313
|
+
# repeated
|
1329
1314
|
a1, a2, a3 = 3.of{C::Int.new(-1)}
|
1330
1315
|
b1, b2, b3 = 3.of{C::Int.new(1)}
|
1331
1316
|
list = _List[a1, b1, a2, b2, a3, b3]
|
1332
|
-
|
1317
|
+
#
|
1333
1318
|
assert_equal(0, list.index(a1))
|
1334
1319
|
assert_equal(0, list.index(a2))
|
1335
1320
|
assert_equal(0, list.index(a3))
|
@@ -1338,7 +1323,7 @@ module NodeListArrayQueryTests
|
|
1338
1323
|
assert_equal(1, list.index(b3))
|
1339
1324
|
assert_nil(list.index(C::Int.new))
|
1340
1325
|
assert_nil(list.index(nil))
|
1341
|
-
|
1326
|
+
#
|
1342
1327
|
assert_equal(4, list.rindex(a1))
|
1343
1328
|
assert_equal(4, list.rindex(a2))
|
1344
1329
|
assert_equal(4, list.rindex(a3))
|
@@ -1349,26 +1334,24 @@ module NodeListArrayQueryTests
|
|
1349
1334
|
assert_nil(list.rindex(nil))
|
1350
1335
|
end
|
1351
1336
|
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
### ----------------------------------------------------------------
|
1356
|
-
###
|
1337
|
+
# ------------------------------------------------------------------
|
1338
|
+
# values_at
|
1339
|
+
# ------------------------------------------------------------------
|
1357
1340
|
|
1358
1341
|
def test_values_at
|
1359
|
-
|
1342
|
+
# empty
|
1360
1343
|
assert_same_list([], empty.values_at())
|
1361
1344
|
assert_same_list([nil], empty.values_at(1))
|
1362
1345
|
assert_same_list([nil], empty.values_at(-1))
|
1363
1346
|
|
1364
|
-
|
1365
|
-
a = *one_els
|
1347
|
+
# one
|
1348
|
+
a, = *one_els
|
1366
1349
|
assert_same_list([], one.values_at())
|
1367
1350
|
assert_same_list([a], one.values_at(0))
|
1368
1351
|
assert_same_list([a], one.values_at(-1))
|
1369
1352
|
assert_same_list([nil, a], one.values_at(1, -1))
|
1370
1353
|
|
1371
|
-
|
1354
|
+
# big -- [a, [b,c], [d, [e], [], [[]]]]
|
1372
1355
|
l1, l2, l21, l22, l23, l230, a, b, c, d, e = *big_els
|
1373
1356
|
assert_same_list([], big.values_at())
|
1374
1357
|
assert_same_list([l2], big.values_at(-1))
|
@@ -1376,14 +1359,12 @@ module NodeListArrayQueryTests
|
|
1376
1359
|
assert_same_list([a, l1, l2], big.values_at(0, -2, -1))
|
1377
1360
|
end
|
1378
1361
|
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
### ----------------------------------------------------------------
|
1383
|
-
###
|
1362
|
+
# ------------------------------------------------------------------
|
1363
|
+
# join
|
1364
|
+
# ------------------------------------------------------------------
|
1384
1365
|
|
1385
1366
|
class N < C::Node
|
1386
|
-
def initialize
|
1367
|
+
def initialize(s)
|
1387
1368
|
@s = s
|
1388
1369
|
end
|
1389
1370
|
def to_s
|
@@ -1391,25 +1372,25 @@ module NodeListArrayQueryTests
|
|
1391
1372
|
end
|
1392
1373
|
end
|
1393
1374
|
def test_join
|
1394
|
-
|
1375
|
+
# empty
|
1395
1376
|
list = _List[]
|
1396
1377
|
assert_equal('', list.join)
|
1397
1378
|
assert_equal('', list.join('.'))
|
1398
1379
|
|
1399
|
-
|
1380
|
+
# one
|
1400
1381
|
a = N.new('a')
|
1401
1382
|
list = _List[a]
|
1402
1383
|
assert_equal('a', list.join)
|
1403
1384
|
assert_equal('a', list.join('.'))
|
1404
1385
|
|
1405
|
-
|
1386
|
+
# two
|
1406
1387
|
a = N.new('a')
|
1407
1388
|
b = N.new('b')
|
1408
1389
|
list = _List[a, b]
|
1409
1390
|
assert_equal('ab', list.join)
|
1410
1391
|
assert_equal('a.b', list.join('.'))
|
1411
1392
|
|
1412
|
-
|
1393
|
+
# two_by_two
|
1413
1394
|
a = N.new('a')
|
1414
1395
|
b = N.new('b')
|
1415
1396
|
c = N.new('c')
|
@@ -1425,24 +1406,24 @@ end
|
|
1425
1406
|
module NodeListModifierTests
|
1426
1407
|
include NodeListTest
|
1427
1408
|
def test_push_none
|
1428
|
-
|
1409
|
+
# empty
|
1429
1410
|
list = _List[]
|
1430
1411
|
assert_same(list, list.push)
|
1431
1412
|
assert_same_list([], list)
|
1432
1413
|
|
1433
|
-
|
1414
|
+
# one
|
1434
1415
|
a = C::Int.new
|
1435
1416
|
list = _List[a]
|
1436
1417
|
assert_same(list, list.push)
|
1437
1418
|
assert_same_list([a], list)
|
1438
1419
|
|
1439
|
-
|
1420
|
+
# two
|
1440
1421
|
a, b = 2.of{C::Int.new}
|
1441
1422
|
list = _List[a, b]
|
1442
1423
|
assert_same(list, list.push)
|
1443
1424
|
assert_same_list([a, b], list)
|
1444
1425
|
|
1445
|
-
|
1426
|
+
# three
|
1446
1427
|
a, b, c = 3.of{C::Int.new}
|
1447
1428
|
list = _List[a, b, c]
|
1448
1429
|
assert_same(list, list.push)
|
@@ -1450,25 +1431,25 @@ module NodeListModifierTests
|
|
1450
1431
|
end
|
1451
1432
|
|
1452
1433
|
def test_push_one
|
1453
|
-
|
1434
|
+
# empty
|
1454
1435
|
a = C::Int.new
|
1455
1436
|
list = _List[]
|
1456
1437
|
assert_same(list, list.push(a))
|
1457
1438
|
assert_same_list([a], list)
|
1458
1439
|
|
1459
|
-
|
1440
|
+
# one
|
1460
1441
|
a, b = 2.of{C::Int.new}
|
1461
1442
|
list = _List[a]
|
1462
1443
|
assert_same(list, list.push(b))
|
1463
1444
|
assert_same_list([a, b], list)
|
1464
1445
|
|
1465
|
-
|
1446
|
+
# two
|
1466
1447
|
a, b, c = 3.of{C::Int.new}
|
1467
1448
|
list = _List[a, b]
|
1468
1449
|
assert_same(list, list.push(c))
|
1469
1450
|
assert_same_list([a, b, c], list)
|
1470
1451
|
|
1471
|
-
|
1452
|
+
# three
|
1472
1453
|
a, b, c, d = 4.of{C::Int.new}
|
1473
1454
|
list = _List[a, b, c]
|
1474
1455
|
assert_same(list, list.push(d))
|
@@ -1476,25 +1457,25 @@ module NodeListModifierTests
|
|
1476
1457
|
end
|
1477
1458
|
|
1478
1459
|
def test_push_two
|
1479
|
-
|
1460
|
+
# empty
|
1480
1461
|
a, b = 2.of{C::Int.new}
|
1481
1462
|
list = _List[]
|
1482
1463
|
assert_same(list, list.push(a, b))
|
1483
1464
|
assert_same_list([a, b], list)
|
1484
1465
|
|
1485
|
-
|
1466
|
+
# one
|
1486
1467
|
a, b, c = 3.of{C::Int.new}
|
1487
1468
|
list = _List[a]
|
1488
1469
|
assert_same(list, list.push(b, c))
|
1489
1470
|
assert_same_list([a, b, c], list)
|
1490
1471
|
|
1491
|
-
|
1472
|
+
# two
|
1492
1473
|
a, b, c, d = 4.of{C::Int.new}
|
1493
1474
|
list = _List[a, b]
|
1494
1475
|
assert_same(list, list.push(c, d))
|
1495
1476
|
assert_same_list([a, b, c, d], list)
|
1496
1477
|
|
1497
|
-
|
1478
|
+
# three
|
1498
1479
|
a, b, c, d, e = 5.of{C::Int.new}
|
1499
1480
|
list = _List[a, b, c]
|
1500
1481
|
assert_same(list, list.push(d, e))
|
@@ -1502,25 +1483,25 @@ module NodeListModifierTests
|
|
1502
1483
|
end
|
1503
1484
|
|
1504
1485
|
def test_push_three
|
1505
|
-
|
1486
|
+
# empty
|
1506
1487
|
a, b, c = 3.of{C::Int.new}
|
1507
1488
|
list = _List[]
|
1508
1489
|
assert_same(list, list.push(a, b, c))
|
1509
1490
|
assert_same_list([a, b, c], list)
|
1510
1491
|
|
1511
|
-
|
1492
|
+
# one
|
1512
1493
|
a, b, c, d = 4.of{C::Int.new}
|
1513
1494
|
list = _List[a]
|
1514
1495
|
assert_same(list, list.push(b, c, d))
|
1515
1496
|
assert_same_list([a, b, c, d], list)
|
1516
1497
|
|
1517
|
-
|
1498
|
+
# two
|
1518
1499
|
a, b, c, d, e = 5.of{C::Int.new}
|
1519
1500
|
list = _List[a, b]
|
1520
1501
|
assert_same(list, list.push(c, d, e))
|
1521
1502
|
assert_same_list([a, b, c, d, e], list)
|
1522
1503
|
|
1523
|
-
|
1504
|
+
# three
|
1524
1505
|
a, b, c, d, e, f = 6.of{C::Int.new}
|
1525
1506
|
list = _List[a, b, c]
|
1526
1507
|
assert_same(list, list.push(d, e, f))
|
@@ -1528,7 +1509,7 @@ module NodeListModifierTests
|
|
1528
1509
|
end
|
1529
1510
|
|
1530
1511
|
def test_push_attached
|
1531
|
-
|
1512
|
+
# one
|
1532
1513
|
a1 = C::Int.new
|
1533
1514
|
b1 = C::Int.new
|
1534
1515
|
a = _List[a1]
|
@@ -1539,7 +1520,7 @@ module NodeListModifierTests
|
|
1539
1520
|
assert_same(a1, a[0])
|
1540
1521
|
assert_copy(b1, a[1])
|
1541
1522
|
|
1542
|
-
|
1523
|
+
# many
|
1543
1524
|
a1 = C::Int.new
|
1544
1525
|
b1, b2, b3, b4 = 4.of{C::Int.new}
|
1545
1526
|
a = _List[a1]
|
@@ -1555,24 +1536,24 @@ module NodeListModifierTests
|
|
1555
1536
|
end
|
1556
1537
|
|
1557
1538
|
def test_unshift_none
|
1558
|
-
|
1539
|
+
# empty
|
1559
1540
|
list = _List[]
|
1560
1541
|
assert_same(list, list.unshift)
|
1561
1542
|
assert_same_list([], list)
|
1562
1543
|
|
1563
|
-
|
1544
|
+
# one
|
1564
1545
|
a = C::Int.new
|
1565
1546
|
list = _List[a]
|
1566
1547
|
assert_same(list, list.unshift)
|
1567
1548
|
assert_same_list([a], list)
|
1568
1549
|
|
1569
|
-
|
1550
|
+
# two
|
1570
1551
|
a, b = 2.of{C::Int.new}
|
1571
1552
|
list = _List[a, b]
|
1572
1553
|
assert_same(list, list.unshift)
|
1573
1554
|
assert_same_list([a, b], list)
|
1574
1555
|
|
1575
|
-
|
1556
|
+
# three
|
1576
1557
|
a, b, c = 3.of{C::Int.new}
|
1577
1558
|
list = _List[a, b, c]
|
1578
1559
|
assert_same(list, list.unshift)
|
@@ -1580,25 +1561,25 @@ module NodeListModifierTests
|
|
1580
1561
|
end
|
1581
1562
|
|
1582
1563
|
def test_unshift_one
|
1583
|
-
|
1564
|
+
# empty
|
1584
1565
|
a = C::Int.new
|
1585
1566
|
list = _List[]
|
1586
1567
|
assert_same(list, list.unshift(a))
|
1587
1568
|
assert_same_list([a], list)
|
1588
1569
|
|
1589
|
-
|
1570
|
+
# one
|
1590
1571
|
a, b = 2.of{C::Int.new}
|
1591
1572
|
list = _List[a]
|
1592
1573
|
assert_same(list, list.unshift(b))
|
1593
1574
|
assert_same_list([b, a], list)
|
1594
1575
|
|
1595
|
-
|
1576
|
+
# two
|
1596
1577
|
a, b, c = 3.of{C::Int.new}
|
1597
1578
|
list = _List[a, b]
|
1598
1579
|
assert_same(list, list.unshift(c))
|
1599
1580
|
assert_same_list([c, a, b], list)
|
1600
1581
|
|
1601
|
-
|
1582
|
+
# three
|
1602
1583
|
a, b, c, d = 4.of{C::Int.new}
|
1603
1584
|
list = _List[a, b, c]
|
1604
1585
|
assert_same(list, list.unshift(d))
|
@@ -1606,25 +1587,25 @@ module NodeListModifierTests
|
|
1606
1587
|
end
|
1607
1588
|
|
1608
1589
|
def test_unshift_two
|
1609
|
-
|
1590
|
+
# empty
|
1610
1591
|
a, b = 2.of{C::Int.new}
|
1611
1592
|
list = _List[]
|
1612
1593
|
assert_same(list, list.unshift(a, b))
|
1613
1594
|
assert_same_list([a, b], list)
|
1614
1595
|
|
1615
|
-
|
1596
|
+
# one
|
1616
1597
|
a, b, c = 3.of{C::Int.new}
|
1617
1598
|
list = _List[a]
|
1618
1599
|
assert_same(list, list.unshift(b, c))
|
1619
1600
|
assert_same_list([b, c, a], list)
|
1620
1601
|
|
1621
|
-
|
1602
|
+
# two
|
1622
1603
|
a, b, c, d = 4.of{C::Int.new}
|
1623
1604
|
list = _List[a, b]
|
1624
1605
|
assert_same(list, list.unshift(c, d))
|
1625
1606
|
assert_same_list([c, d, a, b], list)
|
1626
1607
|
|
1627
|
-
|
1608
|
+
# three
|
1628
1609
|
a, b, c, d, e = 5.of{C::Int.new}
|
1629
1610
|
list = _List[a, b, c]
|
1630
1611
|
assert_same(list, list.unshift(d, e))
|
@@ -1632,25 +1613,25 @@ module NodeListModifierTests
|
|
1632
1613
|
end
|
1633
1614
|
|
1634
1615
|
def test_unshift_three
|
1635
|
-
|
1616
|
+
# empty
|
1636
1617
|
a, b, c = 3.of{C::Int.new}
|
1637
1618
|
list = _List[]
|
1638
1619
|
assert_same(list, list.unshift(a, b, c))
|
1639
1620
|
assert_same_list([a, b, c], list)
|
1640
1621
|
|
1641
|
-
|
1622
|
+
# one
|
1642
1623
|
a, b, c, d = 4.of{C::Int.new}
|
1643
1624
|
list = _List[a]
|
1644
1625
|
assert_same(list, list.unshift(b, c, d))
|
1645
1626
|
assert_same_list([b, c, d, a], list)
|
1646
1627
|
|
1647
|
-
|
1628
|
+
# two
|
1648
1629
|
a, b, c, d, e = 5.of{C::Int.new}
|
1649
1630
|
list = _List[a, b]
|
1650
1631
|
assert_same(list, list.unshift(c, d, e))
|
1651
1632
|
assert_same_list([c, d, e, a, b], list)
|
1652
1633
|
|
1653
|
-
|
1634
|
+
# three
|
1654
1635
|
a, b, c, d, e, f = 6.of{C::Int.new}
|
1655
1636
|
list = _List[a, b, c]
|
1656
1637
|
assert_same(list, list.unshift(d, e, f))
|
@@ -1658,7 +1639,7 @@ module NodeListModifierTests
|
|
1658
1639
|
end
|
1659
1640
|
|
1660
1641
|
def test_unshift_attached
|
1661
|
-
|
1642
|
+
# one
|
1662
1643
|
a1 = C::Int.new
|
1663
1644
|
b1 = C::Int.new
|
1664
1645
|
a = _List[a1]
|
@@ -1669,7 +1650,7 @@ module NodeListModifierTests
|
|
1669
1650
|
assert_copy(b1, a[0])
|
1670
1651
|
assert_same(a1, a[1])
|
1671
1652
|
|
1672
|
-
|
1653
|
+
# many
|
1673
1654
|
a1 = C::Int.new
|
1674
1655
|
b1, b2, b3, b4 = 4.of{C::Int.new}
|
1675
1656
|
a = _List[a1]
|
@@ -1685,26 +1666,26 @@ module NodeListModifierTests
|
|
1685
1666
|
end
|
1686
1667
|
|
1687
1668
|
def test_pop
|
1688
|
-
|
1669
|
+
# empty
|
1689
1670
|
list = _List[]
|
1690
1671
|
assert_same(nil, list.pop)
|
1691
1672
|
assert_same_list([], list)
|
1692
1673
|
|
1693
|
-
|
1674
|
+
# one
|
1694
1675
|
a = C::Int.new
|
1695
1676
|
list = _List[a]
|
1696
1677
|
assert_same(a, list.pop)
|
1697
1678
|
assert_same_list([], list)
|
1698
1679
|
assert_nil(a.parent)
|
1699
1680
|
|
1700
|
-
|
1681
|
+
# two
|
1701
1682
|
a, b = 2.of{C::Int.new}
|
1702
1683
|
list = _List[a, b]
|
1703
1684
|
assert_same(b, list.pop)
|
1704
1685
|
assert_same_list([a], list)
|
1705
1686
|
assert_nil(b.parent)
|
1706
1687
|
|
1707
|
-
|
1688
|
+
# three
|
1708
1689
|
a, b, c = 3.of{C::Int.new}
|
1709
1690
|
list = _List[a, b, c]
|
1710
1691
|
assert_same(c, list.pop)
|
@@ -1713,27 +1694,27 @@ module NodeListModifierTests
|
|
1713
1694
|
end
|
1714
1695
|
|
1715
1696
|
def test_pop_none
|
1716
|
-
|
1697
|
+
# empty
|
1717
1698
|
list = _List[]
|
1718
1699
|
ret = list.pop(0)
|
1719
1700
|
assert_same_list([], ret)
|
1720
1701
|
assert_same_list([], list)
|
1721
1702
|
|
1722
|
-
|
1703
|
+
# one
|
1723
1704
|
a = C::Int.new
|
1724
1705
|
list = _List[a]
|
1725
1706
|
ret = list.pop(0)
|
1726
1707
|
assert_same_list([], ret)
|
1727
1708
|
assert_same_list([a], list)
|
1728
1709
|
|
1729
|
-
|
1710
|
+
# two
|
1730
1711
|
a, b = 2.of{C::Int.new}
|
1731
1712
|
list = _List[a, b]
|
1732
1713
|
ret = list.pop(0)
|
1733
1714
|
assert_same_list([], ret)
|
1734
1715
|
assert_same_list([a, b], list)
|
1735
1716
|
|
1736
|
-
|
1717
|
+
# three
|
1737
1718
|
a, b, c = 3.of{C::Int.new}
|
1738
1719
|
list = _List[a, b, c]
|
1739
1720
|
ret = list.pop(0)
|
@@ -1742,13 +1723,13 @@ module NodeListModifierTests
|
|
1742
1723
|
end
|
1743
1724
|
|
1744
1725
|
def test_pop_one
|
1745
|
-
|
1726
|
+
# empty
|
1746
1727
|
list = _List[]
|
1747
1728
|
ret = list.pop(1)
|
1748
1729
|
assert_same_list([], ret)
|
1749
1730
|
assert_same_list([], list)
|
1750
1731
|
|
1751
|
-
|
1732
|
+
# one
|
1752
1733
|
a = C::Int.new
|
1753
1734
|
list = _List[a]
|
1754
1735
|
ret = list.pop(1)
|
@@ -1756,7 +1737,7 @@ module NodeListModifierTests
|
|
1756
1737
|
assert_same_list([], list)
|
1757
1738
|
assert_nil(a.parent)
|
1758
1739
|
|
1759
|
-
|
1740
|
+
# two
|
1760
1741
|
a, b = 2.of{C::Int.new}
|
1761
1742
|
list = _List[a, b]
|
1762
1743
|
ret = list.pop(1)
|
@@ -1764,7 +1745,7 @@ module NodeListModifierTests
|
|
1764
1745
|
assert_same_list([a], list)
|
1765
1746
|
assert_nil(b.parent)
|
1766
1747
|
|
1767
|
-
|
1748
|
+
# three
|
1768
1749
|
a, b, c = 3.of{C::Int.new}
|
1769
1750
|
list = _List[a, b, c]
|
1770
1751
|
ret = list.pop(1)
|
@@ -1774,13 +1755,13 @@ module NodeListModifierTests
|
|
1774
1755
|
end
|
1775
1756
|
|
1776
1757
|
def test_pop_two
|
1777
|
-
|
1758
|
+
# empty
|
1778
1759
|
list = _List[]
|
1779
1760
|
ret = list.pop(2)
|
1780
1761
|
assert_same_list([], ret)
|
1781
1762
|
assert_same_list([], list)
|
1782
1763
|
|
1783
|
-
|
1764
|
+
# one
|
1784
1765
|
a = C::Int.new
|
1785
1766
|
list = _List[a]
|
1786
1767
|
ret = list.pop(2)
|
@@ -1788,7 +1769,7 @@ module NodeListModifierTests
|
|
1788
1769
|
assert_same_list([], list)
|
1789
1770
|
assert_nil(a.parent)
|
1790
1771
|
|
1791
|
-
|
1772
|
+
# two
|
1792
1773
|
a, b = 2.of{C::Int.new}
|
1793
1774
|
list = _List[a, b]
|
1794
1775
|
ret = list.pop(2)
|
@@ -1797,7 +1778,7 @@ module NodeListModifierTests
|
|
1797
1778
|
assert_nil(a.parent)
|
1798
1779
|
assert_nil(b.parent)
|
1799
1780
|
|
1800
|
-
|
1781
|
+
# three
|
1801
1782
|
a, b, c = 3.of{C::Int.new}
|
1802
1783
|
list = _List[a, b, c]
|
1803
1784
|
ret = list.pop(2)
|
@@ -1808,7 +1789,7 @@ module NodeListModifierTests
|
|
1808
1789
|
end
|
1809
1790
|
|
1810
1791
|
def test_pop_bad
|
1811
|
-
|
1792
|
+
# too many args
|
1812
1793
|
a, b = 2.of{C::Int.new}
|
1813
1794
|
list = _List[a, b]
|
1814
1795
|
assert_raise(ArgumentError){list.pop(1, 2)}
|
@@ -1818,13 +1799,13 @@ module NodeListModifierTests
|
|
1818
1799
|
end
|
1819
1800
|
|
1820
1801
|
def test_shift
|
1821
|
-
|
1802
|
+
# empty
|
1822
1803
|
list = _List[]
|
1823
1804
|
ret = list.shift
|
1824
1805
|
assert_nil(ret)
|
1825
1806
|
assert_same_list([], list)
|
1826
1807
|
|
1827
|
-
|
1808
|
+
# one
|
1828
1809
|
a = C::Int.new
|
1829
1810
|
list = _List[a]
|
1830
1811
|
ret = list.shift
|
@@ -1832,7 +1813,7 @@ module NodeListModifierTests
|
|
1832
1813
|
assert_same_list([], list)
|
1833
1814
|
assert_nil(a.parent)
|
1834
1815
|
|
1835
|
-
|
1816
|
+
# two
|
1836
1817
|
a, b = 2.of{C::Int.new}
|
1837
1818
|
list = _List[a, b]
|
1838
1819
|
ret = list.shift
|
@@ -1840,7 +1821,7 @@ module NodeListModifierTests
|
|
1840
1821
|
assert_same_list([b], list)
|
1841
1822
|
assert_nil(a.parent)
|
1842
1823
|
|
1843
|
-
|
1824
|
+
# three
|
1844
1825
|
a, b, c = 3.of{C::Int.new}
|
1845
1826
|
list = _List[a, b, c]
|
1846
1827
|
ret = list.shift
|
@@ -1850,27 +1831,27 @@ module NodeListModifierTests
|
|
1850
1831
|
end
|
1851
1832
|
|
1852
1833
|
def test_shift_none
|
1853
|
-
|
1834
|
+
# empty
|
1854
1835
|
list = _List[]
|
1855
1836
|
ret = list.shift(0)
|
1856
1837
|
assert_same_list([], ret)
|
1857
1838
|
assert_same_list([], list)
|
1858
1839
|
|
1859
|
-
|
1840
|
+
# one
|
1860
1841
|
a = C::Int.new
|
1861
1842
|
list = _List[a]
|
1862
1843
|
ret = list.shift(0)
|
1863
1844
|
assert_same_list([], ret)
|
1864
1845
|
assert_same_list([a], list)
|
1865
1846
|
|
1866
|
-
|
1847
|
+
# two
|
1867
1848
|
a, b = 2.of{C::Int.new}
|
1868
1849
|
list = _List[a, b]
|
1869
1850
|
ret = list.shift(0)
|
1870
1851
|
assert_same_list([], ret)
|
1871
1852
|
assert_same_list([a, b], list)
|
1872
1853
|
|
1873
|
-
|
1854
|
+
# three
|
1874
1855
|
a, b, c = 3.of{C::Int.new}
|
1875
1856
|
list = _List[a, b, c]
|
1876
1857
|
ret = list.shift(0)
|
@@ -1879,13 +1860,13 @@ module NodeListModifierTests
|
|
1879
1860
|
end
|
1880
1861
|
|
1881
1862
|
def test_shift_one
|
1882
|
-
|
1863
|
+
# empty
|
1883
1864
|
list = _List[]
|
1884
1865
|
ret = list.shift(1)
|
1885
1866
|
assert_same_list([], ret)
|
1886
1867
|
assert_same_list([], list)
|
1887
1868
|
|
1888
|
-
|
1869
|
+
# one
|
1889
1870
|
a = C::Int.new
|
1890
1871
|
list = _List[a]
|
1891
1872
|
ret = list.shift(1)
|
@@ -1893,7 +1874,7 @@ module NodeListModifierTests
|
|
1893
1874
|
assert_same_list([], list)
|
1894
1875
|
assert_nil(a.parent)
|
1895
1876
|
|
1896
|
-
|
1877
|
+
# two
|
1897
1878
|
a, b = 2.of{C::Int.new}
|
1898
1879
|
list = _List[a, b]
|
1899
1880
|
ret = list.shift(1)
|
@@ -1901,7 +1882,7 @@ module NodeListModifierTests
|
|
1901
1882
|
assert_same_list([b], list)
|
1902
1883
|
assert_nil(a.parent)
|
1903
1884
|
|
1904
|
-
|
1885
|
+
# three
|
1905
1886
|
a, b, c = 3.of{C::Int.new}
|
1906
1887
|
list = _List[a, b, c]
|
1907
1888
|
ret = list.shift(1)
|
@@ -1911,13 +1892,13 @@ module NodeListModifierTests
|
|
1911
1892
|
end
|
1912
1893
|
|
1913
1894
|
def test_shift_two
|
1914
|
-
|
1895
|
+
# empty
|
1915
1896
|
list = _List[]
|
1916
1897
|
ret = list.shift(2)
|
1917
1898
|
assert_same_list([], ret)
|
1918
1899
|
assert_same_list([], list)
|
1919
1900
|
|
1920
|
-
|
1901
|
+
# one
|
1921
1902
|
a = C::Int.new
|
1922
1903
|
list = _List[a]
|
1923
1904
|
ret = list.shift(2)
|
@@ -1925,7 +1906,7 @@ module NodeListModifierTests
|
|
1925
1906
|
assert_same_list([], list)
|
1926
1907
|
assert_nil(a.parent)
|
1927
1908
|
|
1928
|
-
|
1909
|
+
# two
|
1929
1910
|
a, b = 2.of{C::Int.new}
|
1930
1911
|
list = _List[a, b]
|
1931
1912
|
ret = list.shift(2)
|
@@ -1934,7 +1915,7 @@ module NodeListModifierTests
|
|
1934
1915
|
assert_nil(a.parent)
|
1935
1916
|
assert_nil(b.parent)
|
1936
1917
|
|
1937
|
-
|
1918
|
+
# three
|
1938
1919
|
a, b, c = 3.of{C::Int.new}
|
1939
1920
|
list = _List[a, b, c]
|
1940
1921
|
ret = list.shift(2)
|
@@ -1945,7 +1926,7 @@ module NodeListModifierTests
|
|
1945
1926
|
end
|
1946
1927
|
|
1947
1928
|
def test_shift_bad
|
1948
|
-
|
1929
|
+
# too many args
|
1949
1930
|
a, b = 2.of{C::Int.new}
|
1950
1931
|
list = _List[a, b]
|
1951
1932
|
assert_raise(ArgumentError){list.shift(1, 2)}
|
@@ -1954,11 +1935,9 @@ module NodeListModifierTests
|
|
1954
1935
|
assert_same(list, b.parent)
|
1955
1936
|
end
|
1956
1937
|
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
### ----------------------------------------------------------------
|
1961
|
-
###
|
1938
|
+
# ------------------------------------------------------------------
|
1939
|
+
# insert
|
1940
|
+
# ------------------------------------------------------------------
|
1962
1941
|
|
1963
1942
|
def test_insert_one_into_one
|
1964
1943
|
a1, a2 = 2.of{C::Int.new}
|
@@ -1966,11 +1945,11 @@ module NodeListModifierTests
|
|
1966
1945
|
a = _List[a1]
|
1967
1946
|
b = _List[b1]
|
1968
1947
|
|
1969
|
-
|
1948
|
+
# beginning
|
1970
1949
|
a.insert(0, a2)
|
1971
1950
|
assert_same_list([a2, a1], a)
|
1972
1951
|
|
1973
|
-
|
1952
|
+
# end
|
1974
1953
|
b.insert(1, b2)
|
1975
1954
|
assert_same_list([b1, b2], b)
|
1976
1955
|
end
|
@@ -1981,11 +1960,11 @@ module NodeListModifierTests
|
|
1981
1960
|
a = _List[a1]
|
1982
1961
|
b = _List[b1]
|
1983
1962
|
|
1984
|
-
|
1963
|
+
# beginning
|
1985
1964
|
a.insert(0, a2, a3)
|
1986
1965
|
assert_same_list([a2, a3, a1], a)
|
1987
1966
|
|
1988
|
-
|
1967
|
+
# end
|
1989
1968
|
b.insert(1, b2, b3)
|
1990
1969
|
assert_same_list([b1, b2, b3], b)
|
1991
1970
|
end
|
@@ -1996,11 +1975,11 @@ module NodeListModifierTests
|
|
1996
1975
|
a = _List[a1]
|
1997
1976
|
b = _List[b1]
|
1998
1977
|
|
1999
|
-
|
1978
|
+
# beginning
|
2000
1979
|
a.insert(0, a2, a3, a4)
|
2001
1980
|
assert_same_list([a2, a3, a4, a1], a)
|
2002
1981
|
|
2003
|
-
|
1982
|
+
# end
|
2004
1983
|
b.insert(1, b2, b3, b4)
|
2005
1984
|
assert_same_list([b1, b2, b3, b4], b)
|
2006
1985
|
end
|
@@ -2011,16 +1990,16 @@ module NodeListModifierTests
|
|
2011
1990
|
a = _List[a1]
|
2012
1991
|
b = _List[b1]
|
2013
1992
|
|
2014
|
-
|
1993
|
+
# beginning
|
2015
1994
|
a.insert(0, a2, a3, a4, a5)
|
2016
1995
|
assert_same_list([a2, a3, a4, a5, a1], a)
|
2017
1996
|
|
2018
|
-
|
1997
|
+
# end
|
2019
1998
|
b.insert(1, b2, b3, b4, b5)
|
2020
1999
|
assert_same_list([b1, b2, b3, b4, b5], b)
|
2021
2000
|
end
|
2022
2001
|
|
2023
|
-
def
|
2002
|
+
def test_insert_one_into_two
|
2024
2003
|
a1, a2, a3 = 3.of{C::Int.new}
|
2025
2004
|
b1, b2, b3 = 3.of{C::Int.new}
|
2026
2005
|
c1, c2, c3 = 3.of{C::Int.new}
|
@@ -2028,16 +2007,16 @@ module NodeListModifierTests
|
|
2028
2007
|
b = _List[b1, b2]
|
2029
2008
|
c = _List[c1, c2]
|
2030
2009
|
|
2031
|
-
|
2010
|
+
# beginning
|
2032
2011
|
a.insert(0, a3)
|
2033
2012
|
assert_same_list([a3, a1, a2], a)
|
2034
2013
|
|
2035
|
-
|
2014
|
+
# end
|
2036
2015
|
b.insert(2, b3)
|
2037
2016
|
assert_same_list([b1, b2, b3], b)
|
2038
2017
|
|
2039
|
-
|
2040
|
-
c.
|
2018
|
+
# middle
|
2019
|
+
c.insert(1, c3)
|
2041
2020
|
assert_same_list([c1, c3, c2], c)
|
2042
2021
|
end
|
2043
2022
|
|
@@ -2050,15 +2029,15 @@ module NodeListModifierTests
|
|
2050
2029
|
b = _List[b1, b2]
|
2051
2030
|
c = _List[c1, c2]
|
2052
2031
|
|
2053
|
-
|
2032
|
+
# beginning
|
2054
2033
|
a.insert(0, a3, a4)
|
2055
2034
|
assert_same_list([a3, a4, a1, a2], a)
|
2056
2035
|
|
2057
|
-
|
2036
|
+
# end
|
2058
2037
|
b.insert(2, b3, b4)
|
2059
2038
|
assert_same_list([b1, b2, b3, b4], b)
|
2060
2039
|
|
2061
|
-
|
2040
|
+
# middle
|
2062
2041
|
c.insert(1, c3, c4)
|
2063
2042
|
assert_same_list([c1, c3, c4, c2], c)
|
2064
2043
|
end
|
@@ -2071,15 +2050,15 @@ module NodeListModifierTests
|
|
2071
2050
|
b = _List[b1, b2]
|
2072
2051
|
c = _List[c1, c2]
|
2073
2052
|
|
2074
|
-
|
2053
|
+
# beginning
|
2075
2054
|
a.insert(0, a3, a4, a5)
|
2076
2055
|
assert_same_list([a3, a4, a5, a1, a2], a)
|
2077
2056
|
|
2078
|
-
|
2057
|
+
# end
|
2079
2058
|
b.insert(2, b3, b4, b5)
|
2080
2059
|
assert_same_list([b1, b2, b3, b4, b5], b)
|
2081
2060
|
|
2082
|
-
|
2061
|
+
# middle
|
2083
2062
|
c.insert(1, c3, c4, c5)
|
2084
2063
|
assert_same_list([c1, c3, c4, c5, c2], c)
|
2085
2064
|
end
|
@@ -2092,21 +2071,21 @@ module NodeListModifierTests
|
|
2092
2071
|
b = _List[b1, b2]
|
2093
2072
|
c = _List[c1, c2]
|
2094
2073
|
|
2095
|
-
|
2074
|
+
# beginning
|
2096
2075
|
a.insert(0, a3, a4, a5, a6)
|
2097
2076
|
assert_same_list([a3, a4, a5, a6, a1, a2], a)
|
2098
2077
|
|
2099
|
-
|
2078
|
+
# end
|
2100
2079
|
b.insert(2, b3, b4, b5, b6)
|
2101
2080
|
assert_same_list([b1, b2, b3, b4, b5, b6], b)
|
2102
2081
|
|
2103
|
-
|
2082
|
+
# middle (after)
|
2104
2083
|
c.insert(1, c3, c4, c5, c6)
|
2105
2084
|
assert_same_list([c1, c3, c4, c5, c6, c2], c)
|
2106
2085
|
end
|
2107
2086
|
|
2108
2087
|
def test_insert_attached
|
2109
|
-
|
2088
|
+
# one
|
2110
2089
|
a1 = C::Int.new
|
2111
2090
|
b1 = C::Int.new
|
2112
2091
|
a = _List[a1]
|
@@ -2116,7 +2095,7 @@ module NodeListModifierTests
|
|
2116
2095
|
assert_same(a1, a[0])
|
2117
2096
|
assert_copy(b1, a[1])
|
2118
2097
|
|
2119
|
-
|
2098
|
+
# many
|
2120
2099
|
a1 = C::Int.new
|
2121
2100
|
b1, b2, b3, b4 = 4.of{C::Int.new}
|
2122
2101
|
a = _List[a1]
|
@@ -2130,11 +2109,9 @@ module NodeListModifierTests
|
|
2130
2109
|
assert_same(a1, a[4])
|
2131
2110
|
end
|
2132
2111
|
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
### ----------------------------------------------------------------
|
2137
|
-
###
|
2112
|
+
# ------------------------------------------------------------------
|
2113
|
+
# concat
|
2114
|
+
# ------------------------------------------------------------------
|
2138
2115
|
|
2139
2116
|
def test_concat_zero_on_zero
|
2140
2117
|
a = _List[]
|
@@ -2173,7 +2150,7 @@ module NodeListModifierTests
|
|
2173
2150
|
|
2174
2151
|
assert_same(a, a.concat(b))
|
2175
2152
|
assert_same_list([b1], b)
|
2176
|
-
|
2153
|
+
#
|
2177
2154
|
assert_equal(1, a.length)
|
2178
2155
|
assert_copy(b1, a[0])
|
2179
2156
|
end
|
@@ -2186,7 +2163,7 @@ module NodeListModifierTests
|
|
2186
2163
|
|
2187
2164
|
assert_same(a, a.concat(b))
|
2188
2165
|
assert_same_list([b1], b)
|
2189
|
-
|
2166
|
+
#
|
2190
2167
|
assert_equal(2, a.length)
|
2191
2168
|
assert_same(a1, a[0])
|
2192
2169
|
assert_copy(b1, a[1])
|
@@ -2200,7 +2177,7 @@ module NodeListModifierTests
|
|
2200
2177
|
|
2201
2178
|
assert_same(a, a.concat(b))
|
2202
2179
|
assert_same_list([b1], b)
|
2203
|
-
|
2180
|
+
#
|
2204
2181
|
assert_equal(3, a.length)
|
2205
2182
|
assert_same(a1, a[0])
|
2206
2183
|
assert_same(a2, a[1])
|
@@ -2214,7 +2191,7 @@ module NodeListModifierTests
|
|
2214
2191
|
|
2215
2192
|
assert_same(a, a.concat(b))
|
2216
2193
|
assert_same_list([b1, b2], b)
|
2217
|
-
|
2194
|
+
#
|
2218
2195
|
assert_equal(2, a.length)
|
2219
2196
|
assert_copy(b1, a[0])
|
2220
2197
|
assert_copy(b2, a[1])
|
@@ -2228,7 +2205,7 @@ module NodeListModifierTests
|
|
2228
2205
|
|
2229
2206
|
assert_same(a, a.concat(b))
|
2230
2207
|
assert_same_list([b1, b2], b)
|
2231
|
-
|
2208
|
+
#
|
2232
2209
|
assert_equal(3, a.length)
|
2233
2210
|
assert_same(a1, a[0])
|
2234
2211
|
assert_copy(b1, a[1])
|
@@ -2243,7 +2220,7 @@ module NodeListModifierTests
|
|
2243
2220
|
|
2244
2221
|
assert_same(a, a.concat(b))
|
2245
2222
|
assert_same_list([b1, b2], b)
|
2246
|
-
|
2223
|
+
#
|
2247
2224
|
assert_equal(4, a.length)
|
2248
2225
|
assert_same(a1, a[0])
|
2249
2226
|
assert_same(a2, a[1])
|
@@ -2251,11 +2228,9 @@ module NodeListModifierTests
|
|
2251
2228
|
assert_copy(b2, a[3])
|
2252
2229
|
end
|
2253
2230
|
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
### ----------------------------------------------------------------
|
2258
|
-
###
|
2231
|
+
# ------------------------------------------------------------------
|
2232
|
+
# delete_at
|
2233
|
+
# ------------------------------------------------------------------
|
2259
2234
|
|
2260
2235
|
def test_delete_at_one
|
2261
2236
|
a1 = C::Int.new
|
@@ -2267,14 +2242,14 @@ module NodeListModifierTests
|
|
2267
2242
|
end
|
2268
2243
|
|
2269
2244
|
def test_delete_at_two
|
2270
|
-
|
2245
|
+
# delete_at 0
|
2271
2246
|
a1, a2 = 2.of{C::Int.new}
|
2272
2247
|
a = _List[a1, a2]
|
2273
2248
|
assert_same(a1, a.delete_at(0))
|
2274
2249
|
assert_nil(a1.parent)
|
2275
2250
|
assert_same_list([a2], a)
|
2276
2251
|
|
2277
|
-
|
2252
|
+
# delete_at 1
|
2278
2253
|
a1, a2 = 2.of{C::Int.new}
|
2279
2254
|
a = _List[a1, a2]
|
2280
2255
|
assert_same(a2, a.delete_at(1))
|
@@ -2283,21 +2258,21 @@ module NodeListModifierTests
|
|
2283
2258
|
end
|
2284
2259
|
|
2285
2260
|
def test_delete_at_three
|
2286
|
-
|
2261
|
+
# delete at 0
|
2287
2262
|
a1, a2, a3 = 3.of{C::Int.new}
|
2288
2263
|
a = _List[a1, a2, a3]
|
2289
2264
|
assert_same(a1, a.delete_at(0))
|
2290
2265
|
assert_nil(a1.parent)
|
2291
2266
|
assert_same_list([a2, a3], a)
|
2292
2267
|
|
2293
|
-
|
2268
|
+
# delete at 1
|
2294
2269
|
a1, a2, a3 = 3.of{C::Int.new}
|
2295
2270
|
a = _List[a1, a2, a3]
|
2296
2271
|
assert_same(a2, a.delete_at(1))
|
2297
2272
|
assert_nil(a2.parent)
|
2298
2273
|
assert_same_list([a1, a3], a)
|
2299
2274
|
|
2300
|
-
|
2275
|
+
# delete at 2
|
2301
2276
|
a1, a2, a3 = 3.of{C::Int.new}
|
2302
2277
|
a = _List[a1, a2, a3]
|
2303
2278
|
assert_same(a3, a.delete_at(2))
|
@@ -2306,7 +2281,7 @@ module NodeListModifierTests
|
|
2306
2281
|
end
|
2307
2282
|
|
2308
2283
|
def test_delete_at_four
|
2309
|
-
|
2284
|
+
# delete at 1
|
2310
2285
|
a1, a2, a3, a4 = 4.of{C::Int.new}
|
2311
2286
|
a = _List[a1, a2, a3, a4]
|
2312
2287
|
assert_same(a2, a.delete_at(1))
|
@@ -2314,11 +2289,9 @@ module NodeListModifierTests
|
|
2314
2289
|
assert_same_list([a1, a3, a4], a)
|
2315
2290
|
end
|
2316
2291
|
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
### ----------------------------------------------------------------
|
2321
|
-
###
|
2292
|
+
# ------------------------------------------------------------------
|
2293
|
+
# clear
|
2294
|
+
# ------------------------------------------------------------------
|
2322
2295
|
|
2323
2296
|
def test_clear_empty
|
2324
2297
|
assert_same(empty, empty.clear)
|
@@ -2358,11 +2331,9 @@ module NodeListModifierTests
|
|
2358
2331
|
assert_nil(l2.parent)
|
2359
2332
|
end
|
2360
2333
|
|
2361
|
-
|
2362
|
-
|
2363
|
-
|
2364
|
-
### ----------------------------------------------------------------
|
2365
|
-
###
|
2334
|
+
# ------------------------------------------------------------------
|
2335
|
+
# replace
|
2336
|
+
# ------------------------------------------------------------------
|
2366
2337
|
|
2367
2338
|
def test_replace_none_with_none
|
2368
2339
|
a = _List[]
|
@@ -2458,7 +2429,7 @@ module NodeListModifierTests
|
|
2458
2429
|
end
|
2459
2430
|
|
2460
2431
|
def test_replace_with_attached
|
2461
|
-
|
2432
|
+
# one
|
2462
2433
|
a1 = C::Int.new
|
2463
2434
|
a = _List[a1]
|
2464
2435
|
b1 = C::Int.new
|
@@ -2468,7 +2439,7 @@ module NodeListModifierTests
|
|
2468
2439
|
assert_equal(1, a.length)
|
2469
2440
|
assert_copy(b1, a[0])
|
2470
2441
|
|
2471
|
-
|
2442
|
+
# many
|
2472
2443
|
a1 = C::Int.new
|
2473
2444
|
a = _List[a1]
|
2474
2445
|
b1, b2, b3, b4 = 4.of{C::Int.new}
|
@@ -2483,7 +2454,7 @@ module NodeListModifierTests
|
|
2483
2454
|
end
|
2484
2455
|
end
|
2485
2456
|
|
2486
|
-
|
2457
|
+
# Make concrete test classes.
|
2487
2458
|
NodeListTest.submodules.each do |test_module|
|
2488
2459
|
test_module.name =~ /^NodeList/ or
|
2489
2460
|
raise "NodeListTest submodule name does not start with 'NodeList': #{test_module.name}"
|