rltk 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +21 -22
  3. data/lib/rltk/ast.rb +185 -118
  4. data/lib/rltk/cfg.rb +157 -103
  5. data/lib/rltk/cg/basic_block.rb +19 -19
  6. data/lib/rltk/cg/bindings.rb +16 -16
  7. data/lib/rltk/cg/builder.rb +129 -129
  8. data/lib/rltk/cg/context.rb +7 -7
  9. data/lib/rltk/cg/contractor.rb +7 -7
  10. data/lib/rltk/cg/execution_engine.rb +30 -30
  11. data/lib/rltk/cg/function.rb +37 -37
  12. data/lib/rltk/cg/generated_bindings.rb +3932 -3932
  13. data/lib/rltk/cg/generic_value.rb +17 -17
  14. data/lib/rltk/cg/instruction.rb +116 -116
  15. data/lib/rltk/cg/llvm.rb +22 -22
  16. data/lib/rltk/cg/memory_buffer.rb +7 -7
  17. data/lib/rltk/cg/module.rb +73 -73
  18. data/lib/rltk/cg/pass_manager.rb +35 -35
  19. data/lib/rltk/cg/target.rb +41 -41
  20. data/lib/rltk/cg/triple.rb +7 -7
  21. data/lib/rltk/cg/type.rb +75 -75
  22. data/lib/rltk/cg/value.rb +161 -161
  23. data/lib/rltk/lexer.rb +57 -57
  24. data/lib/rltk/lexers/calculator.rb +7 -7
  25. data/lib/rltk/lexers/ebnf.rb +5 -5
  26. data/lib/rltk/parser.rb +338 -295
  27. data/lib/rltk/parsers/infix_calc.rb +7 -7
  28. data/lib/rltk/parsers/postfix_calc.rb +3 -3
  29. data/lib/rltk/parsers/prefix_calc.rb +3 -3
  30. data/lib/rltk/token.rb +13 -13
  31. data/lib/rltk/version.rb +6 -6
  32. data/test/cg/tc_basic_block.rb +17 -17
  33. data/test/cg/tc_control_flow.rb +41 -41
  34. data/test/cg/tc_function.rb +4 -4
  35. data/test/cg/tc_generic_value.rb +3 -3
  36. data/test/cg/tc_instruction.rb +53 -53
  37. data/test/cg/tc_math.rb +12 -12
  38. data/test/cg/tc_module.rb +14 -14
  39. data/test/cg/tc_transforms.rb +11 -11
  40. data/test/cg/tc_type.rb +12 -12
  41. data/test/cg/tc_value.rb +35 -35
  42. data/test/cg/ts_cg.rb +5 -5
  43. data/test/tc_ast.rb +137 -60
  44. data/test/tc_cfg.rb +34 -34
  45. data/test/tc_lexer.rb +42 -42
  46. data/test/tc_parser.rb +250 -173
  47. data/test/tc_token.rb +2 -2
  48. data/test/ts_rltk.rb +8 -8
  49. metadata +84 -85
  50. data/lib/rltk/cg/old_generated_bindings.rb +0 -6152
@@ -21,46 +21,46 @@ require 'rltk/cg/value'
21
21
  class TransformTester < Minitest::Test
22
22
  def setup
23
23
  RLTK::CG::LLVM.init(:X86)
24
-
24
+
25
25
  @mod = RLTK::CG::Module.new('Testing Module')
26
26
  @jit = RLTK::CG::JITCompiler.new(@mod)
27
27
  end
28
-
28
+
29
29
  def test_gdce
30
30
  fn0 = @mod.functions.add('fn0', RLTK::CG::VoidType, []) do |fun|
31
31
  fun.linkage = :internal
32
-
32
+
33
33
  blocks.append do
34
34
  ret_void
35
35
  end
36
36
  end
37
-
37
+
38
38
  fn1 = @mod.functions.add('fn1', RLTK::CG::VoidType, []) do |fun|
39
39
  fun.linkage = :internal
40
-
40
+
41
41
  blocks.append do
42
42
  ret_void
43
43
  end
44
44
  end
45
-
45
+
46
46
  main = @mod.functions.add('main', RLTK::CG::VoidType, []) do
47
47
  blocks.append do
48
48
  call(fn0)
49
49
  ret_void
50
50
  end
51
51
  end
52
-
52
+
53
53
  funs = @mod.functions.to_a
54
-
54
+
55
55
  assert(funs.include?(fn0))
