proteus 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +674 -0
- data/README +88 -0
- data/Rakefile +33 -0
- data/bin/pro +189 -0
- data/lib/ClassParser.rb +84 -0
- data/lib/ComponentClass.rb +51 -0
- data/lib/ComponentInstance.rb +76 -0
- data/lib/DefinitionHelper.rb +157 -0
- data/lib/DefinitionParser.rb +107 -0
- data/lib/Facade.rb +116 -0
- data/lib/FileHelper.rb +80 -0
- data/lib/InputParser.rb +241 -0
- data/lib/InstanceParser.rb +65 -0
- data/lib/InstanceProxy.rb +100 -0
- data/lib/PropertyHash.rb +64 -0
- data/lib/TemplateRenderer.rb +128 -0
- data/lib/exceptions.rb +50 -0
- data/test/spec/ClassParser_spec.rb +314 -0
- data/test/spec/ComponentClass_spec.rb +44 -0
- data/test/spec/ComponentInstance_spec.rb +50 -0
- data/test/spec/DefinitionHelper_spec.rb +134 -0
- data/test/spec/DefinitionParser_spec.rb +236 -0
- data/test/spec/Facade_spec.rb +44 -0
- data/test/spec/FileHelper_spec.rb +113 -0
- data/test/spec/InputParser_spec.rb +424 -0
- data/test/spec/InstanceParser_spec.rb +125 -0
- data/test/spec/TemplateRenderer_spec.rb +54 -0
- data/test/spec/lib/NS1/TestComponent10.def +4 -0
- data/test/spec/lib/NS1/TestComponent11.def +4 -0
- data/test/spec/lib/NS1/TestComponent4.def +4 -0
- data/test/spec/lib/NS1/TestComponent5.def +4 -0
- data/test/spec/lib/NS1/TestComponent8.def +4 -0
- data/test/spec/lib/NS1/TestComponent9.def +4 -0
- data/test/spec/lib/NS2/TestComponent6.def +4 -0
- data/test/spec/lib/TestComponent1.def +4 -0
- data/test/spec/lib/TestComponent3.def +4 -0
- data/test/spec/test_lib_dir1/File1.def +0 -0
- data/test/spec/test_lib_dir1/File3.def +0 -0
- data/test/spec/test_lib_dir1/NS1/File4.def +0 -0
- data/test/spec/test_lib_dir1/NS1/NS2/File5.def +0 -0
- data/test/spec/test_lib_dir2/File1.def +0 -0
- data/test/spec/test_lib_dir2/File2.def +0 -0
- metadata +113 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
################################################################################
|
2
|
+
# (C) Copyright 2009 William Madden
|
3
|
+
#
|
4
|
+
# This file is part of Proteus.
|
5
|
+
#
|
6
|
+
# Proteus is free software: you can redistribute it and/or modify it under the
|
7
|
+
# terms of the GNU General Public License as published by the Free Software
|
8
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
9
|
+
# version.
|
10
|
+
#
|
11
|
+
# Proteus is distributed in the hope that it will be useful, but WITHOUT ANY
|
12
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along with
|
16
|
+
# Proteus. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
################################################################################
|
18
|
+
|
19
|
+
require File.expand_path( 'lib/Facade.rb' )
|
20
|
+
|
21
|
+
include Proteus
|
22
|
+
|
23
|
+
|
24
|
+
describe Facade do
|
25
|
+
|
26
|
+
#-----------------------------------------------------------------------------
|
27
|
+
#
|
28
|
+
# Input Constants
|
29
|
+
#
|
30
|
+
#-----------------------------------------------------------------------------
|
31
|
+
|
32
|
+
#-----------------------------------------------------------------------------
|
33
|
+
#
|
34
|
+
# Set up, tear down
|
35
|
+
#
|
36
|
+
#-----------------------------------------------------------------------------
|
37
|
+
|
38
|
+
#-----------------------------------------------------------------------------
|
39
|
+
#
|
40
|
+
# Tests
|
41
|
+
#
|
42
|
+
#-----------------------------------------------------------------------------
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
################################################################################
|
2
|
+
# (C) Copyright 2009 William Madden
|
3
|
+
#
|
4
|
+
# This file is part of Proteus.
|
5
|
+
#
|
6
|
+
# Proteus is free software: you can redistribute it and/or modify it under the
|
7
|
+
# terms of the GNU General Public License as published by the Free Software
|
8
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
9
|
+
# version.
|
10
|
+
#
|
11
|
+
# Proteus is distributed in the hope that it will be useful, but WITHOUT ANY
|
12
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along with
|
16
|
+
# Proteus. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
################################################################################
|
18
|
+
|
19
|
+
require File.expand_path( 'lib/FileHelper.rb' )
|
20
|
+
|
21
|
+
include Proteus
|
22
|
+
|
23
|
+
|
24
|
+
describe FileHelper do
|
25
|
+
|
26
|
+
#-----------------------------------------------------------------------------
|
27
|
+
#
|
28
|
+
# Input Constants
|
29
|
+
#
|
30
|
+
#-----------------------------------------------------------------------------
|
31
|
+
|
32
|
+
@@LIB_DIR_1 = "test/spec/test_lib_dir1"
|
33
|
+
@@LIB_DIR_2 = "test/spec/test_lib_dir2"
|
34
|
+
@@PATH = @@LIB_DIR_1 + ":" + @@LIB_DIR_2
|
35
|
+
|
36
|
+
# Correct answers
|
37
|
+
@@FILE_1_PATH = @@LIB_DIR_1 + "/File1.def"
|
38
|
+
@@FILE_2_PATH = @@LIB_DIR_2 + "/File2.def"
|
39
|
+
@@FILE_3_PATH = @@LIB_DIR_1 + "/File3.def"
|
40
|
+
@@FILE_4_PATH = @@LIB_DIR_1 + "/NS1/File4.def"
|
41
|
+
@@FILE_5_PATH = @@LIB_DIR_1 + "/NS1/NS2/File5.def"
|
42
|
+
|
43
|
+
#-----------------------------------------------------------------------------
|
44
|
+
#
|
45
|
+
# Tests
|
46
|
+
#
|
47
|
+
#-----------------------------------------------------------------------------
|
48
|
+
|
49
|
+
#
|
50
|
+
# Handle collisions - return first match.
|
51
|
+
#
|
52
|
+
it "should return the first matching file" do
|
53
|
+
|
54
|
+
# Search for "File1.def", it should be found in test_lib_dir1
|
55
|
+
file = FileHelper.find_file( 'File1.def', @@PATH )
|
56
|
+
|
57
|
+
file.should == @@FILE_1_PATH
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
#
|
63
|
+
# Search all paths.
|
64
|
+
#
|
65
|
+
it "should search all directories" do
|
66
|
+
|
67
|
+
# Search for "File2.def", it should be found in test_lib_dir2
|
68
|
+
file = FileHelper.find_file( 'File2.def', @@PATH )
|
69
|
+
|
70
|
+
file.should == @@FILE_2_PATH
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
#
|
76
|
+
# Search for definition with no namespaces.
|
77
|
+
#
|
78
|
+
it "should find definitions by classname" do
|
79
|
+
|
80
|
+
# Search for ["File3"]
|
81
|
+
file = FileHelper.find_definition( ['File3'], @@PATH )
|
82
|
+
|
83
|
+
file.should == @@FILE_3_PATH
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
#
|
89
|
+
# Search for definition nested under one namespace.
|
90
|
+
#
|
91
|
+
it "should find definitions with one namespace" do
|
92
|
+
|
93
|
+
# Search for ["NS1", "File4"]
|
94
|
+
file = FileHelper.find_definition( ['NS1', 'File4'], @@PATH )
|
95
|
+
|
96
|
+
file.should == @@FILE_4_PATH
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
#
|
102
|
+
# Search for definition nested by more than one namespace.
|
103
|
+
#
|
104
|
+
it "should find definitions with multiple namespaces" do
|
105
|
+
|
106
|
+
# Search for ["NS1", "NS2", "File5"]
|
107
|
+
file = FileHelper.find_definition( ['NS1', 'NS2', 'File5'], @@PATH )
|
108
|
+
|
109
|
+
file.should == @@FILE_5_PATH
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,424 @@
|
|
1
|
+
################################################################################
|
2
|
+
# (C) Copyright 2009 William Madden
|
3
|
+
#
|
4
|
+
# This file is part of Proteus.
|
5
|
+
#
|
6
|
+
# Proteus is free software: you can redistribute it and/or modify it under the
|
7
|
+
# terms of the GNU General Public License as published by the Free Software
|
8
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
9
|
+
# version.
|
10
|
+
#
|
11
|
+
# Proteus is distributed in the hope that it will be useful, but WITHOUT ANY
|
12
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along with
|
16
|
+
# Proteus. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
################################################################################
|
18
|
+
|
19
|
+
require File.expand_path( 'lib/InputParser.rb' )
|
20
|
+
|
21
|
+
include Proteus
|
22
|
+
|
23
|
+
|
24
|
+
describe InputParser do
|
25
|
+
|
26
|
+
#-----------------------------------------------------------------------------
|
27
|
+
#
|
28
|
+
# Input Constants
|
29
|
+
#
|
30
|
+
#-----------------------------------------------------------------------------
|
31
|
+
|
32
|
+
# Nil
|
33
|
+
|
34
|
+
@@NIL = nil
|
35
|
+
|
36
|
+
# Scalars
|
37
|
+
|
38
|
+
@@INVALID_SCALAR_COMPONENT = "not a component"
|
39
|
+
@@INVALID_SCALAR_COMPONENT2 = "Not A Component"
|
40
|
+
@@INVALID_SCALAR_COMPONENT3 = "Definitely Not Component"
|
41
|
+
|
42
|
+
@@KNOWN_SCALAR_COMPONENT = "TestComponent1"
|
43
|
+
@@KNOWN_SCALAR_COMPONENT2 = "TestComponent3"
|
44
|
+
|
45
|
+
@@UNKNOWN_SCALAR_COMPONENT = "TestComponent2"
|
46
|
+
|
47
|
+
@@COMPONENT_PROPERTIES = {
|
48
|
+
"prop1" => "val1",
|
49
|
+
"prop2" => "val2",
|
50
|
+
"prop3" => @@KNOWN_SCALAR_COMPONENT
|
51
|
+
}
|
52
|
+
|
53
|
+
# Hashes
|
54
|
+
|
55
|
+
@@KNOWN_COMPONENT_HASH = {
|
56
|
+
@@KNOWN_SCALAR_COMPONENT => @@COMPONENT_PROPERTIES
|
57
|
+
}
|
58
|
+
|
59
|
+
@@KNOWN_COMPONENT_HASH2 = {
|
60
|
+
@@KNOWN_SCALAR_COMPONENT2 => @@COMPONENT_PROPERTIES
|
61
|
+
}
|
62
|
+
|
63
|
+
@@INVALID_COMPONENT_HASH = {
|
64
|
+
@@INVALID_SCALAR_COMPONENT => @@COMPONENT_PROPERTIES
|
65
|
+
}
|
66
|
+
|
67
|
+
@@INVALID_COMPONENT_HASH2 = {
|
68
|
+
@@INVALID_SCALAR_COMPONENT2 => @@COMPONENT_PROPERTIES
|
69
|
+
}
|
70
|
+
|
71
|
+
@@UNKNOWN_COMPONENT_HASH = {
|
72
|
+
@@UNKNOWN_SCALAR_COMPONENT => @@COMPONENT_PROPERTIES
|
73
|
+
}
|
74
|
+
|
75
|
+
@@LONG_COMPONENT_HASH = {
|
76
|
+
@@KNOWN_SCALAR_COMPONENT => @@COMPONENT_PROPERTIES,
|
77
|
+
@@KNOWN_SCALAR_COMPONENT2 => @@COMPONENT_PROPERTIES
|
78
|
+
}
|
79
|
+
|
80
|
+
# Arrays
|
81
|
+
|
82
|
+
@@EMPTY_ARRAY = []
|
83
|
+
|
84
|
+
@@NONC_SCALAR_ARRAY = [ @@INVALID_SCALAR_COMPONENT ]
|
85
|
+
|
86
|
+
@@COMP_SCALAR_ARRAY = [ @@KNOWN_SCALAR_COMPONENT ]
|
87
|
+
|
88
|
+
@@MANY_NONC_SCALAR_ARRAY = [
|
89
|
+
@@INVALID_SCALAR_COMPONENT,
|
90
|
+
@@INVALID_SCALAR_COMPONENT2,
|
91
|
+
@@INVALID_SCALAR_COMPONENT3
|
92
|
+
]
|
93
|
+
|
94
|
+
@@MANY_COMP_SCALAR_ARRAY = [
|
95
|
+
@@KNOWN_SCALAR_COMPONENT,
|
96
|
+
@@KNOWN_SCALAR_COMPONENT2
|
97
|
+
]
|
98
|
+
|
99
|
+
@@MIXED_SCALAR_ARRAY = [
|
100
|
+
@@INVALID_SCALAR_COMPONENT,
|
101
|
+
@@KNOWN_SCALAR_COMPONENT,
|
102
|
+
@@INVALID_SCALAR_COMPONENT2,
|
103
|
+
@@KNOWN_SCALAR_COMPONENT2
|
104
|
+
]
|
105
|
+
|
106
|
+
@@NONC_HASH_ARRAY = [ @@INVALID_COMPONENT_HASH ]
|
107
|
+
@@COMP_HASH_ARRAY = [ @@KNOWN_COMPONENT_HASH ]
|
108
|
+
|
109
|
+
@@MANY_NONC_HASH_ARRAY = [
|
110
|
+
@@INVALID_COMPONENT_HASH,
|
111
|
+
@@INVALID_COMPONENT_HASH2,
|
112
|
+
@@INVALID_COMPONENT_HASH
|
113
|
+
]
|
114
|
+
@@MANY_COMP_HASH_ARRAY = [
|
115
|
+
@@KNOWN_COMPONENT_HASH,
|
116
|
+
@@KNOWN_COMPONENT_HASH2,
|
117
|
+
@@KNOWN_COMPONENT_HASH
|
118
|
+
]
|
119
|
+
|
120
|
+
@@MIXED_HASH_ARRAY = [
|
121
|
+
@@INVALID_COMPONENT_HASH,
|
122
|
+
@@KNOWN_COMPONENT_HASH,
|
123
|
+
@@INVALID_COMPONENT_HASH2,
|
124
|
+
@@KNOWN_COMPONENT_HASH2
|
125
|
+
]
|
126
|
+
|
127
|
+
@@MIXED_ARRAY = [
|
128
|
+
@@KNOWN_SCALAR_COMPONENT,
|
129
|
+
@@KNOWN_COMPONENT_HASH,
|
130
|
+
@@INVALID_SCALAR_COMPONENT,
|
131
|
+
@@INVALID_COMPONENT_HASH
|
132
|
+
]
|
133
|
+
|
134
|
+
#-----------------------------------------------------------------------------
|
135
|
+
#
|
136
|
+
# Set up, tear down
|
137
|
+
#
|
138
|
+
#-----------------------------------------------------------------------------
|
139
|
+
|
140
|
+
#------------------------------
|
141
|
+
# before(:all)
|
142
|
+
#------------------------------
|
143
|
+
|
144
|
+
before(:all) do
|
145
|
+
|
146
|
+
# Instance parser
|
147
|
+
@instance_parser = InstanceParser.new
|
148
|
+
|
149
|
+
# Class parser
|
150
|
+
@class_parser = ClassParser.new
|
151
|
+
|
152
|
+
# Definition parser
|
153
|
+
@definition_parser = DefinitionParser.new
|
154
|
+
@definition_parser.class_parser = @class_parser
|
155
|
+
|
156
|
+
# Definition helper
|
157
|
+
@definition_helper = DefinitionHelper.new
|
158
|
+
@definition_helper.definition_parser = @definition_parser
|
159
|
+
@definition_helper.path = "test/spec/lib"
|
160
|
+
|
161
|
+
@definition_parser.definition_helper = @definition_helper
|
162
|
+
|
163
|
+
# Input parser
|
164
|
+
@input_parser = InputParser.new
|
165
|
+
@input_parser.instance_parser = @instance_parser
|
166
|
+
@input_parser.definition_helper = @definition_helper
|
167
|
+
|
168
|
+
@definition_parser.input_parser = @input_parser
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
#-----------------------------------------------------------------------------
|
173
|
+
#
|
174
|
+
# Helper functions
|
175
|
+
#
|
176
|
+
#-----------------------------------------------------------------------------
|
177
|
+
|
178
|
+
def check_hash_parsed( hash )
|
179
|
+
hash.is_a?( Hash ).should == true
|
180
|
+
hash.length.should == 1
|
181
|
+
|
182
|
+
check_properties_parsed( hash.values[0] )
|
183
|
+
end
|
184
|
+
|
185
|
+
def check_properties_parsed( hash )
|
186
|
+
hash.length.should == 3
|
187
|
+
|
188
|
+
hash["prop1"].should == "val1"
|
189
|
+
hash["prop2"].should == "val2"
|
190
|
+
hash["prop3"].is_a?( ComponentInstance ).should == true
|
191
|
+
hash["prop3"].kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
192
|
+
end
|
193
|
+
|
194
|
+
#-----------------------------------------------------------------------------
|
195
|
+
#
|
196
|
+
# Tests
|
197
|
+
#
|
198
|
+
#-----------------------------------------------------------------------------
|
199
|
+
|
200
|
+
# Parse nil:
|
201
|
+
# nil
|
202
|
+
|
203
|
+
it "nil -> nil" do
|
204
|
+
result = @input_parser.parse_yaml( @@NIL )
|
205
|
+
result.should == @@NIL
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
# Parse scalar:
|
210
|
+
# invalid component name -> scalar
|
211
|
+
# valid, known component name -> component instance
|
212
|
+
# valid but unknown component name -> scalar
|
213
|
+
|
214
|
+
it "invalid component name -> scalar" do
|
215
|
+
result = @input_parser.parse_yaml( @@INVALID_SCALAR_COMPONENT )
|
216
|
+
result.should == @@INVALID_SCALAR_COMPONENT
|
217
|
+
end
|
218
|
+
|
219
|
+
it "valid, known component name -> component instance" do
|
220
|
+
result = @input_parser.parse_yaml( @@KNOWN_SCALAR_COMPONENT )
|
221
|
+
result.is_a?( ComponentInstance ).should == true
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
it "valid but unknown component name -> scalar" do
|
226
|
+
result = @input_parser.parse_yaml( @@UNKNOWN_SCALAR_COMPONENT )
|
227
|
+
result.should == @@UNKNOWN_SCALAR_COMPONENT
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
# Parse hash:
|
232
|
+
# length 1 with valid, known component name -> component instance
|
233
|
+
# length 1 with valid, unknown component name -> hash of parsed values
|
234
|
+
# length 1 with invalid component name -> hash of parsed values
|
235
|
+
# length > 1 -> hash of parsed values
|
236
|
+
|
237
|
+
it "length 1 with valid, known component name -> component instance" do
|
238
|
+
result = @input_parser.parse_yaml( @@KNOWN_COMPONENT_HASH )
|
239
|
+
|
240
|
+
result.is_a?( ComponentInstance ).should == true
|
241
|
+
result.kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
242
|
+
end
|
243
|
+
|
244
|
+
|
245
|
+
it "length 1 with valid, unknown component name -> hash of parsed values" do
|
246
|
+
result = @input_parser.parse_yaml( @@UNKNOWN_COMPONENT_HASH )
|
247
|
+
|
248
|
+
check_hash_parsed( result )
|
249
|
+
end
|
250
|
+
|
251
|
+
|
252
|
+
it "length 1 with invalid component name -> hash of parsed values" do
|
253
|
+
result = @input_parser.parse_yaml( @@INVALID_COMPONENT_HASH )
|
254
|
+
|
255
|
+
check_hash_parsed( result )
|
256
|
+
end
|
257
|
+
|
258
|
+
|
259
|
+
it "length > 1 -> hash of parsed values" do
|
260
|
+
result = @input_parser.parse_yaml( @@LONG_COMPONENT_HASH )
|
261
|
+
|
262
|
+
result.length.should == 2
|
263
|
+
|
264
|
+
result.keys[0].should == @@KNOWN_SCALAR_COMPONENT
|
265
|
+
result.keys[1].should == @@KNOWN_SCALAR_COMPONENT2
|
266
|
+
|
267
|
+
check_properties_parsed( result.values[0] )
|
268
|
+
check_properties_parsed( result.values[1] )
|
269
|
+
end
|
270
|
+
|
271
|
+
|
272
|
+
# Parse arrays:
|
273
|
+
# empty array -> empty array
|
274
|
+
# array of single, non-component scalar -> array of parsed values
|
275
|
+
# array of single, component scalar -> array of component instance
|
276
|
+
# array of many non-component scalars -> array of parsed values
|
277
|
+
# array of many component scalars -> array of component instances
|
278
|
+
# array of mixed scalars -> array of parsed values
|
279
|
+
# array of single, non-component hash -> array of parsed hash
|
280
|
+
# array of single, component hash -> array of component instance
|
281
|
+
# array of many non-component hashes -> array of parsed hashes
|
282
|
+
# array of many component hashes -> array of component instances
|
283
|
+
# array of mixed hashes -> array of parsed hashes
|
284
|
+
# array of mixed scalars and hashes -> array of parsed values
|
285
|
+
|
286
|
+
it "empty array -> empty array" do
|
287
|
+
result = @input_parser.parse_yaml( @@EMPTY_ARRAY )
|
288
|
+
result.should == @@EMPTY_ARRAY
|
289
|
+
end
|
290
|
+
|
291
|
+
|
292
|
+
it "array of single, non-component scalar -> array of parsed values" do
|
293
|
+
result = @input_parser.parse_yaml( @@NONC_SCALAR_ARRAY )
|
294
|
+
result.should == @@NONC_SCALAR_ARRAY
|
295
|
+
end
|
296
|
+
|
297
|
+
|
298
|
+
it "array of single, component scalar -> array of component instance" do
|
299
|
+
result = @input_parser.parse_yaml( @@COMP_SCALAR_ARRAY )
|
300
|
+
result.length.should == 1
|
301
|
+
result[0].is_a?( ComponentInstance ).should == true
|
302
|
+
result[0].kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
303
|
+
end
|
304
|
+
|
305
|
+
|
306
|
+
it "array of many non-component scalars -> array of parsed values" do
|
307
|
+
result = @input_parser.parse_yaml( @@MANY_NONC_SCALAR_ARRAY )
|
308
|
+
result.should == @@MANY_NONC_SCALAR_ARRAY
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
it "array of many component scalars -> array of component instances" do
|
313
|
+
result = @input_parser.parse_yaml( @@MANY_COMP_SCALAR_ARRAY )
|
314
|
+
|
315
|
+
result.length.should == 2
|
316
|
+
|
317
|
+
result[0].is_a?( ComponentInstance ).should == true
|
318
|
+
result[0].kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
319
|
+
|
320
|
+
result[1].is_a?( ComponentInstance ).should == true
|
321
|
+
result[1].kind.name.should == @@KNOWN_SCALAR_COMPONENT2
|
322
|
+
end
|
323
|
+
|
324
|
+
|
325
|
+
it "array of mixed scalars -> array of parsed values" do
|
326
|
+
result = @input_parser.parse_yaml( @@MIXED_SCALAR_ARRAY )
|
327
|
+
|
328
|
+
result.length.should == 4
|
329
|
+
|
330
|
+
result[0].should == @@INVALID_SCALAR_COMPONENT
|
331
|
+
|
332
|
+
result[1].is_a?( ComponentInstance ).should == true
|
333
|
+
result[1].kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
334
|
+
|
335
|
+
result[2].should == @@INVALID_SCALAR_COMPONENT2
|
336
|
+
|
337
|
+
result[3].is_a?( ComponentInstance ).should == true
|
338
|
+
result[3].kind.name.should == @@KNOWN_SCALAR_COMPONENT2
|
339
|
+
end
|
340
|
+
|
341
|
+
|
342
|
+
it "array of single, non-component hash -> array of parsed hash" do
|
343
|
+
result = @input_parser.parse_yaml( @@NONC_HASH_ARRAY )
|
344
|
+
result.length.should == 1
|
345
|
+
result[0].is_a?( Hash ).should == true
|
346
|
+
|
347
|
+
check_hash_parsed( result[0] )
|
348
|
+
end
|
349
|
+
|
350
|
+
|
351
|
+
it "array of single, component hash -> array of component instance" do
|
352
|
+
result = @input_parser.parse_yaml( @@COMP_HASH_ARRAY )
|
353
|
+
result.length.should == 1
|
354
|
+
result[0].is_a?( ComponentInstance ).should == true
|
355
|
+
result[0].kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
356
|
+
end
|
357
|
+
|
358
|
+
|
359
|
+
it "array of many non-component hashes -> array of parsed hashes" do
|
360
|
+
result = @input_parser.parse_yaml( @@MANY_NONC_HASH_ARRAY )
|
361
|
+
|
362
|
+
result.length.should == 3
|
363
|
+
|
364
|
+
result[0].is_a?( Hash ).should == true
|
365
|
+
result[1].is_a?( Hash ).should == true
|
366
|
+
result[2].is_a?( Hash ).should == true
|
367
|
+
|
368
|
+
check_hash_parsed( result[0] )
|
369
|
+
check_hash_parsed( result[1] )
|
370
|
+
check_hash_parsed( result[2] )
|
371
|
+
end
|
372
|
+
|
373
|
+
|
374
|
+
it "array of many component hashes -> array of component instances" do
|
375
|
+
result = @input_parser.parse_yaml( @@MANY_COMP_HASH_ARRAY )
|
376
|
+
|
377
|
+
result.length.should == 3
|
378
|
+
|
379
|
+
result[0].is_a?( ComponentInstance ).should == true
|
380
|
+
result[0].kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
381
|
+
result[1].is_a?( ComponentInstance ).should == true
|
382
|
+
result[1].kind.name.should == @@KNOWN_SCALAR_COMPONENT2
|
383
|
+
result[2].is_a?( ComponentInstance ).should == true
|
384
|
+
result[2].kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
385
|
+
end
|
386
|
+
|
387
|
+
|
388
|
+
it "array of mixed hashes -> array of parsed hashes" do
|
389
|
+
result = @input_parser.parse_yaml( @@MIXED_HASH_ARRAY )
|
390
|
+
|
391
|
+
result.length.should == 4
|
392
|
+
|
393
|
+
check_hash_parsed( result[0] )
|
394
|
+
|
395
|
+
result[1].is_a?( ComponentInstance ).should == true
|
396
|
+
result[1].kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
397
|
+
|
398
|
+
check_hash_parsed( result[2] )
|
399
|
+
|
400
|
+
result[3].is_a?( ComponentInstance ).should == true
|
401
|
+
result[3].kind.name.should == @@KNOWN_SCALAR_COMPONENT2
|
402
|
+
|
403
|
+
end
|
404
|
+
|
405
|
+
|
406
|
+
it "array of mixed scalars and hashes -> array of parsed values" do
|
407
|
+
result = @input_parser.parse_yaml( @@MIXED_ARRAY )
|
408
|
+
|
409
|
+
result.length.should == 4
|
410
|
+
|
411
|
+
result[0].is_a?( ComponentInstance ).should == true
|
412
|
+
result[0].kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
413
|
+
|
414
|
+
result[1].is_a?( ComponentInstance ).should == true
|
415
|
+
result[1].kind.name.should == @@KNOWN_SCALAR_COMPONENT
|
416
|
+
|
417
|
+
result[2].should == @@INVALID_SCALAR_COMPONENT
|
418
|
+
|
419
|
+
check_hash_parsed( result[3] )
|
420
|
+
|
421
|
+
end
|
422
|
+
|
423
|
+
|
424
|
+
end
|