cast 0.0.1 → 0.3.1

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