56
56
  assert(funs.include?(fn1))
57
57
  assert(funs.include?(main))
58
-
58
+
59
59
  @mod.pass_manager << :GDCE
60
60
  assert(@mod.pass_manager.run)
61
-
61
+
62
62
  funs = @mod.functions.to_a
63
-
63
+
64
64
  assert( funs.include?(fn0))
65
65
  assert(!funs.include?(fn1))
66
66
  assert( funs.include?(main))
@@ -19,48 +19,48 @@ class TypeTester < Minitest::Test
19
19
  @pointee = RLTK::CG::NativeIntType.instance
20
20
  @pointer = RLTK::CG::PointerType.new(@pointee)
21
21
  end
22
-
22
+
23
23
  def test_deferrent_element_type_stuct_type
24
24
  type = RLTK::CG::StructType.new([], 'test_struct')
25
25
  type.element_types = [RLTK::CG::NativeIntType, RLTK::CG::FloatType]
26
-
26
+
27
27
  assert_equal(2, type.element_types.size)
28
28
  assert_equal(RLTK::CG::NativeIntType.instance, type.element_types[0])
29
29
  assert_equal(RLTK::CG::FloatType.instance, type.element_types[1])
30
-
30
+
31
31
  end
32
-
32
+
33
33
  def test_element_type
34
34
  assert_equal(@pointee, @pointer.element_type)
35
35
  end
36
-
36
+
37
37
  def test_equality
38
38
  assert_equal(RLTK::CG::NativeIntType, RLTK::CG::NativeIntType)
39
39
  refute_equal(RLTK::CG::NativeIntType, RLTK::CG::FloatType)
40
-
40
+
41
41
  at0 = RLTK::CG::ArrayType.new(RLTK::CG::NativeIntType, 2)
42
42
  at1 = RLTK::CG::ArrayType.new(RLTK::CG::NativeIntType, 2)
43
43
  at2 = RLTK::CG::ArrayType.new(RLTK::CG::FloatType, 2)
44
-
44
+
45
45
  assert_equal(at0, at1)
46
46
  refute_equal(at0, at2)
47
47
  end
48
-
48
+
49
49
  def test_kind
50
50
  assert_equal(:pointer, @pointer.kind)
51
51
  assert_equal(:integer, @pointee.kind)
52
52
  end
53
-
53
+
54
54
  def test_named_struct_type
55
55
  type = RLTK::CG::StructType.new([RLTK::CG::NativeIntType, RLTK::CG::FloatType], 'test_struct')
56
-
56
+
57
57
  assert_instance_of(RLTK::CG::StructType, type)
58
58
  assert_equal('test_struct', type.name)
59
59
  end
60
-
60
+
61
61
  def test_simple_struct_type
62
62
  type = RLTK::CG::StructType.new([RLTK::CG::NativeIntType, RLTK::CG::FloatType])
63
-
63
+
64
64
  assert_instance_of(RLTK::CG::StructType, type)
65
65
  assert_equal(2, type.element_types.size)
66
66
  assert_equal(RLTK::CG::NativeIntType.instance, type.element_types[0])
@@ -21,130 +21,130 @@ require 'rltk/cg/value'
21
21
  class ValueTester < Minitest::Test
22
22
  def setup
23
23
  RLTK::CG::LLVM.init(:X86)
24
-
24
+
25
25
  @mod = RLTK::CG::Module.new('Testing Module')
26
26
  @jit = RLTK::CG::JITCompiler.new(@mod)
27
27
  end
28
-
28
+
29
29
  def test_array_values
30
30
  fun = @mod.functions.add('array_function_tester', RLTK::CG::NativeIntType,
31
31
  [RLTK::CG::NativeIntType, RLTK::CG::NativeIntType]) do |fun|
32
-
32
+
33
33
  blocks.append do
34
34
  ptr = alloca(RLTK::CG::ArrayType.new(RLTK::CG::NativeIntType, 2))
35
-
35
+
36
36
  array = load(ptr)
37
37
  array = insert_value(array, fun.params[0], 0)
38
38
  array = insert_value(array, fun.params[1], 1)
39
-
39
+
40
40
  ret(add(extract_value(array, 0), extract_value(array, 1)))
41
41
  end
42
42
  end
43
-
43
+
44
44
  assert_equal(5, @jit.run_function(fun, 2, 3).to_i)
45
45
  end
46
-
46
+
47
47
  def test_constant_array_from_array
