kuniri 0.0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -7
- data/COPYING +160 -656
- data/Gemfile +4 -3
- data/README.md +57 -27
- data/Rakefile +3 -1
- data/bin/kuniri +50 -26
- data/data/aggregation_lang.rb +33 -0
- data/data/attribute_lang.rb +14 -87
- data/data/class_lang.rb +19 -41
- data/data/comment_lang.rb +52 -0
- data/data/conditional_lang.rb +14 -41
- data/data/constructor_lang.rb +4 -12
- data/data/end_block_lang.rb +7 -6
- data/data/extern_requirement_lang.rb +10 -17
- data/data/function_behavior_lang.rb +17 -66
- data/data/global_function_lang.rb +26 -0
- data/data/lang_syntax.rb +82 -49
- data/data/method_lang.rb +26 -0
- data/data/module_namespace_lang.rb +8 -13
- data/data/repetition_lang.rb +19 -32
- data/data/token_lang.rb +2 -44
- data/data/variable_behaviour_lang.rb +43 -0
- data/data/variable_global_lang.rb +13 -72
- data/kuniri.gemspec +4 -4
- data/lib/kuniri/core/configuration/language_available.rb +2 -2
- data/lib/kuniri/core/kuniri.rb +32 -24
- data/lib/kuniri/core/setting.rb +51 -85
- data/lib/kuniri/error/parser_error.rb +9 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/aggregation.rb +29 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +0 -40
- data/lib/kuniri/language/abstract_container/structured_and_oo/global_tokens.rb +20 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +9 -1
- data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +0 -35
- data/lib/kuniri/language/container_data/structured_and_oo/aggregation_data.rb +23 -0
- data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +4 -2
- data/lib/kuniri/language/container_data/structured_and_oo/basic_structure.rb +24 -0
- data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +13 -19
- data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +2 -13
- data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +2 -0
- data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +11 -6
- data/lib/kuniri/language/container_data/structured_and_oo/{file_element.rb → file_element_data.rb} +11 -9
- data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +58 -11
- data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +3 -3
- data/lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb +55 -0
- data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +5 -4
- data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +3 -1
- data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +2 -13
- data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +2 -0
- data/lib/kuniri/language/language.rb +37 -11
- data/lib/kuniri/language/metadata.rb +29 -0
- data/lib/kuniri/language/ruby/aggregation_ruby.rb +37 -0
- data/lib/kuniri/language/ruby/attribute_ruby.rb +23 -38
- data/lib/kuniri/language/ruby/class_ruby.rb +2 -10
- data/lib/kuniri/language/ruby/conditional_ruby.rb +20 -6
- data/lib/kuniri/language/ruby/constructor_ruby.rb +5 -7
- data/lib/kuniri/language/ruby/end_block_ruby.rb +1 -1
- data/lib/kuniri/language/ruby/function_behavior_ruby.rb +1 -9
- data/lib/kuniri/language/ruby/global_function_ruby.rb +32 -0
- data/lib/kuniri/language/ruby/method_ruby.rb +33 -0
- data/lib/kuniri/language/ruby/repetition_ruby.rb +60 -14
- data/lib/kuniri/language/ruby/ruby_syntax.rb +76 -49
- data/lib/kuniri/parser/output_factory.rb +29 -0
- data/lib/kuniri/parser/output_format.rb +134 -0
- data/lib/kuniri/parser/parser.rb +3 -7
- data/lib/kuniri/parser/xml_builder_engine.rb +94 -0
- data/lib/kuniri/parser/xml_output_format.rb +143 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/aggregation_state.rb +45 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +0 -1
- data/lib/kuniri/state_machine/OO_structured_fsm/basic_structure_state.rb +182 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +12 -3
- data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +11 -68
- data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +7 -52
- data/lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb +86 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +2 -3
- data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +8 -50
- data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +6 -1
- data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +10 -59
- data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +4 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +0 -1
- data/lib/kuniri/version.rb +1 -1
- data/other/analyseFile.asta +0 -0
- data/spec/core/kuniri_spec.rb +2 -1
- data/spec/core/setting_spec.rb +35 -61
- data/spec/language/abstract_container/aggregation_spec.rb +13 -0
- data/spec/language/abstract_container/extern_requirement_spec.rb +13 -0
- data/spec/language/container_data/structured_and_oo/aggregation_data_spec.rb +29 -0
- data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +9 -2
- data/spec/language/container_data/structured_and_oo/class_data_spec.rb +1 -46
- data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +32 -2
- data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +31 -7
- data/spec/language/container_data/structured_and_oo/{file_element_spec.rb → file_element_data_spec.rb} +21 -5
- data/spec/language/container_data/structured_and_oo/function_abstract_spec.rb +213 -0
- data/spec/language/container_data/structured_and_oo/function_data_spec.rb +31 -2
- data/spec/language/container_data/structured_and_oo/manager_basic_structure_data_spec.rb +150 -0
- data/spec/language/container_data/structured_and_oo/method_data_spec.rb +80 -0
- data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +7 -1
- data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +9 -0
- data/spec/language/language_factory_spec.rb +1 -1
- data/spec/language/language_spec.rb +46 -9
- data/spec/language/ruby/aggregation_ruby_spec.rb +80 -0
- data/spec/language/ruby/class_ruby_spec.rb +66 -6
- data/spec/language/ruby/constructor_ruby_spec.rb +1 -1
- data/spec/language/ruby/end_block_ruby_spec.rb +11 -0
- data/spec/language/ruby/extern_requirement_ruby_spec.rb +59 -0
- data/spec/language/ruby/function_behavior_ruby_spec.rb +54 -2
- data/spec/language/ruby/global_test/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/complete_class_ruby_spec.rb +161 -0
- data/spec/language/ruby/global_test/conditional/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri1.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri2.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri3.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri4.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri5.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri6.yml +4 -0
- data/spec/language/ruby/global_test/conditional/a_lot_of_conditionals_spec.rb +92 -0
- data/spec/language/ruby/global_test/conditional/constructor_very_mix_conditional_spec.rb +105 -0
- data/spec/language/ruby/global_test/conditional/function_with_conditional_spec.rb +94 -0
- data/spec/language/ruby/global_test/conditional/function_with_nested_conditional_spec.rb +56 -0
- data/spec/language/ruby/global_test/conditional/method_very_mix_conditional_spec.rb +109 -0
- data/spec/language/ruby/global_test/conditional/very_deep_conditional_structure_spec.rb +61 -0
- data/spec/language/ruby/global_test/conditional/very_mix_conditional_spec.rb +105 -0
- data/spec/language/ruby/global_test/conditionalAndRepetition/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/conditionalAndRepetition/mix_conditional_repetition_spec.rb +57 -0
- data/spec/language/ruby/global_test/repetition/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri2.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri3.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri4.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri5.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri6.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri7.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri8.yml +4 -0
- data/spec/language/ruby/global_test/repetition/complete_class_integrity.rb +41 -0
- data/spec/language/ruby/global_test/repetition/complete_class_until_loop_spec.rb +42 -0
- data/spec/language/ruby/global_test/repetition/complete_class_while_loop_spec.rb +41 -0
- data/spec/language/ruby/global_test/repetition/complete_class_with_repetition_spec.rb +42 -0
- data/spec/language/ruby/global_test/repetition/constructor_with_mix_repetition_spec.rb +57 -0
- data/spec/language/ruby/global_test/repetition/method_with_mix_repetition_spec.rb +59 -0
- data/spec/language/ruby/global_test/repetition/very_mix_repetition_spec.rb +61 -0
- data/spec/language/ruby/global_test/repetition/very_nested_repetition_spec.rb +65 -0
- data/spec/language/ruby/method_ruby_spec.rb +52 -0
- data/spec/language/ruby/repetition_ruby_spec.rb +175 -8
- data/spec/language/ruby/ruby_syntax_spec.rb +213 -84
- data/spec/parser/output_factory_spec.rb +32 -0
- data/spec/parser/output_format_spec.rb +83 -0
- data/spec/parser/parser_spec.rb +7 -0
- data/spec/parser/xmlSchemaValidate/.kuniri1.yml +3 -0
- data/spec/parser/xmlSchemaValidate/.kuniri2.yml +3 -0
- data/spec/parser/xmlSchemaValidate/.kuniri3.yml +3 -0
- data/spec/parser/xmlSchemaValidate/class_data.xsd +99 -0
- data/spec/parser/xmlSchemaValidate/fullCodeTwo.xsd +119 -0
- data/spec/parser/xmlSchemaValidate/fullCodeWithComments.xsd +146 -0
- data/spec/parser/xmlSchemaValidate/simpleFunction.xsd +25 -0
- data/spec/parser/xmlSchemaValidate/validate_xml_spec.rb +52 -0
- data/spec/parser/xml_builder_engine_spec.rb +258 -0
- data/spec/parser/xml_output_format_spec.rb +274 -0
- data/spec/samples/rubySyntaxParts/aggregation/classAggregation.rb +37 -0
- data/spec/samples/rubySyntaxParts/aggregation/constructorAggregation.rb +36 -0
- data/spec/samples/rubySyntaxParts/aggregation/methodAggregation.rb +36 -0
- data/spec/samples/rubySyntaxParts/aggregation/multipleAggregation.rb +59 -0
- data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +7 -0
- data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +2 -1
- data/spec/samples/rubySyntaxParts/conditionalStatment/aLotOfConditionals.rb +42 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/commonCasesOfConditionals.rb +47 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +1 -1
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorMixConditional.rb +41 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/methodMixConditional.rb +41 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/mixConditionalWithRepetition.rb +20 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +61 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/veryDeepConditionalStructure.rb +48 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/veryMixConditional.rb +37 -0
- data/spec/samples/rubySyntaxParts/fullCode/fullCodeTwo.rb +56 -0
- data/spec/samples/rubySyntaxParts/fullCode/fullCodeWithComments.rb +64 -0
- data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +9 -1
- data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +2 -0
- data/spec/samples/rubySyntaxParts/repetition/beginWithWhileLoopInClass.rb +10 -0
- data/spec/samples/rubySyntaxParts/repetition/constructorWithMixRepetition.rb +22 -0
- data/spec/samples/rubySyntaxParts/repetition/forLoopInClass.rb +7 -0
- data/spec/samples/rubySyntaxParts/repetition/methodWithMixRepetition.rb +19 -0
- data/spec/samples/rubySyntaxParts/repetition/mixConditionalRepetition.rb +17 -0
- data/spec/samples/rubySyntaxParts/repetition/untilLoopInClass.rb +16 -0
- data/spec/samples/rubySyntaxParts/repetition/veryMixRepetition.rb +28 -0
- data/spec/samples/rubySyntaxParts/repetition/veryNestedRepetition.rb +17 -0
- data/spec/samples/rubySyntaxParts/repetition/whileLoopInClass.rb +12 -0
- data/spec/state_machine/OO_structured_fsm/aggregation_state_spec.rb +67 -0
- data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +15 -0
- data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +64 -0
- data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +3 -3
- data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +18 -0
- data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +27 -0
- metadata +195 -28
- data/lib/kuniri/core/configuration/monitor_available.rb +0 -13
- data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +0 -52
- data/lib/kuniri/parser/parser_xml.rb +0 -128
- data/spec/language/abstract_container/constructor_spec.rb +0 -13
- data/spec/util/html_logger_spec.rb +0 -31
- data/spec/util/logger_spec.rb +0 -20
- data/spec/util/txt_logger_spec.rb +0 -31
@@ -48,6 +48,17 @@ RSpec.describe Languages::Ruby::EndBlockRuby do
|
|
48
48
|
expect(isEnd).to eq(true)
|
49
49
|
end
|
50
50
|
|
51
|
+
it "Find end of block when the whole method is in one line." do
|
52
|
+
isEnd = @endBlock.has_end_of_block?("def subtract(a,b) a-b end")
|
53
|
+
expect(isEnd).to eq(true)
|
54
|
+
isEnd = @endBlock.has_end_of_block?("def subtract(a,b) a-b friend")
|
55
|
+
expect(isEnd).to eq(false)
|
56
|
+
isEnd = @endBlock.has_end_of_block?("def subtract(a,b) a-b endless")
|
57
|
+
expect(isEnd).to eq(false)
|
58
|
+
isEnd = @endBlock.has_end_of_block?("def sum(a,b) a+b end;")
|
59
|
+
expect(isEnd).to eq(true)
|
60
|
+
end
|
61
|
+
|
51
62
|
end
|
52
63
|
|
53
64
|
#context "end in the same line of other instructions" do
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Languages::Ruby::ExternRequirementRuby do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@extern = Languages::Ruby::ExternRequirementRuby.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Simple case of match" do
|
10
|
+
it "'Require', Normal case" do
|
11
|
+
result = @extern.get_requirement('require "xpto"')
|
12
|
+
expect(result.library).to eq('xpto')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "'require_relative', Normal case" do
|
16
|
+
result = @extern.get_requirement('require_relative "xpto"')
|
17
|
+
expect(result.library).to eq('xpto')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "Find requires with multiple spaces" do
|
22
|
+
it "A lot of space at the end (require)" do
|
23
|
+
result = @extern.get_requirement('require "xpto" ')
|
24
|
+
expect(result.library).to eq('xpto')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "A lot of space at the end (require_relative)" do
|
28
|
+
result = @extern.get_requirement('require_relative "xpto" ')
|
29
|
+
expect(result.library).to eq('xpto')
|
30
|
+
end
|
31
|
+
|
32
|
+
it "A lot of space at the beginning (require)" do
|
33
|
+
result = @extern.get_requirement('require "xpto"')
|
34
|
+
expect(result.library).to eq('xpto')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "A lot of space at the beginning (require_relative)" do
|
38
|
+
result = @extern.get_requirement('require_relative "xpto"')
|
39
|
+
expect(result.library).to eq('xpto')
|
40
|
+
end
|
41
|
+
|
42
|
+
it "A lot of space at the beginning and the end (require_relative)" do
|
43
|
+
result = @extern.get_requirement('require_relative "xpto" ')
|
44
|
+
expect(result.library).to eq('xpto')
|
45
|
+
end
|
46
|
+
|
47
|
+
it "A lot of space at the beginning and the end (require)" do
|
48
|
+
result = @extern.get_requirement('require "xpto" ')
|
49
|
+
expect(result.library).to eq('xpto')
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
after :all do
|
55
|
+
@extern = nil
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
@@ -67,7 +67,7 @@ RSpec.describe Languages::Ruby::FunctionBehaviorRuby do
|
|
67
67
|
.to eq("xpto_method")
|
68
68
|
end
|
69
69
|
|
70
|
-
it "Whitespace in the beginning, between and in the end" do
|
70
|
+
it "Whitespace in the beginning, between and in the end" do
|
71
71
|
input = " def xpto_method "
|
72
72
|
expect(@functionBehaviorRuby.get_function(input).name)
|
73
73
|
.to eq("xpto_method")
|
@@ -193,7 +193,6 @@ RSpec.describe Languages::Ruby::FunctionBehaviorRuby do
|
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
|
-
|
197
196
|
context "When has parameters and no parenthesis." do
|
198
197
|
it "No parenthesis, and one parameter" do
|
199
198
|
input = "def xpto_method x"
|
@@ -237,6 +236,59 @@ RSpec.describe Languages::Ruby::FunctionBehaviorRuby do
|
|
237
236
|
expect(methodOne.parameters).to match_array(["x", "m", "nda", "t"])
|
238
237
|
end
|
239
238
|
|
239
|
+
it "No parenthesis, and one parameter with assignment" do
|
240
|
+
input = "def xpto_method x=1"
|
241
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
242
|
+
expect(methodOne.parameters).to match_array([{"x"=>"1"}])
|
243
|
+
end
|
244
|
+
|
245
|
+
it "One parameter with assignment, with space at the end." do
|
246
|
+
input = "def xpto_method x=1 "
|
247
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
248
|
+
expect(methodOne.parameters).to match_array([{"x"=>"1"}])
|
249
|
+
end
|
250
|
+
|
251
|
+
it "One parameter with: assignment, and spaces as a delimiter." do
|
252
|
+
input = "def xpto_method x=1 "
|
253
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
254
|
+
expect(methodOne.parameters).to match_array([{"x"=>"1"}])
|
255
|
+
end
|
256
|
+
|
257
|
+
it "One parameter with assignment, multiple spaces" do
|
258
|
+
input = " def xpto_method x=1 "
|
259
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
260
|
+
expect(methodOne.parameters).to match_array([{"x"=>"1"}])
|
261
|
+
end
|
262
|
+
|
263
|
+
it "One parameter with assignment with multiple spaces between" do
|
264
|
+
input = "def xpto_method x = 1 "
|
265
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
266
|
+
expect(methodOne.parameters).to match_array([{"x"=>"1"}])
|
267
|
+
end
|
268
|
+
|
269
|
+
it "Two parameters with assignment" do
|
270
|
+
input = "def xpto_method x=1,y=2"
|
271
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
272
|
+
expect(methodOne.parameters).to match_array([{"x"=>"1"},
|
273
|
+
{"y"=>"2"}])
|
274
|
+
end
|
275
|
+
|
276
|
+
it "Three parameters with assignment" do
|
277
|
+
input = "def xpto_method x=1, abcde=2, xyz=3"
|
278
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
279
|
+
expect(methodOne.parameters).to match_array([{"x"=>"1"},
|
280
|
+
{"abcde"=>"2"},
|
281
|
+
{"xyz"=>"3"}])
|
282
|
+
end
|
283
|
+
|
284
|
+
it "Multiple parameters with assignment and with many spaces" do
|
285
|
+
input = " def xpto_method x=1 , m=65, nda=8 , t=4 "
|
286
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
287
|
+
expect(methodOne.parameters).to match_array([{"x"=>"1"},
|
288
|
+
{"m"=>"65"},
|
289
|
+
{"nda"=>"8"},
|
290
|
+
{"t"=>"4"}])
|
291
|
+
end
|
240
292
|
end
|
241
293
|
|
242
294
|
after :all do
|
@@ -0,0 +1,161 @@
|
|
1
|
+
require_relative '../../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Kuniri::Kuniri do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@path = "./spec/language/ruby/global_test/.kuniri.yml"
|
7
|
+
@kuniri = Kuniri::Kuniri.new
|
8
|
+
@kuniri.read_configuration_file(@path)
|
9
|
+
@kuniri.run_analysis
|
10
|
+
parser = Parser::XMLOutputFormat.new(@kuniri.configurationInfo[:output])
|
11
|
+
parser.create_all_data(@kuniri.get_parser())
|
12
|
+
@output = File.open("./spec/language/ruby/global_test/simpleFullCode.xml", "r")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "Should contain the class name" do
|
16
|
+
@class_name = nil
|
17
|
+
@output.each do |line|
|
18
|
+
@class_name = line =~ /\s+<classData\sname="Abc"\svisibility="public">/
|
19
|
+
break unless @class_name.nil?
|
20
|
+
end
|
21
|
+
expect(@class_name).not_to be_nil
|
22
|
+
@class_end = nil
|
23
|
+
@output.each do |line|
|
24
|
+
@class_end = line =~ /\s+<\/classData>$/
|
25
|
+
break unless @class_end.nil?
|
26
|
+
end
|
27
|
+
expect(@class_end).not_to be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "Should contain constructor" do
|
31
|
+
@constructor = nil
|
32
|
+
@output.each do |line|
|
33
|
+
@class_name = line =~ /\s+<methodData\sname="initialize"\svisibility="public"\/?>/
|
34
|
+
break unless @class_name.nil?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "Validade method" do
|
39
|
+
it "Find method1" do
|
40
|
+
@method_name = nil
|
41
|
+
@output.each do |line|
|
42
|
+
@method_name = line =~
|
43
|
+
/\s+<methodData\sname="method1"\svisibility="public"\/?>/
|
44
|
+
break unless @method_name.nil?
|
45
|
+
end
|
46
|
+
expect(@method_name).not_to be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "Find method2" do
|
50
|
+
@method_name = nil
|
51
|
+
@output.each do |line|
|
52
|
+
@method_name = line =~
|
53
|
+
/\s+<methodData\sname="method2"\svisibility="public"\/?>/
|
54
|
+
break unless @method_name.nil?
|
55
|
+
end
|
56
|
+
expect(@method_name).not_to be_nil
|
57
|
+
end
|
58
|
+
|
59
|
+
it "Find method3" do
|
60
|
+
@method_name = nil
|
61
|
+
@output.each do |line|
|
62
|
+
@method_name = line =~
|
63
|
+
/\s+<methodData\sname="method3"\svisibility="public"\/?>/
|
64
|
+
break unless @method_name.nil?
|
65
|
+
end
|
66
|
+
expect(@method_name).not_to be_nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "Should find all methods" do
|
71
|
+
@methods = []
|
72
|
+
@output.each do |line|
|
73
|
+
line_of_method = line =~
|
74
|
+
/\s+<methodData\sname="method\d"\svisibility="public"\/?>/
|
75
|
+
@methods << line_of_method unless line_of_method.nil?
|
76
|
+
end
|
77
|
+
expect(@methods.size).to eq(3)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "Should contain the parameter name" do
|
81
|
+
@parameter_name = nil
|
82
|
+
@output.each do |line|
|
83
|
+
@parameter_name = line =~ /\s+<parameterData\sname="x"\/>/
|
84
|
+
break unless @parameter_name.nil?
|
85
|
+
end
|
86
|
+
expect(@parameter_name).not_to be_nil
|
87
|
+
|
88
|
+
@parameter_name = nil
|
89
|
+
@output.each do |line|
|
90
|
+
@parameter_name = line =~ /\s+<parameterData\sname="a"\/>/
|
91
|
+
break unless @parameter_name.nil?
|
92
|
+
end
|
93
|
+
expect(@parameter_name).not_to be_nil
|
94
|
+
|
95
|
+
@parameter_name = nil
|
96
|
+
@output.each do |line|
|
97
|
+
@parameter_name = line =~ /\s+<parameterData\sname="b"\/>/
|
98
|
+
break unless @parameter_name.nil?
|
99
|
+
end
|
100
|
+
expect(@parameter_name).not_to be_nil
|
101
|
+
|
102
|
+
@parameter_name = nil
|
103
|
+
@output.each do |line|
|
104
|
+
@parameter_name = line =~ /\s+<parameterData\sname="c"\/>/
|
105
|
+
break unless @parameter_name.nil?
|
106
|
+
end
|
107
|
+
expect(@parameter_name).not_to be_nil
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
it "Should find all parameters" do
|
112
|
+
@parameters = []
|
113
|
+
@output.each do |line|
|
114
|
+
line_of_parameter = line =~ /\s+<parameterData\sname="\w+"\/>/
|
115
|
+
@parameters << line_of_parameter unless line_of_parameter.nil?
|
116
|
+
end
|
117
|
+
expect(@parameters.size).to eq(4)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "Should contain the inheritance name" do
|
121
|
+
@inheritance_name = nil
|
122
|
+
@output.each do |line|
|
123
|
+
@inheritance_name = line =~ /\s+<inheritanceData\s+name="Array"\/>/
|
124
|
+
break unless @inheritance_name.nil?
|
125
|
+
end
|
126
|
+
expect(@inheritance_name).not_to be_nil
|
127
|
+
end
|
128
|
+
|
129
|
+
it "Should find all inheritances" do
|
130
|
+
@inheritance = []
|
131
|
+
@output.each do |line|
|
132
|
+
line_of_inheritance = line =~ /\s+<inheritanceData\s+name="\w+"\/>/
|
133
|
+
@inheritance << line_of_inheritance unless line_of_inheritance.nil?
|
134
|
+
end
|
135
|
+
expect(@inheritance.size).to eq(1)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "Should verify the opening-closing structure" do
|
139
|
+
@stack = []
|
140
|
+
@output.each do |line|
|
141
|
+
next if line =~ /<\?xml.*/
|
142
|
+
next if line =~ /.*\/>/
|
143
|
+
|
144
|
+
if line =~ /\s*<\/(\w*)>/
|
145
|
+
expect(@stack.last).to eq($1)
|
146
|
+
@stack.pop
|
147
|
+
elsif line =~ /\s*<(\w*)(.*)>/
|
148
|
+
@stack.push $1
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
expect(@stack.size).to eq(0)
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
after :each do
|
157
|
+
@kuniri = nil
|
158
|
+
@output = nil
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require_relative '../../../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Kuniri::Kuniri do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@path = "./spec/language/ruby/global_test/conditional/.kuniri2.yml"
|
7
|
+
@kuniri = Kuniri::Kuniri.new
|
8
|
+
@kuniri.read_configuration_file(@path)
|
9
|
+
@kuniri.run_analysis
|
10
|
+
parser = Parser::XMLOutputFormat.new(@kuniri.configurationInfo[:output])
|
11
|
+
parser.create_all_data(@kuniri.get_parser())
|
12
|
+
str = "./spec/language/ruby/global_test/conditional/aLotOfConditionals.xml"
|
13
|
+
@output = File.open(str, "r")
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec.shared_examples "Conditional verification" do |regex, description|
|
17
|
+
it "Method: #{description}" do
|
18
|
+
conditional = nil
|
19
|
+
@output.each do |line|
|
20
|
+
conditional = line =~ regex
|
21
|
+
break unless conditional.nil?
|
22
|
+
end
|
23
|
+
expect(conditional).not_to be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "Test mix repetition" do
|
28
|
+
|
29
|
+
message = "Find: if conditional1 == level0"
|
30
|
+
regex = /\s+<if\sexpression="conditional1 == 'level0'"\slevel="0"\/?>/
|
31
|
+
include_examples "Conditional verification" , regex, message
|
32
|
+
|
33
|
+
message = "Find: conditional2 == level1"
|
34
|
+
regex = /\s+<if\sexpression="conditional2 == 'level1'"\slevel="1"\/?>/
|
35
|
+
include_examples "Conditional verification" , regex, message
|
36
|
+
|
37
|
+
message = "Find: unless conditional3 == level1"
|
38
|
+
regex = /\s+<unless\sexpression="conditional3 == 'level1'"\slevel="1"\/?>/
|
39
|
+
include_examples "Conditional verification" , regex, message
|
40
|
+
|
41
|
+
message = "Find: if xpto == level0"
|
42
|
+
regex = /\s+<if\sexpression="xpto == 'level0'"\slevel="0"\/?>/
|
43
|
+
include_examples "Conditional verification" , regex, message
|
44
|
+
|
45
|
+
message = "Find: elsif abc == level0"
|
46
|
+
regex = /\s+<elsif\sexpression="abc == 'level0'"\slevel="0"\/?>/
|
47
|
+
include_examples "Conditional verification" , regex, message
|
48
|
+
|
49
|
+
message = "Find: elsif banana == level0"
|
50
|
+
regex = /\s+<elsif\sexpression="banana == 'level0'"\slevel="0"\/?>/
|
51
|
+
include_examples "Conditional verification" , regex, message
|
52
|
+
|
53
|
+
message = "Find: if abc == level1"
|
54
|
+
regex = /\s+<if\sexpression="abc == 'level1'"\slevel="1"\/?>/
|
55
|
+
include_examples "Conditional verification" , regex, message
|
56
|
+
|
57
|
+
message = "Find: unless moreAndMore == level2"
|
58
|
+
regex = /\s+<unless\sexpression="moreAndMore == 'level2'"\slevel="2"\/?>/
|
59
|
+
include_examples "Conditional verification" , regex, message
|
60
|
+
|
61
|
+
message = "Find: elsif asdf == level1"
|
62
|
+
regex = /\s+<elsif\sexpression="asdf == 'level1'"\slevel="1"\/?>/
|
63
|
+
include_examples "Conditional verification" , regex, message
|
64
|
+
|
65
|
+
message = "Find: else level 1"
|
66
|
+
regex = /\s+<else\slevel="1"\/?>/
|
67
|
+
include_examples "Conditional verification" , regex, message
|
68
|
+
|
69
|
+
message = "Find: else level 0"
|
70
|
+
regex = /\s+<else\slevel="0"\/?>/
|
71
|
+
include_examples "Conditional verification" , regex, message
|
72
|
+
|
73
|
+
message = "Find: case p"
|
74
|
+
regex = /\s+<case\sexpression="p"\slevel="1"\/?>/
|
75
|
+
include_examples "Conditional verification" , regex, message
|
76
|
+
|
77
|
+
message = "Find: when 2"
|
78
|
+
regex = /\s+<when\sexpression="2"\slevel="1"\/?>/
|
79
|
+
include_examples "Conditional verification" , regex, message
|
80
|
+
|
81
|
+
message = "Find: when 4"
|
82
|
+
regex = /\s+<when\sexpression="4"\slevel="1"\/?>/
|
83
|
+
include_examples "Conditional verification" , regex, message
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
after :each do
|
88
|
+
@kuniri = nil
|
89
|
+
@output1 = nil
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|