cast 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -724,6 +724,7 @@ module C
724
724
  class FloatLiteral
725
725
  field :format, :dec
726
726
  field :val
727
+ field :exponent
727
728
  field :suffix
728
729
  initializer :val
729
730
  end
@@ -238,7 +238,7 @@ module C
238
238
  def node_after(node)
239
239
  node.parent.equal? self or
240
240
  raise ArgumentError, "node is not a child"
241
- @array[index = node.instance_variable_get(:@parent_index)+1]
241
+ @array[node.instance_variable_get(:@parent_index) + 1]
242
242
  end
243
243
 
244
244
  def node_before(node)
@@ -248,7 +248,7 @@ module C
248
248
  if index.zero?
249
249
  return nil
250
250
  else
251
- return @array[index-1]
251
+ return @array[index - 1]
252
252
  end
253
253
  end
254
254
 
@@ -256,7 +256,7 @@ module C
256
256
  node.parent.equal? self or
257
257
  raise ArgumentError, "node is not a child"
258
258
  index = node.instance_variable_get(:@parent_index)
259
- index.instance_variable_set(:@parent_index, nil)
259
+ node.instance_variable_set(:@parent_index, nil)
260
260
  removed_(@array[index])
261
261
  @array.delete_at(index)
262
262
  adjust_indices_(index)
@@ -435,8 +435,8 @@ module C
435
435
  end
436
436
  def pop(*args)
437
437
  if args.empty?
438
- ret = @array.pop
439
- removed_(ret)
438
+ ret = @array.pop and
439
+ removed_(ret)
440
440
  return ret
441
441
  else
442
442
  args.length == 1 or
@@ -450,8 +450,8 @@ module C
450
450
  end
451
451
  def shift(*args)
452
452
  if args.empty?
453
- ret = @array.shift
454
- removed_ ret
453
+ ret = @array.shift and
454
+ removed_ ret
455
455
  else
456
456
  args.length == 1 or
457
457
  raise ArgumentError, "wrong number of arguments (#{args.length} for 0..1)"
@@ -460,7 +460,7 @@ module C
460
460
  ret = @array.slice!(0, arg)
461
461
  removed_(*ret)
462
462
  end
463
- adjust_indices_(0)
463
+ adjust_indices_(0) unless ret.nil?
464
464
  return ret
465
465
  end
466
466
  def insert(i, *newnodes)
@@ -786,7 +786,7 @@ module C
786
786
  else
787
787
  b.instance_variable_set(:@prev, last)
788
788
  end
789
-
789
+
790
790
  # connect `nodes'
791
791
  if nodes.length == 1
792
792
  node = nodes[0]
@@ -1,4 +1,5 @@
1
1
  require 'rbconfig'
2
+ require 'shellwords'
2
3
 
3
4
  ######################################################################
4
5
  #
@@ -21,9 +22,10 @@ module C
21
22
 
22
23
  attr_accessor :pwd, :include_path, :macros
23
24
 
24
- def initialize
25
+ def initialize(quiet: false)
25
26
  @include_path = []
26
27
  @macros = {}
28
+ @quiet = quiet
27
29
  end
28
30
  def preprocess(text)
29
31
  filename = nil
@@ -31,7 +33,7 @@ module C
31
33
  filename = file.path
32
34
  file.puts text
33
35
  end
34
- output = `#{full_command(filename)} 2>&1`
36
+ output = `#{full_command(filename)} #{'2> /dev/null' if @quiet}`
35
37
  if $? == 0
36
38
  return output
37
39
  else
@@ -48,25 +50,10 @@ module C
48
50
 
49
51
  private # -------------------------------------------------------
50
52
 