48
48
  array = RLTK::CG::ConstantArray.new(RLTK::CG::NativeIntType, [RLTK::CG::NativeInt.new(0), RLTK::CG::NativeInt.new(1)])
49
-
49
+
50
50
  assert_instance_of(RLTK::CG::ConstantArray, array)
51
51
  assert_equal(2, array.length)
52
52
  end
53
-
53
+
54
54
  def test_constant_array_from_size
55
55
  array = RLTK::CG::ConstantArray.new(RLTK::CG::NativeIntType, 2) { |i| RLTK::CG::NativeInt.new(i) }
56
-
56
+
57
57
  assert_instance_of(RLTK::CG::ConstantArray, array)
58
58
  assert_equal(2, array.length)
59
59
  end
60
-
60
+
61
61
  def test_constant_vector_elements
62
62
  fun = @mod.functions.add('constant_vector_elements_tester', RLTK::CG::NativeIntType,
63
63
  [RLTK::CG::NativeIntType, RLTK::CG::NativeIntType]) do |fun|
64
-
64
+
65
65
  blocks.append do
66
66
  ptr = alloca(RLTK::CG::VectorType.new(RLTK::CG::NativeIntType, 2))
67
-
67
+
68
68
  vector = load(ptr)
69
69
  vector = insert_element(vector, fun.params[0], RLTK::CG::NativeInt.new(0))
70
70
  vector = insert_element(vector, fun.params[1], RLTK::CG::NativeInt.new(1))
71
-
71
+
72
72
  ret(add(extract_element(vector, RLTK::CG::NativeInt.new(0)), extract_element(vector, RLTK::CG::NativeInt.new(1))))
73
73
  end
74
74
  end
75
-
75
+
76
76
  assert_equal(5, @jit.run_function(fun, 2, 3).to_i)
77
77
  end
78
-
78
+
79
79
  def test_constant_vector_from_array
80
80
  vector = RLTK::CG::ConstantVector.new([RLTK::CG::NativeInt.new(0), RLTK::CG::NativeInt.new(1)])
81
-
81
+
82
82
  assert_instance_of(RLTK::CG::ConstantVector, vector)
83
83
  assert_equal(2, vector.size)
84
84
  end
85
-
85
+
86
86
  def test_constant_vector_from_size
87
87
  vector = RLTK::CG::ConstantVector.new(2) { |i| RLTK::CG::NativeInt.new(i) }
88
-
88
+
89
89
  assert_instance_of(RLTK::CG::ConstantVector, vector)
90
90
  assert_equal(2, vector.size)
91
91
  end
92
-
92
+
93
93
  def test_constant_vector_shuffle
94
94
  fun = @mod.functions.add('constant_vector_shuffle_tester', RLTK::CG::NativeIntType, Array.new(4, RLTK::CG::NativeIntType)) do |fun|
95
95
  blocks.append do
96
96
  vec_type = RLTK::CG::VectorType.new(RLTK::CG::NativeIntType, 2)
97
-
97
+
98
98
  v0 = load(alloca(vec_type))
99
99
  v0 = insert_element(v0, fun.params[0], RLTK::CG::NativeInt.new(0))
100
100
  v0 = insert_element(v0, fun.params[1], RLTK::CG::NativeInt.new(1))
101
-
101
+
102
102
  v1 = load(alloca(vec_type))
103
103
  v1 = insert_element(v1, fun.params[2], RLTK::CG::NativeInt.new(0))
104
104
  v1 = insert_element(v1, fun.params[3], RLTK::CG::NativeInt.new(1))
105
-
105
+
106
106
  v2 = shuffle_vector(v0, v1, RLTK::CG::ConstantVector.new([RLTK::CG::NativeInt.new(0), RLTK::CG::NativeInt.new(3)]))
107
-
107
+
108
108
  ret(add(extract_element(v2, RLTK::CG::NativeInt.new(0)), extract_element(v2, RLTK::CG::NativeInt.new(1))))
109
109
  end
110
110
  end
111
-
111
+
112
112
  assert_equal(5, @jit.run_function(fun, 1, 2, 3, 4).to_i)
113
113
  end
114
-
114
+
115
115
  def test_constant_struct_from_size_packed
116
116
  struct = RLTK::CG::ConstantStruct.new(2, true) { |i| RLTK::CG::NativeInt.new(i) }
117
-
117
+
118
118
  assert_instance_of(RLTK::CG::ConstantStruct, struct)
119
119
  assert_equal(2, struct.operands.size)