51
- def shellquote(arg)
52
- if arg !~ /[\"\'\\$&<>|\s]/
53
- return arg
54
- elsif arg !~ /\'/
55
- return "'#{arg}'"
56
- else
57
- arg.gsub!(/([\"\\$&<>|])/, '\\\\\\1')
58
- return "\"#{arg}\""
59
- end
60
- end
61
53
  def full_command(filename)
62
- include_args = include_path.map do |path|
63
- "#{shellquote('-I'+path)}"
64
- end.join(' ')
65
- macro_args = macros.sort.map do |key, val|
66
- shellquote("-D#{key}" + (val ? "=#{val}" : ''))
67
- end.join(' ')
68
- filename = shellquote(filename)
69
- "#{Preprocessor.command} #{include_args} #{macro_args} #{filename}"
54
+ include_args = include_path.map { |path| "-I#{path}" }
55
+ macro_args = macros.sort.map { |key, val| "-D#{key}" + (val ? "=#{val}" : '') }
56
+ [*Preprocessor.command.shellsplit, *include_args, *macro_args, filename].shelljoin
70
57
  end
71
58
  end
72
59
  end
@@ -527,12 +527,48 @@ module C
527
527
  end
528
528
  class IntLiteral
529
529
  def to_s
530
- val.to_s
530
+ case format
531
+ when :dec
532
+ "#{val.to_s}#{suffix}"
533
+ when :hex
534
+ "0x#{val.to_s(16)}#{suffix}"
535
+ when :oct
536
+ "0#{val.to_s(8)}#{suffix}"
537
+ else
538
+ raise "invalid C::IntLiteral format: #{format}"
539
+ end
531
540
  end
532
541
  end
533
542
  class FloatLiteral
534
543
  def to_s
535
- val.to_s
544
+ case format
545
+ when :dec
546
+ if exponent
547
+ "#{val / 10**exponent}e#{exponent}#{suffix}"
548
+ else
549
+ "#{val}#{suffix}"
550
+ end
551
+ when :hex
552
+ "0x#{float_hex(val / 2**exponent)}p#{exponent || 0}#{suffix}"
553
+ else
554
+ raise "invalid C::FloatLiteral format: #{format}"
555
+ end
556
+ end
557
+
558
+ private
559
+
560
+ HEX_DIGITS = %w[0 1 2 3 4 5 6 7 8 9 a b c d e f]
561
+
562
+ def float_hex(value)
563
+ int, frac = value.divmod(1)
564
+ string = "#{int.to_s(16)}."
565
+ # 64-bit floats have 53 bits of significand ~ 14 hex digits.
566
+ 14.times do
567
+ break if frac < 1e-17
568
+ int, frac = (frac * 16).divmod(1)
569
+ string << HEX_DIGITS[int]
570
+ end
571
+ string
536
572
  end
537
573
  end
538
574
  class Variable
@@ -1,5 +1,5 @@
1
1
  module C
2
- VERSION = [0, 2, 1]
2
+ VERSION = [0, 3, 0]
3
3
 
4
4
  class << VERSION
5
5
  include Comparable
@@ -6,7 +6,7 @@
6
6
 
7
7
  require 'test_helper'
8
8
 
9
- class MiscTests < Test::Unit::TestCase
9
+ class MiscTests < Minitest::Test
10
10
 
11
11
  # ------------------------------------------------------------------
12
12
  # Declarator#declaration type
@@ -164,7 +164,7 @@ EOS
164
164
 
165
165
  t = C::Int.new
166
166
  x = C::Void.new
167
- assert_raise(NoMethodError){t.direct_type = x}
167
+ assert_raises(NoMethodError){t.direct_type = x}
168
168
  end
169
169
 
170
170
  # ------------------------------------------------------------------
@@ -8,7 +8,7 @@
8
8
 
9
9
  require 'test_helper'
10
10
 
11
- class LexerTest < Test::Unit::TestCase
11
+ class LexerTest < Minitest::Test
12
12
  def check(s)
13
13
  check_ast(s){|inp| C::Parser.new.parse(inp)}
14
14
  end
@@ -136,10 +136,10 @@ TranslationUnit
136
136
  val: 4660
137
137
  suffix: "ULL"
138
138
  EOS
139
- assert_raise(C::ParseError){C::Parser.new.parse('void f() {12lll;}')}
140
- assert_raise(C::ParseError){C::Parser.new.parse('void f() {12ulL;}')}
141
- assert_raise(C::ParseError){C::Parser.new.parse('void f() {12lul;}')}
142
- assert_raise(C::ParseError){C::Parser.new.parse('void f() {123_4;}')}
139
+ assert_raises(C::ParseError){C::Parser.new.parse('void f() {12lll;}')}
140
+ assert_raises(C::ParseError){C::Parser.new.parse('void f() {12ulL;}')}
141
+ assert_raises(C::ParseError){C::Parser.new.parse('void f() {12lul;}')}
142
+ assert_raises(C::ParseError){C::Parser.new.parse('void f() {123_4;}')}
143
143
  end
144
144
  def test_float_literal
145
145
  check <<EOS
@@ -166,51 +166,63 @@ TranslationUnit
166
166
  exprs:
167
167
  - FloatLiteral
168
168
  val: 1230000.0
169
+ exponent: 4
169
170
  - FloatLiteral
170
171
  val: 0.0123
172
+ exponent: -4
171
173
  - ExpressionStatement
172
174
  expr: Comma
173
175
  exprs:
174
176
  - FloatLiteral
175
177
  val: 1234000000000.0
178
+ exponent: 10
176
179
  - FloatLiteral
177
180
  val: 1.23e-05
181
+ exponent: -4
178
182
  - ExpressionStatement
179
183
  expr: Comma
180
184
  exprs:
181
185
  - FloatLiteral
182
186
  val: 12340000.0
187
+ exponent: 5
183
188
  - FloatLiteral
184
189
  val: 1.23e-08
190
+ exponent: -10
185
191
  - ExpressionStatement
186
192
  expr: Comma
187
193
  exprs:
188
194
  - FloatLiteral
189
195
  format: hex
190
196
  val: 684.0
197
+ exponent: 2
191
198
  - FloatLiteral
192
199
  format: hex
193
200
  val: 2.68359375
201
+ exponent: -10
194
202
  - ExpressionStatement
195
203
  expr: Comma
196
204
  exprs:
197
205
  - FloatLiteral
198
206
  format: hex
199
207
  val: 21990.5
208
+ exponent: 3
200
209
  - FloatLiteral
201
210
  format: hex
202
211
  val: 1.341796875
212
+ exponent: -11
203
213
  - ExpressionStatement
204
214
  expr: Comma
205
215
  exprs:
206
216
  - FloatLiteral
207
217
  format: hex
208
218
  val: 43981.0
219
+ exponent: 4
209
220
  - FloatLiteral
210
221
  format: hex
211
222
  val: 0.6708984375
223
+ exponent: -12
212
224
  EOS
213
- assert_raise(C::ParseError){C::Parser.new.parse('void f() {0x123.4pa;}')}
225
+ assert_raises(C::ParseError){C::Parser.new.parse('void f() {0x123.4pa;}')}
214
226
  end
215
227
  def test_string_literal
216
228
  check <<EOS
@@ -269,7 +281,7 @@ TranslationUnit
269
281
  prefix: "L"
270
282
  val: "a\\nb"
271
283
  EOS
272
- assert_raise(C::ParseError){C::Parser.new.parse('void f() {xy"ab";}')}
284
+ assert_raises(C::ParseError){C::Parser.new.parse('void f() {xy"ab";}')}
273
285
  end
274
286
  def test_char_literal
275
287
  check <<EOS
@@ -318,6 +330,6 @@ TranslationUnit
318
330
  prefix: "L"
319
331
  val: "\\n"
320
332
  EOS
321
- assert_raise(C::ParseError){C::Parser.new.parse("void f() {xy'ab';}")}
333
+ assert_raises(C::ParseError){C::Parser.new.parse("void f() {xy'ab';}")}
322
334
  end
323
335
  end
@@ -243,7 +243,7 @@ module NodeListEqualTest
243
243
  assert(a.eql?(b))
244
244
  assert(a.hash == b.hash)
245
245
  end
246
- def assert_not_eq(a, b)
246
+ def refute_eq(a, b)
247
247
  assert(!(a == b))
248
248
  assert(!a.eql?(b))
249
249
  end
@@ -256,12 +256,12 @@ module NodeListEqualTest
256
256
  assert_eq(two_by_four, two_by_four)
257
257
  assert_eq(big, big)
258
258
 
259
- assert_not_eq(empty, one)
260
- assert_not_eq(one, empty)
261
- assert_not_eq(one, two)
262
- assert_not_eq(two, one)
263
- assert_not_eq(two, three)
264
- 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)
265
265
 
266
266
  # []
267
267
  empty2 = _List[]
@@ -453,12 +453,12 @@ module NodeListChildManagementTests
453
453
  include NodeListTest
454
454
  def check_not_child(list, node)
455
455
  n = C::Int.new
456
- assert_raise(ArgumentError, list.node_before(node))
457
- assert_raise(ArgumentError, list.node_after(node))
458
- assert_raise(ArgumentError, list.remove_node(node))
459
- assert_raise(ArgumentError, list.insert_after(node, n))
460
- assert_raise(ArgumentError, list.insert_before(node, n))
461
- 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))
462
462
  end
463
463
 
464
464
  def check_list(list, *nodes)
@@ -1151,7 +1151,7 @@ module NodeListArrayQueryTests
1151
1151
  assert_same_list([a1, a2, a3], a.first(4))
1152
1152
 
1153
1153
  # negative array size
1154
- assert_raise(ArgumentError){a.first(-1)}
1154
+ assert_raises(ArgumentError){a.first(-1)}
1155
1155
  end
1156
1156
 
1157
1157
  def test_last
@@ -1188,7 +1188,7 @@ module NodeListArrayQueryTests
1188
1188
  assert_same_list([a1, a2, a3], a.last(4))
1189
1189
 
1190
1190
  # negative array size
1191
- assert_raise(ArgumentError){a.last(-1)}
1191
+ assert_raises(ArgumentError){a.last(-1)}
1192
1192
  end
1193
1193
 
1194
1194
  # ------------------------------------------------------------------
@@ -1792,7 +1792,7 @@ module NodeListModifierTests
1792
1792
  # too many args
1793
1793
  a, b = 2.of{C::Int.new}
1794
1794
  list = _List[a, b]
1795
- assert_raise(ArgumentError){list.pop(1, 2)}
1795
+ assert_raises(ArgumentError){list.pop(1, 2)}
1796
1796
  assert_same_list([a, b], list)
1797
1797
  assert_same(list, a.parent)
1798
1798
  assert_same(list, b.parent)
@@ -1929,7 +1929,7 @@ module NodeListModifierTests
1929
1929
  # too many args
1930
1930
  a, b = 2.of{C::Int.new}
1931
1931
  list = _List[a, b]
1932
- assert_raise(ArgumentError){list.shift(1, 2)}
1932
+ assert_raises(ArgumentError){list.shift(1, 2)}
1933
1933
  assert_same_list([a, b], list)
1934
1934
  assert_same(list, a.parent)
1935
1935
  assert_same(list, b.parent)
@@ -2462,7 +2462,7 @@ NodeListTest.submodules.each do |test_module|
2462
2462
  %w[NodeArray NodeChain].each do |list_class|
2463
2463
  test_class = test_module.name.sub(/^NodeList/, list_class)
2464
2464
  eval "
2465
- class #{test_class} < Test::Unit::TestCase
2465
+ class #{test_class} < Minitest::Test
2466
2466
  def _List
2467
2467
  C::#{list_class}
2468
2468
  end
@@ -38,7 +38,7 @@ class V < C::Node
38
38
  initializer :a
39
39
  end
40
40
 
41
- class NodeInitializeTest < Test::Unit::TestCase
41
+ class NodeInitializeTest < Minitest::Test
42
42
 
43
43
  # ------------------------------------------------------------------
44
44
  # initialize
@@ -94,7 +94,7 @@ class NodeInitializeTest < Test::Unit::TestCase
94
94
  end
95
95
  end
96
96
 
97
- class NodeEqualTest < Test::Unit::TestCase
97
+ class NodeEqualTest < Minitest::Test
98
98
  def str
99
99
  "(struct s){.a = 1, [2] = {3, 4}, .b [5] = 6, 7}"
100
100
  end
@@ -108,7 +108,7 @@ class NodeEqualTest < Test::Unit::TestCase
108
108
  five = C::IntLiteral.new(5)
109
109
  six = C::IntLiteral.new(6)
110
110
  seven = C::IntLiteral.new(7)
111
-
111
+
112
112
  mi0 = C::MemberInit.new(Chain[ma], one)
113
113
  mi10 = C::MemberInit.new(nil, three)
114
114
  mi11 = C::MemberInit.new(nil, four)
@@ -134,42 +134,42 @@ class NodeEqualTest < Test::Unit::TestCase
134
134
  # change any one field and it should be not_equal
135
135
  n = node
136
136
  n.type = nil
137
- assert_not_equal(node, n)
137
+ refute_equal(node, n)
138
138
  assert(!node.eql?(n))
139
139
 
140
140
  n = node
141
141
  n.member_inits[0].member[0] = C::Member.new('c')
142
- assert_not_equal(node, n)
142
+ refute_equal(node, n)
143
143
  assert(!node.eql?(n))
144
144
  copy = node.dup
145
145
 
146
146
  n = node
147
147
  n.member_inits[2].member[1] = C::IntLiteral.new(8)
148
- assert_not_equal(node, n)
148
+ refute_equal(node, n)
149
149
  assert(!node.eql?(n))
150
150
 
151
151
  # add a member's init and it should be not_equal
152
152
  n = node
153
153
  n.member_inits[3].init = C::IntLiteral.new(9)
154
- assert_not_equal(node, n)
154
+ refute_equal(node, n)
155
155
  assert(!node.eql?(n))
156
156
 
157
157
  # change a member's init and it should be not_equal
158
158
  n = node
159
159
  n.member_inits[0].init = C::IntLiteral.new(10)
160
- assert_not_equal(node, n)
160
+ refute_equal(node, n)
161
161
  assert(!node.eql?(n))
162
162
 
163
163
  # add a member specifier and it should be not_equal
164
164
  n = node
165
165
  n.member_inits[3].member = Chain[C::Member.new('d')]
166
- assert_not_equal(node, n)
166
+ refute_equal(node, n)
167
167
  assert(!node.eql?(n))
168
168
 
169
169
  # pop a member and it should be not_equal
170
170
  n = node
171
171
  n.member_inits.pop
172
- assert_not_equal(node, n)
172
+ refute_equal(node, n)
173
173
  assert(!node.eql?(n))
174
174
 
175
175
  # assign a field a copy of what's there and it should still be
@@ -205,7 +205,7 @@ class NodeEqualTest < Test::Unit::TestCase
205
205
  end
206
206
  end
207
207
 
208
- class NodeCopyTest < Test::Unit::TestCase
208
+ class NodeCopyTest < Minitest::Test
209
209
  def setup
210
210
  # (struct s){.a = 1, [2] = {3, 4}, .b [5] = 6, 7}
211
211
 
@@ -273,12 +273,12 @@ class NodeCopyTest < Test::Unit::TestCase
273
273
  assert_same(value, dres)
274
274
  assert_same(value, eres)
275
275
  end
276
- assert_raise(NoMethodError){dres.new_method}
276
+ assert_raises(NoMethodError){dres.new_method}
277
277
  case value.object_id
278
278
  when @c.object_id, @c_mis1_i_mis0.object_id
279
279
  assert_same(100, eres.new_method)
280
280
  else
281
- assert_raise(NoMethodError){eres.new_method}
281
+ assert_raises(NoMethodError){eres.new_method}
282
282
  end
283
283
  end
284
284
 
@@ -331,7 +331,7 @@ class NodeCopyTest < Test::Unit::TestCase
331
331
  end
332
332
  end
333
333
 
334
- class NodeWalkTest < Test::Unit::TestCase
334
+ class NodeWalkTest < Minitest::Test
335
335
  #
336
336
  # Collect and return the args yielded to `node.send(method)' as an
337
337
  # Array, each element of which is an array of args yielded.
@@ -800,8 +800,8 @@ class NodeWalkTest < Test::Unit::TestCase
800
800
 
801
801
  # no parent
802
802
  i = C::Int.new
803
- assert_raise(C::Node::NoParent){i.next}
804
- assert_raise(C::Node::NoParent){i.prev}
803
+ assert_raises(C::Node::NoParent){i.next}
804
+ assert_raises(C::Node::NoParent){i.prev}
805
805
  end
806
806
 
807
807
  def test_list_next_prev
@@ -818,19 +818,19 @@ class NodeWalkTest < Test::Unit::TestCase
818
818
  i1 = C::IntLiteral.new(1)
819
819
  i2 = C::IntLiteral.new(2)
820
820
  a = C::Add.new(i1, i2)
821
- assert_raise(C::Node::BadParent){i1.list_next}
822
- assert_raise(C::Node::BadParent){i2.list_next}
823
- assert_raise(C::Node::BadParent){i1.list_prev}
824
- assert_raise(C::Node::BadParent){i2.list_prev}
821
+ assert_raises(C::Node::BadParent){i1.list_next}
822
+ assert_raises(C::Node::BadParent){i2.list_next}
823
+ assert_raises(C::Node::BadParent){i1.list_prev}
824
+ assert_raises(C::Node::BadParent){i2.list_prev}
825
825
 
826
826
  # no parent
827
827
  i = C::Int.new
828
- assert_raise(C::Node::NoParent){i.list_next}
829
- assert_raise(C::Node::NoParent){i.list_prev}
828
+ assert_raises(C::Node::NoParent){i.list_next}
829
+ assert_raises(C::Node::NoParent){i.list_prev}
830
830
  end
831
831
  end
832
832
 
833
- class NodeTreeTest < Test::Unit::TestCase
833
+ class NodeTreeTest < Minitest::Test
834
834
  def setup
835
835
  # @c = "(int){[1] = 10,
836
836
  # .x = 20,
@@ -953,10 +953,10 @@ class NodeTreeTest < Test::Unit::TestCase
953
953
  assert_tree(mi)
954
954
  assert_same_list([mi1, mi2, mis[1], mis[2]], c.member_inits)
955
955
 
956
- assert_raise(C::Node::NoParent){mi.replace_with(nil)}
956
+ assert_raises(C::Node::NoParent){mi.replace_with(nil)}
957
957
  i1 = C::Int.new
958
958
  i2 = C::Int.new
959
- assert_raise(ArgumentError){c.type.replace_with(i1, i2)}
959
+ assert_raises(ArgumentError){c.type.replace_with(i1, i2)}
960
960
  end
961
961
 
962
962
  def test_node_swap_with
@@ -1015,9 +1015,9 @@ class NodeTreeTest < Test::Unit::TestCase
1015
1015
 
1016
1016
  def test_node_insert_next_detached
1017
1017
  x1, x2 = 2.of{X.new}
1018
- assert_raise(C::Node::NoParent){x1.insert_next}
1018
+ assert_raises(C::Node::NoParent){x1.insert_next}
1019
1019
  assert_nil(x1.parent)
1020
- assert_raise(C::Node::NoParent){x1.insert_next(x2)}
1020
+ assert_raises(C::Node::NoParent){x1.insert_next(x2)}
1021
1021
  assert_nil(x1.parent)
1022
1022
  assert_nil(x2.parent)
1023
1023
  end
@@ -1025,9 +1025,9 @@ class NodeTreeTest < Test::Unit::TestCase
1025
1025
  parent = X.new
1026
1026
  x1, x2 = 2.of{X.new}
1027
1027
  parent.a = x1
1028
- assert_raise(C::Node::BadParent){x1.insert_next}
1028
+ assert_raises(C::Node::BadParent){x1.insert_next}
1029
1029
  assert_same(parent, x1.parent)
1030
- assert_raise(C::Node::BadParent){x1.insert_next(x2)}
1030
+ assert_raises(C::Node::BadParent){x1.insert_next(x2)}
1031
1031
  assert_same(parent, x1.parent)
1032
1032
  assert_nil(x2.parent)
1033
1033
  end
@@ -1046,9 +1046,9 @@ class NodeTreeTest < Test::Unit::TestCase
1046
1046
 
1047
1047
  def test_node_insert_prev_detached
1048
1048
  a1, a2 = 2.of{X.new}
1049
- assert_raise(C::Node::NoParent){a1.insert_prev}
1049
+ assert_raises(C::Node::NoParent){a1.insert_prev}
1050
1050
  assert_nil(a1.parent)
1051
- assert_raise(C::Node::NoParent){a1.insert_prev(a2)}
1051
+ assert_raises(C::Node::NoParent){a1.insert_prev(a2)}
1052
1052
  assert_nil(a1.parent)
1053
1053
  assert_nil(a2.parent)
1054
1054
  end
@@ -1056,9 +1056,9 @@ class NodeTreeTest < Test::Unit::TestCase
1056
1056
  parent = X.new
1057
1057
  x1, x2 = 2.of{X.new}
1058
1058
  parent.a = x1
1059
- assert_raise(C::Node::BadParent){x1.insert_prev}
1059
+ assert_raises(C::Node::BadParent){x1.insert_prev}
1060
1060
  assert_same(parent, x1.parent)
1061
- assert_raise(C::Node::BadParent){x1.insert_prev(x2)}
1061
+ assert_raises(C::Node::BadParent){x1.insert_prev(x2)}
1062
1062
  assert_same(parent, x1.parent)
1063
1063
  assert_nil(x2.parent)
1064
1064
  end
@@ -1083,15 +1083,15 @@ class NodeTreeTest < Test::Unit::TestCase
1083
1083
  # node not a child
1084
1084
  x1, x2 = 2.of{X.new}
1085
1085
  parent = X.new(x1)
1086
- assert_raise(ArgumentError){parent.node_after(x2)}
1087
- assert_raise(ArgumentError){parent.node_before(x2)}
1086
+ assert_raises(ArgumentError){parent.node_after(x2)}
1087
+ assert_raises(ArgumentError){parent.node_before(x2)}
1088
1088
 
1089
1089
  x1, x2 = 2.of{X.new}
1090
1090
  parent = Z.new(nil, x1, nil, x2, nil)
1091
- assert_raise(ArgumentError){parent.node_after(x1)}
1092
- assert_raise(ArgumentError){parent.node_after(x2)}
1093
- assert_raise(ArgumentError){parent.node_before(x1)}
1094
- assert_raise(ArgumentError){parent.node_before(x2)}
1091
+ assert_raises(ArgumentError){parent.node_after(x1)}
1092
+ assert_raises(ArgumentError){parent.node_after(x2)}
1093
+ assert_raises(ArgumentError){parent.node_before(x1)}
1094
+ assert_raises(ArgumentError){parent.node_before(x2)}
1095
1095
 
1096
1096
  # one child
1097
1097
  x = X.new
@@ -1127,8 +1127,8 @@ class NodeTreeTest < Test::Unit::TestCase
1127
1127
  # node not a child
1128
1128
  x1, x2, x3 = 3.of{X.new}
1129
1129
  parent = Z.new(x1, x2)
1130
- assert_raise(ArgumentError){parent.remove_node(x2)}
1131
- assert_raise(ArgumentError){parent.remove_node(x3)}
1130
+ assert_raises(ArgumentError){parent.remove_node(x2)}
1131
+ assert_raises(ArgumentError){parent.remove_node(x3)}
1132
1132
 
1133
1133
  # one child
1134
1134
  x = X.new
@@ -1151,8 +1151,8 @@ class NodeTreeTest < Test::Unit::TestCase
1151
1151
  # node not a child
1152
1152
  x1, x2, x3, x4 = 3.of{X.new}
1153
1153
  parent = Z.new(x1, x2)
1154
- assert_raise(ArgumentError){parent.replace_node(x2, x4)}
1155
- assert_raise(ArgumentError){parent.replace_node(x3, x4)}
1154
+ assert_raises(ArgumentError){parent.replace_node(x2, x4)}
1155
+ assert_raises(ArgumentError){parent.replace_node(x3, x4)}
1156
1156
 
1157
1157
  # no newnode
1158
1158
  x = X.new
@@ -1165,7 +1165,7 @@ class NodeTreeTest < Test::Unit::TestCase
1165
1165
  # >1 newnode
1166
1166
  x1, x2, x3 = 3.of{X.new}
1167
1167
  parent = X.new(x1)
1168
- assert_raise(ArgumentError){parent.replace_node(x1, x2, x3)}
1168
+ assert_raises(ArgumentError){parent.replace_node(x1, x2, x3)}
1169
1169
 
1170
1170
  # one child
1171
1171
  x1, x2 = 2.of{X.new}