120
120
  end
121
-
121
+
122
122
  def test_constant_struct_from_size_unpacked
123
123
  struct = RLTK::CG::ConstantStruct.new(2, false) { |i| RLTK::CG::NativeInt.new(i) }
124
-
124
+
125
125
  assert_instance_of(RLTK::CG::ConstantStruct, struct)
126
126
  assert_equal(2, struct.operands.size)
127
127
  end
128
-
128
+
129
129
  def test_constant_struct_from_values_packed
130
130
  struct = RLTK::CG::ConstantStruct.new([RLTK::CG::NativeInt.new(0), RLTK::CG::NativeInt.new(1)], true)
131
-
131
+
132
132
  assert_instance_of(RLTK::CG::ConstantStruct, struct)
133
133
  assert_equal(2, struct.operands.size)
134
134
  end
135
-
135
+
136
136
  def test_constant_struct_from_values_unpacked
137
137
  struct = RLTK::CG::ConstantStruct.new([RLTK::CG::NativeInt.new(0), RLTK::CG::NativeInt.new(1)], false)
138
-
138
+
139
139
  assert_instance_of(RLTK::CG::ConstantStruct, struct)
140
140
  assert_equal(2, struct.operands.size)
141
141
  end
142
-
142
+
143
143
  def test_equality
144
144
  v0 = RLTK::CG::NativeInt.new(0)
145
145
  v1 = RLTK::CG::NativeInt.new(1)
146
146
  v2 = RLTK::CG::NativeInt.new(v0.ptr)
147
-
147
+
148
148
  assert_equal(v0, v2)
149
149
  refute_equal(v0, v1)
150
150
  end
@@ -1,8 +1,8 @@
1
- # Author: Chris Wailes <chris.wailes@gmail.com>
2
- # Project: Ruby Language Toolkit
3
- # Date: 2012/05/04
4
- # Description: This file contains test suit for the RLTK LLVM bindigns. It
5
- # requires the individual tests from their respective files.
1
+ # Author: Chris Wailes <chris.wailes@gmail.com>
2
+ # Project: Ruby Language Toolkit
3
+ # Date: 2012/05/04
4
+ # Description: This file contains test suit for the RLTK LLVM bindigns. It
5
+ # requires the individual tests from their respective files.
6
6
 
7
7
  ############
8
8
  # Requires #
@@ -27,35 +27,71 @@ class ASTNodeTester < Minitest::Test
27
27
  class CNode < ANode; end
28
28
 
29
29
  class DNode < RLTK::ASTNode; end
30
-
30
+
31
31
  class ENode < RLTK::ASTNode
32
32
  value :str, String
33
33
  end
34
-
34
+
35
35
  class FNode < ENode
36
36
  child :c, [ENode]
37
37
  end
38
-
38
+
39
39
  class SNode < RLTK::ASTNode
40
40
  value :string, String
41
-
41
+
42
42
  child :left, SNode
43
43
  child :right, SNode
44
44
  end
45
-
45
+
46
46
  class VNode < RLTK::ASTNode
47
47
  value :a, Integer
48
48
  value :b, Integer
49
49
  end
50
-
50
+
51
+ class ONode < RLTK::ASTNode
52
+ value :a, Integer
53
+ value :b, Integer, true
54
+ value :c, Integer
55
+ end
56
+
57
+ class ValuesFirstNode < RLTK::ASTNode
58
+ child :b, ValuesFirstNode
59
+ value :a, Integer
60
+ end
61
+
62
+ class ChildrenFirstNode < RLTK::ASTNode
63
+ order :children
64
+
65
+ value :b, Integer
66
+ child :a, ChildrenFirstNode
67
+ end
68
+
69
+ class DefOrderNode < RLTK::ASTNode
70
+ order :def
71
+
72
+ value :a, Integer
73
+ child :b, DefOrderNode
74
+ value :c, Float
75
+ end
76
+
77
+ class CustomOrderNode < RLTK::ASTNode
78
+ custom_order :a, :b, :c, :d
79
+
80
+ child :b, CustomOrderNode
81
+ child :d, CustomOrderNode
82
+
83
+ value :a, Integer
84
+ value :c, String
85
+ end
86
+
51
87
  def setup
52
88
  @leaf0 = CNode.new
53
89
  @tree0 = ANode.new(BNode.new(@leaf0), BNode.new)
54
-
90
+
55
91
  @tree1 = ANode.new(BNode.new(CNode.new), BNode.new)
56
92
  @tree2 = ANode.new(BNode.new, BNode.new(CNode.new))
57
93
  @tree3 = ANode.new(CNode.new(BNode.new), CNode.new)
58
-
94
+
59
95
  @tree4 = SNode.new('F',
60
96
  SNode.new('B',
61
97
  SNode.new('A'),
@@ -71,22 +107,22 @@ class ASTNodeTester < Minitest::Test
71
107
  )
72
108
  )
73
109
  )
74
-
110
+
75
111
  @tree5 = FNode.new('one',
76
112
  [FNode.new('two',
77
113
  [ENode.new('three')]),
78
114
  ENode.new('four')])
79
-
115
+
80
116
  @tree6 = FNode.new('one',
81
117
  [FNode.new('two',
82
118
  [ENode.new('three')]),
83
119
  ENode.new('four')])
84
-
120
+
85
121
  @tree7 = FNode.new('one!',
86
122
  [FNode.new('two!',
87
123
  [ENode.new('three!')]),
88
124
  ENode.new('four!')])
89
-
125
+
90
126
  @bc_proc = Proc.new do |n|
91
127
  case n
92
128
  when BNode then CNode.new(n.left, n.right)
@@ -95,125 +131,125 @@ class ASTNodeTester < Minitest::Test
95
131
  end
96
132
  end
97
133
  end
98
-
134
+
99
135
  def test_children
100
136
  node = ANode.new
101
-
137
+
102
138
  assert_equal(node.children, [nil, nil])
103
-
139
+
104
140
  node.children = (expected_children = [BNode.new, CNode.new])
105
-
141
+
106
142
  assert_equal(node.children, expected_children)
107
-
143
+
108
144
  node.children = (expected_children = {:left => CNode.new, :right => BNode.new})
109
-
145
+
110
146
  assert_equal(node.children(Hash), expected_children)
111
147
  end
112
-
148
+
113
149
  def test_copy
114
150
  new_tree = @tree5.copy
115
-
151
+
116
152
  assert_equal(@tree5, new_tree)
117
153
  end
118
-
154
+
119
155
  def test_dump
120
156
  tree0_string = @tree0.dump
121
-
157
+
122
158
  reloaded_tree = Marshal.load(tree0_string)
123
-
159
+
124
160
  assert_equal(@tree0, reloaded_tree)
125
161
  end
126
-
162
+
127
163
  def test_each
128
164
  # Test pre-order
129
165
  nodes = []
130
166
  expected = ['F', 'B', 'A', 'D', 'C', 'E', 'G', 'I', 'H']
131
167
  @tree4.each(:pre) { |n| nodes << n.string }
132
-
168
+
133
169
  assert_equal(expected, nodes)
134
-
170
+
135
171
  # Test post-order
136
172
  nodes = []
137
173
  expected = ['A', 'C', 'E', 'D', 'B', 'H', 'I', 'G', 'F']
138
174
  @tree4.each(:post) { |n| nodes << n.string }
139
-
175
+
140
176
  assert_equal(expected, nodes)
141
-
177
+
142
178
  # Test level-order
143
179
  nodes = []
144
180
  expected = ['F', 'B', 'G', 'A', 'D', 'I', 'C', 'E', 'H']
145
181
  @tree4.each(:level) { |n| nodes << n.string }
146
-
182
+
147
183
  assert_equal(expected, nodes)
148
-
184
+
149
185
  # Test iteration with array children.
150
-
186
+
151
187
  res = ''
152
188
  @tree5.each(:pre) { |node| res += ' ' + node.str }
153
189
  assert_equal(res, ' one two three four')
154
-
190
+
155
191
  res = ''
156
192
  @tree5.each(:post) { |node| res += ' ' + node.str }
157
193
  assert_equal(res, ' three two four one')
158
-
194
+
159
195
  res = ''
160
196
  @tree5.each(:level) { |node| res += ' ' + node.str }
161
197
  assert_equal(res, ' one two four three')
162
198
  end
163
-
199
+
164
200
  def test_equal
165
201
  assert_equal(@tree0, @tree1)
166
202
  refute_equal(@tree0, @tree2)
167
203
  end
168
-
204
+
169
205
  def test_initialize
170
206
  assert_raises(AbstractClassError) { RLTK::ASTNode.new }
171
-
207
+
172
208
  node = ENode.new { self.str = 'hello world' }
173
209
  assert_equal('hello world', node.str)
174
210
  end
175
-
211
+
176
212
  def test_map
177
213
  mapped_tree = @tree1.map(&@bc_proc)
178
-
214
+
179
215
  assert_equal(@tree0, @tree1)
180
216
  assert_equal(@tree3, mapped_tree)
181
-
217
+
182
218
  mapped_tree = @tree5.map do |c|
183
219
  c.str += '!'
184
-
220
+
185
221
  c
186
222
  end
187
-
223
+
188
224
  assert_equal(@tree6, @tree5)
189
225
  assert_equal(@tree7, mapped_tree)
190
226
  end
191
-
227
+
192
228
  def test_map!
193
229
  tree1_clone = @tree1.clone
194
230
  tree1_clone.map!(&@bc_proc)
195
-
231
+
196
232
  refute_equal(@tree1, tree1_clone)
197
233
  assert_equal(@tree3, tree1_clone)
198
-
234
+
199
235
  replace_node = BNode.new
200
236
  replace_node = replace_node.map!(&@bc_proc)
201
-
237
+
202
238
  assert_equal(CNode.new, replace_node)
203
-
239
+
204
240
  mapped_tree = @tree5.map! do |c|
205
241
  c.str += '!'
206
-
242
+
207
243
  c
208
244
  end
209
-
245
+
210
246
  refute_equal(@tree6, @tree5)
211
247
  assert_equal(@tree7, @tree5)
212
248
  end
213
-
249
+
214
250
  def test_notes
215
251
  node = ANode.new
216
-
252
+
217
253
  assert_nil(node[:a])
218
254
  assert_equal(node[:a] = :b, :b)
219
255
  assert_equal(node.note?(:a), true)
@@ -221,35 +257,76 @@ class ASTNodeTester < Minitest::Test
221
257
  assert_equal(node.delete_note(:a), :b)
222
258
  assert_nil(node[:a])
223
259
  end
224
-
260
+
261
+ def test_omit
262
+ onode = ONode.new(1, 3)
263
+
264
+ assert_equal(1, onode.a)
265
+ assert_nil(onode.b)
266
+ assert_equal(3, onode.c)
267
+ end
268
+
225
269
  def test_one_definition_rule
226
270
  asserter = self
227
-
271
+
228
272
  Class.new(ANode) do
229
273
  asserter.assert_raises(ArgumentError) { child :left, ANode }
230
274
  end
231
-
275
+
232
276
  Class.new(ENode) do
233
277
  asserter.assert_raises(ArgumentError) { value :str, String }
234
278
  end
235
279
  end
236
-
280
+
281
+ def test_ordering
282
+ vfn = ValuesFirstNode.new(42, ValuesFirstNode.new)
283
+
284
+ a, b = vfn.destructure(2)
285
+
286
+ assert_equal(42, a)
287
+ assert_instance_of(ValuesFirstNode, b)
288
+
289
+ cfn = ChildrenFirstNode.new(ChildrenFirstNode.new, 42)
290
+
291
+ a, b = cfn.destructure(2)
292
+
293
+ assert_instance_of(ChildrenFirstNode, a)
294
+ assert_equal(42, b)
295
+
296
+ dfn = DefOrderNode.new(4, DefOrderNode.new, 2.0)
297
+
298
+ a, b, c = dfn.destructure(3)
299
+
300
+ assert_equal(4, a)
301
+ assert_instance_of(DefOrderNode, b)
302
+ assert_equal(2.0, c)
303
+
304
+ con = CustomOrderNode.new(42, CustomOrderNode.new, 'foo')
305
+
306
+ a, b, c, d = con.destructure(4)
307
+
308
+ assert_equal(42, a)
309
+ assert_instance_of(CustomOrderNode, b)
310
+ assert_equal('foo', c)
311
+ assert_nil(d)
312
+ end
313
+
237
314
  def test_root
238
315
  assert_same(@tree0, @tree0.root)
239
316
  assert_same(@tree0, @leaf0.root)
240
317
  end
241
-
318
+
242
319
  def test_value
243
320
  node = VNode.new
244
-
321
+
245
322
  assert_equal(node.values, [nil, nil])
246
-
323
+
247
324
  node.values = (expected_values = [42, 1984])
248
-
325
+
249
326
  assert_equal(node.values, expected_values)
250
-
327
+
251
328
  node.values = (expected_values = {:a => 1984, :b => 42})
252
-
329
+
253
330
  assert_equal(node.values(Hash), expected_values)
254
331
  end
255
332
  end