kuniri 0.0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +9 -7
  4. data/COPYING +160 -656
  5. data/Gemfile +4 -3
  6. data/README.md +57 -27
  7. data/Rakefile +3 -1
  8. data/bin/kuniri +50 -26
  9. data/data/aggregation_lang.rb +33 -0
  10. data/data/attribute_lang.rb +14 -87
  11. data/data/class_lang.rb +19 -41
  12. data/data/comment_lang.rb +52 -0
  13. data/data/conditional_lang.rb +14 -41
  14. data/data/constructor_lang.rb +4 -12
  15. data/data/end_block_lang.rb +7 -6
  16. data/data/extern_requirement_lang.rb +10 -17
  17. data/data/function_behavior_lang.rb +17 -66
  18. data/data/global_function_lang.rb +26 -0
  19. data/data/lang_syntax.rb +82 -49
  20. data/data/method_lang.rb +26 -0
  21. data/data/module_namespace_lang.rb +8 -13
  22. data/data/repetition_lang.rb +19 -32
  23. data/data/token_lang.rb +2 -44
  24. data/data/variable_behaviour_lang.rb +43 -0
  25. data/data/variable_global_lang.rb +13 -72
  26. data/kuniri.gemspec +4 -4
  27. data/lib/kuniri/core/configuration/language_available.rb +2 -2
  28. data/lib/kuniri/core/kuniri.rb +32 -24
  29. data/lib/kuniri/core/setting.rb +51 -85
  30. data/lib/kuniri/error/parser_error.rb +9 -0
  31. data/lib/kuniri/language/abstract_container/structured_and_oo/aggregation.rb +29 -0
  32. data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +0 -40
  33. data/lib/kuniri/language/abstract_container/structured_and_oo/global_tokens.rb +20 -0
  34. data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +9 -1
  35. data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +0 -35
  36. data/lib/kuniri/language/container_data/structured_and_oo/aggregation_data.rb +23 -0
  37. data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +4 -2
  38. data/lib/kuniri/language/container_data/structured_and_oo/basic_structure.rb +24 -0
  39. data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +13 -19
  40. data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +2 -13
  41. data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +2 -0
  42. data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +11 -6
  43. data/lib/kuniri/language/container_data/structured_and_oo/{file_element.rb → file_element_data.rb} +11 -9
  44. data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +58 -11
  45. data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +3 -3
  46. data/lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb +55 -0
  47. data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +5 -4
  48. data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +3 -1
  49. data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +2 -13
  50. data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +2 -0
  51. data/lib/kuniri/language/language.rb +37 -11
  52. data/lib/kuniri/language/metadata.rb +29 -0
  53. data/lib/kuniri/language/ruby/aggregation_ruby.rb +37 -0
  54. data/lib/kuniri/language/ruby/attribute_ruby.rb +23 -38
  55. data/lib/kuniri/language/ruby/class_ruby.rb +2 -10
  56. data/lib/kuniri/language/ruby/conditional_ruby.rb +20 -6
  57. data/lib/kuniri/language/ruby/constructor_ruby.rb +5 -7
  58. data/lib/kuniri/language/ruby/end_block_ruby.rb +1 -1
  59. data/lib/kuniri/language/ruby/function_behavior_ruby.rb +1 -9
  60. data/lib/kuniri/language/ruby/global_function_ruby.rb +32 -0
  61. data/lib/kuniri/language/ruby/method_ruby.rb +33 -0
  62. data/lib/kuniri/language/ruby/repetition_ruby.rb +60 -14
  63. data/lib/kuniri/language/ruby/ruby_syntax.rb +76 -49
  64. data/lib/kuniri/parser/output_factory.rb +29 -0
  65. data/lib/kuniri/parser/output_format.rb +134 -0
  66. data/lib/kuniri/parser/parser.rb +3 -7
  67. data/lib/kuniri/parser/xml_builder_engine.rb +94 -0
  68. data/lib/kuniri/parser/xml_output_format.rb +143 -0
  69. data/lib/kuniri/state_machine/OO_structured_fsm/aggregation_state.rb +45 -0
  70. data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +0 -1
  71. data/lib/kuniri/state_machine/OO_structured_fsm/basic_structure_state.rb +182 -0
  72. data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +12 -3
  73. data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +11 -68
  74. data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +7 -52
  75. data/lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb +86 -0
  76. data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +2 -3
  77. data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +8 -50
  78. data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +6 -1
  79. data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +10 -59
  80. data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +4 -0
  81. data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +0 -1
  82. data/lib/kuniri/version.rb +1 -1
  83. data/other/analyseFile.asta +0 -0
  84. data/spec/core/kuniri_spec.rb +2 -1
  85. data/spec/core/setting_spec.rb +35 -61
  86. data/spec/language/abstract_container/aggregation_spec.rb +13 -0
  87. data/spec/language/abstract_container/extern_requirement_spec.rb +13 -0
  88. data/spec/language/container_data/structured_and_oo/aggregation_data_spec.rb +29 -0
  89. data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +9 -2
  90. data/spec/language/container_data/structured_and_oo/class_data_spec.rb +1 -46
  91. data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +32 -2
  92. data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +31 -7
  93. data/spec/language/container_data/structured_and_oo/{file_element_spec.rb → file_element_data_spec.rb} +21 -5
  94. data/spec/language/container_data/structured_and_oo/function_abstract_spec.rb +213 -0
  95. data/spec/language/container_data/structured_and_oo/function_data_spec.rb +31 -2
  96. data/spec/language/container_data/structured_and_oo/manager_basic_structure_data_spec.rb +150 -0
  97. data/spec/language/container_data/structured_and_oo/method_data_spec.rb +80 -0
  98. data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +7 -1
  99. data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +9 -0
  100. data/spec/language/language_factory_spec.rb +1 -1
  101. data/spec/language/language_spec.rb +46 -9
  102. data/spec/language/ruby/aggregation_ruby_spec.rb +80 -0
  103. data/spec/language/ruby/class_ruby_spec.rb +66 -6
  104. data/spec/language/ruby/constructor_ruby_spec.rb +1 -1
  105. data/spec/language/ruby/end_block_ruby_spec.rb +11 -0
  106. data/spec/language/ruby/extern_requirement_ruby_spec.rb +59 -0
  107. data/spec/language/ruby/function_behavior_ruby_spec.rb +54 -2
  108. data/spec/language/ruby/global_test/.kuniri.yml +4 -0
  109. data/spec/language/ruby/global_test/complete_class_ruby_spec.rb +161 -0
  110. data/spec/language/ruby/global_test/conditional/.kuniri.yml +4 -0
  111. data/spec/language/ruby/global_test/conditional/.kuniri1.yml +4 -0
  112. data/spec/language/ruby/global_test/conditional/.kuniri2.yml +4 -0
  113. data/spec/language/ruby/global_test/conditional/.kuniri3.yml +4 -0
  114. data/spec/language/ruby/global_test/conditional/.kuniri4.yml +4 -0
  115. data/spec/language/ruby/global_test/conditional/.kuniri5.yml +4 -0
  116. data/spec/language/ruby/global_test/conditional/.kuniri6.yml +4 -0
  117. data/spec/language/ruby/global_test/conditional/a_lot_of_conditionals_spec.rb +92 -0
  118. data/spec/language/ruby/global_test/conditional/constructor_very_mix_conditional_spec.rb +105 -0
  119. data/spec/language/ruby/global_test/conditional/function_with_conditional_spec.rb +94 -0
  120. data/spec/language/ruby/global_test/conditional/function_with_nested_conditional_spec.rb +56 -0
  121. data/spec/language/ruby/global_test/conditional/method_very_mix_conditional_spec.rb +109 -0
  122. data/spec/language/ruby/global_test/conditional/very_deep_conditional_structure_spec.rb +61 -0
  123. data/spec/language/ruby/global_test/conditional/very_mix_conditional_spec.rb +105 -0
  124. data/spec/language/ruby/global_test/conditionalAndRepetition/.kuniri.yml +4 -0
  125. data/spec/language/ruby/global_test/conditionalAndRepetition/mix_conditional_repetition_spec.rb +57 -0
  126. data/spec/language/ruby/global_test/repetition/.kuniri.yml +4 -0
  127. data/spec/language/ruby/global_test/repetition/.kuniri2.yml +4 -0
  128. data/spec/language/ruby/global_test/repetition/.kuniri3.yml +4 -0
  129. data/spec/language/ruby/global_test/repetition/.kuniri4.yml +4 -0
  130. data/spec/language/ruby/global_test/repetition/.kuniri5.yml +4 -0
  131. data/spec/language/ruby/global_test/repetition/.kuniri6.yml +4 -0
  132. data/spec/language/ruby/global_test/repetition/.kuniri7.yml +4 -0
  133. data/spec/language/ruby/global_test/repetition/.kuniri8.yml +4 -0
  134. data/spec/language/ruby/global_test/repetition/complete_class_integrity.rb +41 -0
  135. data/spec/language/ruby/global_test/repetition/complete_class_until_loop_spec.rb +42 -0
  136. data/spec/language/ruby/global_test/repetition/complete_class_while_loop_spec.rb +41 -0
  137. data/spec/language/ruby/global_test/repetition/complete_class_with_repetition_spec.rb +42 -0
  138. data/spec/language/ruby/global_test/repetition/constructor_with_mix_repetition_spec.rb +57 -0
  139. data/spec/language/ruby/global_test/repetition/method_with_mix_repetition_spec.rb +59 -0
  140. data/spec/language/ruby/global_test/repetition/very_mix_repetition_spec.rb +61 -0
  141. data/spec/language/ruby/global_test/repetition/very_nested_repetition_spec.rb +65 -0
  142. data/spec/language/ruby/method_ruby_spec.rb +52 -0
  143. data/spec/language/ruby/repetition_ruby_spec.rb +175 -8
  144. data/spec/language/ruby/ruby_syntax_spec.rb +213 -84
  145. data/spec/parser/output_factory_spec.rb +32 -0
  146. data/spec/parser/output_format_spec.rb +83 -0
  147. data/spec/parser/parser_spec.rb +7 -0
  148. data/spec/parser/xmlSchemaValidate/.kuniri1.yml +3 -0
  149. data/spec/parser/xmlSchemaValidate/.kuniri2.yml +3 -0
  150. data/spec/parser/xmlSchemaValidate/.kuniri3.yml +3 -0
  151. data/spec/parser/xmlSchemaValidate/class_data.xsd +99 -0
  152. data/spec/parser/xmlSchemaValidate/fullCodeTwo.xsd +119 -0
  153. data/spec/parser/xmlSchemaValidate/fullCodeWithComments.xsd +146 -0
  154. data/spec/parser/xmlSchemaValidate/simpleFunction.xsd +25 -0
  155. data/spec/parser/xmlSchemaValidate/validate_xml_spec.rb +52 -0
  156. data/spec/parser/xml_builder_engine_spec.rb +258 -0
  157. data/spec/parser/xml_output_format_spec.rb +274 -0
  158. data/spec/samples/rubySyntaxParts/aggregation/classAggregation.rb +37 -0
  159. data/spec/samples/rubySyntaxParts/aggregation/constructorAggregation.rb +36 -0
  160. data/spec/samples/rubySyntaxParts/aggregation/methodAggregation.rb +36 -0
  161. data/spec/samples/rubySyntaxParts/aggregation/multipleAggregation.rb +59 -0
  162. data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +7 -0
  163. data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +2 -1
  164. data/spec/samples/rubySyntaxParts/conditionalStatment/aLotOfConditionals.rb +42 -0
  165. data/spec/samples/rubySyntaxParts/conditionalStatment/commonCasesOfConditionals.rb +47 -0
  166. data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +1 -1
  167. data/spec/samples/rubySyntaxParts/conditionalStatment/constructorMixConditional.rb +41 -0
  168. data/spec/samples/rubySyntaxParts/conditionalStatment/methodMixConditional.rb +41 -0
  169. data/spec/samples/rubySyntaxParts/conditionalStatment/mixConditionalWithRepetition.rb +20 -0
  170. data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +61 -0
  171. data/spec/samples/rubySyntaxParts/conditionalStatment/veryDeepConditionalStructure.rb +48 -0
  172. data/spec/samples/rubySyntaxParts/conditionalStatment/veryMixConditional.rb +37 -0
  173. data/spec/samples/rubySyntaxParts/fullCode/fullCodeTwo.rb +56 -0
  174. data/spec/samples/rubySyntaxParts/fullCode/fullCodeWithComments.rb +64 -0
  175. data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +9 -1
  176. data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +2 -0
  177. data/spec/samples/rubySyntaxParts/repetition/beginWithWhileLoopInClass.rb +10 -0
  178. data/spec/samples/rubySyntaxParts/repetition/constructorWithMixRepetition.rb +22 -0
  179. data/spec/samples/rubySyntaxParts/repetition/forLoopInClass.rb +7 -0
  180. data/spec/samples/rubySyntaxParts/repetition/methodWithMixRepetition.rb +19 -0
  181. data/spec/samples/rubySyntaxParts/repetition/mixConditionalRepetition.rb +17 -0
  182. data/spec/samples/rubySyntaxParts/repetition/untilLoopInClass.rb +16 -0
  183. data/spec/samples/rubySyntaxParts/repetition/veryMixRepetition.rb +28 -0
  184. data/spec/samples/rubySyntaxParts/repetition/veryNestedRepetition.rb +17 -0
  185. data/spec/samples/rubySyntaxParts/repetition/whileLoopInClass.rb +12 -0
  186. data/spec/state_machine/OO_structured_fsm/aggregation_state_spec.rb +67 -0
  187. data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +15 -0
  188. data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +64 -0
  189. data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +3 -3
  190. data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +18 -0
  191. data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +27 -0
  192. metadata +195 -28
  193. data/lib/kuniri/core/configuration/monitor_available.rb +0 -13
  194. data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +0 -52
  195. data/lib/kuniri/parser/parser_xml.rb +0 -128
  196. data/spec/language/abstract_container/constructor_spec.rb +0 -13
  197. data/spec/util/html_logger_spec.rb +0 -31
  198. data/spec/util/logger_spec.rb +0 -20
  199. data/spec/util/txt_logger_spec.rb +0 -31
@@ -0,0 +1,65 @@
1
+ require_relative '../../../../spec_helper'
2
+
3
+ RSpec.describe "Verify repetition output with a nested conditional" do
4
+
5
+ before :each do
6
+ @path = "./spec/language/ruby/global_test/repetition/.kuniri6.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/repetition/veryNestedRepetition.xml", "r")
13
+ end
14
+
15
+ RSpec.shared_examples "Nested multiple verification" do |regex, description|
16
+
17
+ it "Global Function: #{description}" do
18
+ repetition = nil
19
+ @output.each do |line|
20
+ repetition = line =~ regex
21
+ break unless repetition.nil?
22
+ end
23
+ expect(repetition).not_to be_nil
24
+ end
25
+
26
+ end
27
+
28
+ context "Test neted repetition" do
29
+
30
+ message = "Global Function: for level0 in 0..5"
31
+ regex = /\s+<for\sexpression="level0 in 0\.\.5"\slevel="0"\/?>/
32
+ include_examples "Nested multiple verification" , regex, message
33
+
34
+ message = "Global Function: for level1 in 0..6"
35
+ regex = /\s+<for\sexpression="level1 in 0\.\.6"\slevel="1"\/?>/
36
+ include_examples "Nested multiple verification" , regex, message
37
+
38
+ message = "Global Function: for level2 in 0..7"
39
+ regex = /\s+<for\sexpression="level2 in 0\.\.7"\slevel="2"\/?>/
40
+ include_examples "Nested multiple verification" , regex, message
41
+
42
+ message = "Global Function: for level3 in 0..8"
43
+ regex = /\s+<for\sexpression="level3 in 0\.\.8"\slevel="3"\/?>/
44
+ include_examples "Nested multiple verification" , regex, message
45
+
46
+ message = "Global Function: for level4 in 0..9"
47
+ regex = /\s+<for\sexpression="level4 in 0\.\.9"\slevel="4"\/?>/
48
+ include_examples "Nested multiple verification" , regex, message
49
+
50
+ message = "Global Function: for level5 in 0..10"
51
+ regex = /\s+<for\sexpression="level5 in 0\.\.10"\slevel="5"\/?>/
52
+ include_examples "Nested multiple verification" , regex, message
53
+
54
+ message = "Global Function: for level6 in 0..11"
55
+ regex = /\s+<for\sexpression="level6 in 0\.\.11"\slevel="6"\/?>/
56
+ include_examples "Nested multiple verification" , regex, message
57
+
58
+ end
59
+
60
+ after :each do
61
+ @kuniri = nil
62
+ @output = nil
63
+ end
64
+
65
+ end
@@ -0,0 +1,52 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ RSpec.describe Languages::Ruby::MethodRuby do
4
+
5
+ before :all do
6
+ @methodRuby = Languages::Ruby::MethodRuby.new
7
+ end
8
+
9
+ context "When method without parameter" do
10
+ it "Simple declaration" do
11
+ input = "def xpto"
12
+ expect(@methodRuby.get_method(input).name)
13
+ .to eq("xpto")
14
+ end
15
+
16
+ it "With spaces in the begin" do
17
+ input = " def xpto"
18
+ expect(@methodRuby.get_method(input).name)
19
+ .to eq("xpto")
20
+ end
21
+
22
+ it "With spaces in the begin and between method name" do
23
+ input = " def xpto"
24
+ expect(@methodRuby.get_method(input).name)
25
+ .to eq("xpto")
26
+ input = " def xpto"
27
+ expect(@methodRuby.get_method(input).name)
28
+ .to eq("xpto")
29
+ end
30
+
31
+ it "With spaces in the end" do
32
+ input = "def xpto "
33
+ expect(@methodRuby.get_method(input).name)
34
+ .to eq("xpto")
35
+ input = "def xpto "
36
+ expect(@methodRuby.get_method(input).name)
37
+ .to eq("xpto")
38
+ end
39
+
40
+ it "With spaces in both sides" do
41
+ input = " def xpto "
42
+ expect(@methodRuby.get_method(input).name)
43
+ .to eq("xpto")
44
+ end
45
+
46
+ end
47
+
48
+ after :all do
49
+ @constructor = nil
50
+ end
51
+
52
+ end
@@ -6,24 +6,191 @@ RSpec.describe Languages::Ruby::RepetitionRuby do
6
6
  @repetitionRuby = Languages::Ruby::RepetitionRuby.new
7
7
  end
8
8
 
9
- context "When it is if statment." do
10
- it "Simple if statment." do
9
+ context "While loop" do
10
+ it "Simple while statement." do
11
11
  input = "while gets do"
12
- repetitionCaptured = @repetitionRuby.get_repetition(input).expression
13
- expect(repetitionCaptured).to eq("gets")
12
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
13
+ expect(repetitionCaptured.expression).to eq("gets")
14
+ expect(repetitionCaptured.type).to eq(Languages::WHILE_LABEL)
15
+ end
14
16
 
17
+ it "Numerical statement" do
15
18
  input = "while 2 < 3 do"
16
19
  repetitionCaptured = @repetitionRuby.get_repetition(input).expression
17
20
  expect(repetitionCaptured).to eq("2 < 3")
21
+ end
18
22
 
19
- #input = "for x.range(0,1)"
20
- #repetitionCaptured = @repetitionRuby.get_repetition(input).expression
21
- #expect(repetitionCaptured).to eq("x.range(0,1)")
22
-
23
+ it "Big number" do
23
24
  input = "while x == 222222 do"
24
25
  repetitionCaptured = @repetitionRuby.get_repetition(input).expression
25
26
  expect(repetitionCaptured).to eq("x == 222222")
26
27
  end
28
+
29
+ it "Compare with string" do
30
+ input = 'while x == "abc" do'
31
+ repetitionCaptured = @repetitionRuby.get_repetition(input).expression
32
+ expect(repetitionCaptured).to eq('x == "abc"')
33
+ end
34
+
35
+ it "While with multiple spaces between expression" do
36
+ input = 'while x == "abc" do'
37
+ repetitionCaptured = @repetitionRuby.get_repetition(input).expression
38
+ expect(repetitionCaptured).to eq('x == "abc"')
39
+ end
40
+
41
+ it "While with multiple spaces in the beginning" do
42
+ input = ' while x == "abc" do'
43
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
44
+ expect(repetitionCaptured.expression).to eq('x == "abc"')
45
+ expect(repetitionCaptured.type).to eq(Languages::WHILE_LABEL)
46
+ end
47
+
48
+ it "'Do' is not mandatory" do
49
+ input = "while x > 3"
50
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
51
+ expect(repetitionCaptured.type).to eq(Languages::WHILE_LABEL)
52
+ end
53
+
54
+ it "Not match" do
55
+ input = "whiles x > 3"
56
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
57
+ expect(repetitionCaptured).to eq(nil)
58
+ end
59
+
60
+ end
61
+
62
+ context "For loop" do
63
+ it "Simple for statement." do
64
+ input = "for i in 0..5"
65
+ repetitionCaptured = @repetitionRuby.get_repetition(input).expression
66
+ expect(repetitionCaptured).to eq("i in 0..5")
67
+ end
68
+
69
+ it "Multiple spaces in the beginning of for" do
70
+ input = " for i in 0..5"
71
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
72
+ expect(repetitionCaptured.expression).to eq("i in 0..5")
73
+ expect(repetitionCaptured.type).to eq(Languages::FOR_LABEL)
74
+ end
75
+
76
+ it "Multiple spaces between of for and expression" do
77
+ input = " for i in 0..5"
78
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
79
+ expect(repetitionCaptured.expression).to eq("i in 0..5")
80
+ expect(repetitionCaptured.type).to eq(Languages::FOR_LABEL)
81
+ end
82
+
83
+ it "No match" do
84
+ input = "for xpto"
85
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
86
+ expect(repetitionCaptured).to eq(nil)
87
+ end
88
+
89
+ it "We can have 'do' or not at the end" do
90
+ input = "for i in 0..5 do"
91
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
92
+ expect(repetitionCaptured.expression).to eq("i in 0..5")
93
+ end
94
+
95
+ it "For with 'do' and space in the end" do
96
+ input = "for i in 0..5 do "
97
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
98
+ expect(repetitionCaptured.expression).to eq("i in 0..5")
99
+ end
100
+
101
+ end
102
+
103
+ context "Until loop" do
104
+ it "Simple until statement" do
105
+ input = "until $i > $num do"
106
+ repetitionCaptured = @repetitionRuby.get_repetition(input).expression
107
+ expect(repetitionCaptured).to eq("$i > $num")
108
+ end
109
+
110
+ it "Compare with string" do
111
+ input = 'until xpto == "exit" do'
112
+ repetitionCaptured = @repetitionRuby.get_repetition(input).expression
113
+ expect(repetitionCaptured).to eq('xpto == "exit"')
114
+ end
115
+
116
+ it "Check correct type" do
117
+ input = 'until xpto == "exit" do'
118
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
119
+ expect(repetitionCaptured.type).to eq(Languages::UNTIL_LABEL)
120
+ end
121
+
122
+ it "'Do' is not mandatory with until" do
123
+ input = 'until xpto == "exit"'
124
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
125
+ expect(repetitionCaptured.type).to eq(Languages::UNTIL_LABEL)
126
+ end
127
+
128
+ it "Until without 'do' and with space at the end" do
129
+ input = 'until xpto == "exit" '
130
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
131
+ expect(repetitionCaptured.type).to eq(Languages::UNTIL_LABEL)
132
+ end
133
+
134
+ it "Until without 'do' and with space at the begin and the end" do
135
+ input = ' until xpto == "exit" '
136
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
137
+ expect(repetitionCaptured.type).to eq(Languages::UNTIL_LABEL)
138
+ end
139
+
140
+ it "Not match" do
141
+ input = 'untils xpto == "exit"'
142
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
143
+ expect(repetitionCaptured).to eq(nil)
144
+ end
145
+
146
+ end
147
+
148
+ context "Do while" do
149
+ it "Simple do while statement" do
150
+ input = "end while $i < $num"
151
+ repetitionCaptured = @repetitionRuby.get_repetition(input).expression
152
+ expect(repetitionCaptured).to eq("$i < $num")
153
+ end
154
+
155
+ it "No match" do
156
+ input = "end whiles $xpto > 23 do"
157
+ repetitionCaptured = @repetitionRuby.get_repetition(input)
158
+ expect(repetitionCaptured).to eq(nil)
159
+ end
160
+
161
+ # it "No match" do
162
+ # input = "end while $xpto > 23 do"
163
+ # repetitionCaptured = @repetitionRuby.get_repetition(input)
164
+ # expect(repetitionCaptured).to eq(nil)
165
+ # end
166
+
167
+ end
168
+
169
+ context "Iterators loop" do
170
+ it "Simple each iterator" do
171
+ input = "abc.each do |something|"
172
+ repetitionCaptured = @repetitionRuby.get_repetition(input).type
173
+ expect(repetitionCaptured).to eq("EACH")
174
+ end
175
+
176
+ it "Simple each_with_index iterator" do
177
+ input = "abc.each_with_index do |something|"
178
+ repetitionCaptured = @repetitionRuby.get_repetition(input).type
179
+ expect(repetitionCaptured).to eq("EACH_WITH_INDEX")
180
+ end
181
+
182
+ it "Simple collect iterator" do
183
+ input = "abc.collect do |something|"
184
+ repetitionCaptured = @repetitionRuby.get_repetition(input).type
185
+ expect(repetitionCaptured).to eq("COLLECT")
186
+ end
187
+
188
+ it "Simple collect iterator" do
189
+ input = "abc.map do |something|"
190
+ repetitionCaptured = @repetitionRuby.get_repetition(input).type
191
+ expect(repetitionCaptured).to eq("MAP")
192
+ end
193
+
27
194
  end
28
195
 
29
196
  after :each do
@@ -4,6 +4,8 @@ RSpec.describe Languages::RubySyntax do
4
4
 
5
5
  before :each do
6
6
  @syntax = Languages::RubySyntax.new
7
+ @syntax.metadata.allClasses.clear
8
+ @syntax.metadata.allAggregations.clear
7
9
  end
8
10
 
9
11
  context "Extern requirement detections." do
@@ -24,15 +26,15 @@ RSpec.describe Languages::RubySyntax do
24
26
  path = "spec/samples/rubySyntaxParts/extern/requireRelative.rb"
25
27
 
26
28
  @syntax.analyse_source(path)
27
- expect(@syntax.fileElements[0].extern_requirements[0].name).to eq ("one")
28
- expect(@syntax.fileElements[0].extern_requirements[1].name).to eq ("two")
29
- expect(@syntax.fileElements[0].extern_requirements[2].name)
29
+ expect(@syntax.fileElements[0].extern_requirements[0].library).to eq ("one")
30
+ expect(@syntax.fileElements[0].extern_requirements[1].library).to eq ("two")
31
+ expect(@syntax.fileElements[0].extern_requirements[2].library)
30
32
  .to eq ("three")
31
- expect(@syntax.fileElements[0].extern_requirements[3].name)
33
+ expect(@syntax.fileElements[0].extern_requirements[3].library)
32
34
  .to eq ("four")
33
- expect(@syntax.fileElements[0].extern_requirements[4].name)
35
+ expect(@syntax.fileElements[0].extern_requirements[4].library)
34
36
  .to eq ("five")
35
- expect(@syntax.fileElements[0].extern_requirements[5].name).to eq ("six")
37
+ expect(@syntax.fileElements[0].extern_requirements[5].library).to eq ("six")
36
38
  expect(@syntax.fileElements[0].extern_requirements.size).to eq (6)
37
39
  end
38
40
 
@@ -50,20 +52,20 @@ RSpec.describe Languages::RubySyntax do
50
52
  path = "spec/samples/rubySyntaxParts/extern/simpleExternRequirement.rb"
51
53
 
52
54
  @syntax.analyse_source(path)
53
- expect(@syntax.fileElements[0].extern_requirements[0].name).to eq ("one")
54
- expect(@syntax.fileElements[0].extern_requirements[1].name).to eq ("two")
55
- expect(@syntax.fileElements[0].extern_requirements[2].name)
55
+ expect(@syntax.fileElements[0].extern_requirements[0].library).to eq ("one")
56
+ expect(@syntax.fileElements[0].extern_requirements[1].library).to eq ("two")
57
+ expect(@syntax.fileElements[0].extern_requirements[2].library)
56
58
  .to eq ("three")
57
- expect(@syntax.fileElements[0].extern_requirements[3].name)
59
+ expect(@syntax.fileElements[0].extern_requirements[3].library)
58
60
  .to eq ("four")
59
- expect(@syntax.fileElements[0].extern_requirements[4].name)
61
+ expect(@syntax.fileElements[0].extern_requirements[4].library)
60
62
  .to eq ("five")
61
- expect(@syntax.fileElements[0].extern_requirements[5].name).to eq ("six")
62
- expect(@syntax.fileElements[0].extern_requirements[6].name)
63
+ expect(@syntax.fileElements[0].extern_requirements[5].library).to eq ("six")
64
+ expect(@syntax.fileElements[0].extern_requirements[6].library)
63
65
  .to eq ("seven")
64
- expect(@syntax.fileElements[0].extern_requirements[7].name)
66
+ expect(@syntax.fileElements[0].extern_requirements[7].library)
65
67
  .to eq ("eight")
66
- expect(@syntax.fileElements[0].extern_requirements[8].name)
68
+ expect(@syntax.fileElements[0].extern_requirements[8].library)
67
69
  .to eq ("nine")
68
70
  expect(@syntax.fileElements[0].extern_requirements.size).to eq (9)
69
71
  end
@@ -171,6 +173,20 @@ RSpec.describe Languages::RubySyntax do
171
173
  expect(@syntax.fileElements[0].classes[4].name).to eq("Simple5")
172
174
  end
173
175
 
176
+ it "All classes in Metadata array" do
177
+ path = "spec/samples/rubySyntaxParts/class/simpleClass.rb"
178
+
179
+ @syntax.analyse_source(path)
180
+
181
+ expect(@syntax.metadata.allClasses.size).to eq(5)
182
+ expect(@syntax.metadata.allClasses[0].name).to eq('Simple1')
183
+ expect(@syntax.metadata.allClasses[1].name).to eq('Simple2')
184
+ expect(@syntax.metadata.allClasses[2].name).to eq('Simple3')
185
+ expect(@syntax.metadata.allClasses[3].name).to eq('Simple4')
186
+ expect(@syntax.metadata.allClasses[4].name).to eq('Simple5')
187
+ end
188
+
189
+
174
190
  end
175
191
 
176
192
  context "Attribute line" do
@@ -225,6 +241,10 @@ RSpec.describe Languages::RubySyntax do
225
241
  .to eq("method2")
226
242
  expect(@syntax.fileElements[0].classes[0].methods[2].name)
227
243
  .to eq("method3")
244
+ expect(@syntax.fileElements[0].classes[0].methods[3].name)
245
+ .to eq("method4")
246
+ expect(@syntax.fileElements[0].classes[0].methods[4].name)
247
+ .to eq("method5")
228
248
  end
229
249
  end
230
250
 
@@ -267,25 +287,20 @@ RSpec.describe Languages::RubySyntax do
267
287
  "spec/samples/rubySyntaxParts/conditionalStatment/simpleConditional.rb"
268
288
 
269
289
  @syntax.analyse_source(path)
270
- expect(@syntax.fileElements[0].global_functions[0].name)
271
- .to eq("simple1")
272
-
273
- expect(@syntax.fileElements[0].global_functions[0]
274
- .conditionals[0].expression).to eq("3 > 2")
275
- expect(@syntax.fileElements[0].global_functions[0]
276
- .conditionals[0].type).to eq("IF")
277
-
278
- expect(@syntax.fileElements[0].global_functions[1].name)
279
- .to eq("simple2")
280
- expect(@syntax.fileElements[0].global_functions[1]
281
- .conditionals[0].expression).to eq("7 > 2")
282
- expect(@syntax.fileElements[0].global_functions[1]
283
- .conditionals[0].type).to eq("IF")
284
-
285
- expect(@syntax.fileElements[0].global_functions[1]
286
- .conditionals[1].expression).to eq("\"a\" < \"k\"")
287
- expect(@syntax.fileElements[0].global_functions[1]
288
- .conditionals[1].type).to eq("IF")
290
+ allFuntion0 = @syntax.fileElements[0].global_functions[0]
291
+ .managerCondAndLoop.basicStructure
292
+ allFuntion1 = @syntax.fileElements[0].global_functions[1]
293
+ .managerCondAndLoop.basicStructure
294
+
295
+ expect(@syntax.fileElements[0].global_functions[0].name).to eq("simple1")
296
+ expect(allFuntion0[0].expression).to eq("3 > 2")
297
+ expect(allFuntion0[0].type).to eq(Languages::IF_LABEL)
298
+
299
+ expect(@syntax.fileElements[0].global_functions[1].name).to eq("simple2")
300
+ expect(allFuntion1[0].expression).to eq("7 > 2")
301
+ expect(allFuntion1[0].type).to eq(Languages::IF_LABEL)
302
+ expect(allFuntion1[1].expression).to eq("\"a\" < \"k\"")
303
+ expect(allFuntion1[1].type).to eq(Languages::IF_LABEL)
289
304
  end
290
305
 
291
306
  it "Correct state transition (Method)." do
@@ -304,40 +319,41 @@ RSpec.describe Languages::RubySyntax do
304
319
  "spec/samples/rubySyntaxParts/conditionalStatment/methodConditional.rb"
305
320
 
306
321
  @syntax.analyse_source(path)
322
+ allMethod0 = @syntax.fileElements[0].classes[0].methods[0]
323
+ .managerCondAndLoop.basicStructure
324
+ allMethod1 = @syntax.fileElements[0].classes[0].methods[1]
325
+ .managerCondAndLoop.basicStructure
326
+ allMethod2 = @syntax.fileElements[0].classes[0].methods[2]
327
+ .managerCondAndLoop.basicStructure
328
+ allMethod3 = @syntax.fileElements[0].classes[0].methods[3]
329
+ .managerCondAndLoop.basicStructure
330
+
307
331
  expect(@syntax.fileElements[0].classes[0].methods[0].name)
308
332
  .to eq("method1")
309
333
 
310
- expect(@syntax.fileElements[0].classes[0].methods[0].conditionals[0]
311
- .expression).to eq("x > 3")
312
- expect(@syntax.fileElements[0].classes[0].methods[0].conditionals[0]
313
- .type).to eq("IF")
334
+ expect(allMethod0[0].expression).to eq("x > 3")
335
+ expect(allMethod0[0].type).to eq(Languages::IF_LABEL)
314
336
 
315
337
  expect(@syntax.fileElements[0].classes[0].methods[1].name)
316
338
  .to eq("method2")
317
- expect(@syntax.fileElements[0].classes[0].methods[1].conditionals[0]
318
- .expression).to eq("b && c")
319
- expect(@syntax.fileElements[0].classes[0].methods[1].conditionals[0]
320
- .type).to eq("IF")
339
+ expect(allMethod1[0].expression).to eq("b && c")
340
+ expect(allMethod1[0].type).to eq(Languages::IF_LABEL)
321
341
 
322
342
  expect(@syntax.fileElements[0].classes[0].methods[2].name)
323
343
  .to eq("method3")
324
- expect(@syntax.fileElements[0].classes[0].methods[2].conditionals[0]
325
- .expression).to eq("b == 3")
326
- expect(@syntax.fileElements[0].classes[0].methods[2].conditionals[1]
327
- .expression).to eq("b < 7")
344
+ expect(allMethod2[0].expression).to eq("b == 3")
345
+ expect(allMethod2[1].expression).to eq("b < 7")
328
346
 
329
- expect(@syntax.fileElements[0].classes[0].methods[2].conditionals[0]
330
- .type).to eq("IF")
347
+ expect(allMethod2[0].type).to eq(Languages::IF_LABEL)
331
348
 
332
349
  expect(@syntax.fileElements[0].classes[0].methods[3].name)
333
350
  .to eq("method4")
334
- expect(@syntax.fileElements[0].classes[0].methods[3].conditionals[0]
335
- .expression).to eq("x")
351
+ expect(allMethod3[0].expression).to eq("x")
336
352
  end
337
353
 
338
354
  it "Correct state transition (Constructor)." do
339
- path =
340
- "spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb"
355
+ path = "spec/samples/rubySyntaxParts/" +
356
+ "conditionalStatment/constructorConditional.rb"
341
357
 
342
358
  expect(@syntax.state)
343
359
  .to be_instance_of(StateMachine::OOStructuredFSM::IdleState)
@@ -347,43 +363,46 @@ RSpec.describe Languages::RubySyntax do
347
363
  end
348
364
 
349
365
  it "Correct data capture (conditional - method)" do
350
- path =
351
- "spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb"
366
+ path = "spec/samples/rubySyntaxParts/" +
367
+ "conditionalStatment/constructorConditional.rb"
352
368
 
353
369
  @syntax.analyse_source(path)
370
+ allConstructor = @syntax.fileElements[0].classes[0].constructors[0]
371
+ .managerCondAndLoop.basicStructure
354
372
  expect(@syntax.fileElements[0].classes[0].constructors[0].name)
355
373
  .to eq("initialize")
356
374
 
357
- expect(@syntax.fileElements[0].classes[0].constructors[0].conditionals[0]
358
- .expression).to eq("a > b")
359
- expect(@syntax.fileElements[0].classes[0].constructors[0].conditionals[0]
360
- .type).to eq("IF")
375
+ expect(allConstructor[0].expression).to eq("a > b")
376
+ expect(allConstructor[0].type).to eq(Languages::IF_LABEL)
377
+
378
+ expect(allConstructor[1].expression).to eq("x")
379
+ expect(allConstructor[1].type).to eq(Languages::CASE_LABEL)
361
380
 
362
- expect(@syntax.fileElements[0].classes[0].constructors[0].conditionals[1]
363
- .expression).to eq("x")
364
- expect(@syntax.fileElements[0].classes[0].constructors[0].conditionals[1]
365
- .type).to eq("CASE")
381
+ expect(allConstructor[2].expression).to eq("3")
382
+ expect(allConstructor[2].type).to eq(Languages::WHEN_LABEL)
383
+ expect(allConstructor[3].expression).to eq("8")
384
+ expect(allConstructor[3].type).to eq(Languages::WHEN_LABEL)
385
+ expect(allConstructor[4].expression).to eq("90")
386
+ expect(allConstructor[4].type).to eq(Languages::WHEN_LABEL)
387
+ expect(allConstructor[5].type).to eq(Languages::ELSE_LABEL)
366
388
 
367
- expect(@syntax.fileElements[0].classes[0].constructors[0].conditionals[2]
368
- .expression).to eq("u && y")
369
- expect(@syntax.fileElements[0].classes[0].constructors[0].conditionals[2]
370
- .type).to eq("IF")
389
+ expect(allConstructor[6].expression).to eq("u && y")
390
+ expect(allConstructor[6].type).to eq(Languages::IF_LABEL)
371
391
 
372
- expect(@syntax.fileElements[0].classes[0].constructors[0].conditionals[3]
373
- .expression).to eq("u == 1")
374
- expect(@syntax.fileElements[0].classes[0].constructors[0].conditionals[3]
375
- .type).to eq("ELSIF")
392
+ expect(allConstructor[7].expression).to eq("u == 1")
393
+ expect(allConstructor[7].type).to eq(Languages::ELSIF_LABEL)
376
394
  end
377
395
 
378
396
  it "Correct data capture (repetition[while] - Method)" do
379
397
  path = "spec/samples/rubySyntaxParts/repetition/simpleRepetition.rb"
380
398
 
381
399
  @syntax.analyse_source(path)
382
- expect(@syntax.fileElements[0].classes[0].methods[0].name)
383
- .to eq("simple1")
400
+ allLoop = @syntax.fileElements[0].classes[0]
401
+ .methods[0].managerCondAndLoop.basicStructure
384
402
 
385
- expect(@syntax.fileElements[0].classes[0].methods[0].repetitions[0]
386
- .expression).to eq("i < num")
403
+ expect(@syntax.fileElements[0].classes[0].methods[0].name)
404
+ .to eq("simple1")
405
+ expect(allLoop[0].expression).to eq("i < num")
387
406
  end
388
407
 
389
408
  it "Correct data capture (repetiton[util] - Method)" do
@@ -393,8 +412,9 @@ RSpec.describe Languages::RubySyntax do
393
412
  expect(@syntax.fileElements[0].classes[0].methods[1].name)
394
413
  .to eq("simple2")
395
414
 
396
- expect(@syntax.fileElements[0].classes[0].methods[1].repetitions[0]
397
- .expression).to eq("i > num")
415
+ all = @syntax.fileElements[0].classes[0].methods[1]
416
+ .managerCondAndLoop.basicStructure
417
+ expect(all[0].expression).to eq("i > num")
398
418
 
399
419
  end
400
420
 
@@ -405,8 +425,9 @@ RSpec.describe Languages::RubySyntax do
405
425
  expect(@syntax.fileElements[0].classes[0].methods[1].name)
406
426
  .to eq("simple2")
407
427
 
408
- expect(@syntax.fileElements[0].classes[0].methods[1].repetitions[1]
409
- .expression).to eq("i in 0..5")
428
+ all = @syntax.fileElements[0].classes[0].methods[1]
429
+ .managerCondAndLoop.basicStructure
430
+ expect(all[1].expression).to eq("i in 0..5")
410
431
  end
411
432
 
412
433
  end
@@ -415,7 +436,8 @@ RSpec.describe Languages::RubySyntax do
415
436
 
416
437
  it "Correct single line comment capture - Globals" do
417
438
 
418
- path = "spec/samples/rubySyntaxParts/comment/simple_single_line_comment_global.rb"
439
+ path = "spec/samples/rubySyntaxParts/" +
440
+ "comment/simple_single_line_comment_global.rb"
419
441
 
420
442
  @syntax.analyse_source(path)
421
443
  expect(@syntax.fileElements[0].comments).to eq(" First comment\n")
@@ -429,7 +451,8 @@ RSpec.describe Languages::RubySyntax do
429
451
 
430
452
  it "Correct single line comment capture - Class" do
431
453
 
432
- path = "spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb"
454
+ path = "spec/samples/rubySyntaxParts/" +
455
+ "comment/simple_single_line_comment_class.rb"
433
456
 
434
457
  @syntax.analyse_source(path)
435
458
  expect(@syntax.fileElements[0].classes[0].comments)
@@ -439,14 +462,16 @@ RSpec.describe Languages::RubySyntax do
439
462
  expect(@syntax.fileElements[0].classes[0].methods[0].comments)
440
463
  .to eq(" Comment 3: method\n")
441
464
  expect(@syntax.fileElements[0].classes[0].methods[1].comments)
442
- .to eq(" Comment 4: Combo 1\n Comment 5: Combo 2\n")
465
+ .to eq(" Comment 4: Combo 1\n Comment 5: "+
466
+ "Combo 2\n Comment 6: Combo 3; Combo 4\n")
443
467
  expect(@syntax.fileElements[0].classes[0].attributes[0].comments)
444
- .to eq (" Comment 6: Attribute\n")
468
+ .to eq (" Comment 7: Attribute\n")
445
469
  end
446
470
 
447
471
  it "Correct multiple line comment capture - Global" do
448
472
 
449
- path = "spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_global.rb"
473
+ path = "spec/samples/rubySyntaxParts/" +
474
+ "comment/simple_multiple_line_comment_global.rb"
450
475
 
451
476
  @syntax.analyse_source(path)
452
477
  expect(@syntax.fileElements[0].comments)
@@ -459,7 +484,8 @@ RSpec.describe Languages::RubySyntax do
459
484
 
460
485
  it "Correct multiple line comment capture - Class" do
461
486
 
462
- path = "spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb"
487
+ path = "spec/samples/rubySyntaxParts/" +
488
+ "comment/simple_multiple_line_comment_class.rb"
463
489
 
464
490
  @syntax.analyse_source(path)
465
491
  expect(@syntax.fileElements[0].classes[0].comments)
@@ -470,7 +496,110 @@ RSpec.describe Languages::RubySyntax do
470
496
  .to eq(" First method\n")
471
497
  expect(@syntax.fileElements[0].classes[0].methods[1].comments)
472
498
  .to eq(" methodTwo\n")
499
+ expect(@syntax.fileElements[0].classes[0].methods[2].comments)
500
+ .to eq(" method;Three\n")
501
+
502
+ end
503
+
504
+ end
505
+
506
+ context "Aggregation" do
507
+
508
+ it "Aggregation single line capture in constructor" do
509
+ path = "spec/samples/rubySyntaxParts/" +
510
+ "aggregation/constructorAggregation.rb"
511
+
512
+ @syntax.analyse_source(path)
513
+
514
+ expect(@syntax.fileElements[0].classes[2].aggregations[0].name)
515
+ .to eq("Foo")
516
+ expect(@syntax.fileElements[0].classes[2].aggregations[1].name)
517
+ .to eq("Blah")
518
+ end
519
+
520
+ it "Aggregation single line capture in method" do
521
+ path = "spec/samples/rubySyntaxParts/" +
522
+ "aggregation/methodAggregation.rb"
523
+
524
+ @syntax.analyse_source(path)
525
+
526
+ expect(@syntax.fileElements[0].classes[2].aggregations[0].name)
527
+ .to eq("Test1")
528
+ expect(@syntax.fileElements[0].classes[2].aggregations[1].name)
529
+ .to eq("Test2")
530
+ end
531
+
532
+ it "Aggregation single line capture in class" do
533
+ path = "spec/samples/rubySyntaxParts/" +
534
+ "aggregation/classAggregation.rb"
535
+
536
+ @syntax.analyse_source(path)
537
+
538
+ expect(@syntax.fileElements[0].classes[2].aggregations[0].name)
539
+ .to eq("Class1")
540
+ expect(@syntax.fileElements[0].classes[2].aggregations[1].name)
541
+ .to eq("Class2")
542
+ end
543
+
544
+ it "All aggregations in Metadata array" do
545
+ path = "spec/samples/rubySyntaxParts/" +
546
+ "aggregation/classAggregation.rb"
547
+
548
+
549
+ @syntax.analyse_source(path)
550
+
551
+ expect(@syntax.metadata.allAggregations.size).to eq(2)
552
+ expect(@syntax.metadata.allAggregations[0].name).to eq('Class1')
553
+ expect(@syntax.metadata.allAggregations[1].name).to eq('Class2')
554
+
555
+ end
556
+
557
+ end
558
+
559
+ context 'Second parser' do
560
+
561
+ it 'All Classes should be sorted by name' do
562
+ path = "spec/samples/rubySyntaxParts/" +
563
+ "aggregation/multipleAggregation.rb"
564
+
565
+ @syntax.analyse_source(path)
566
+
567
+ expect(@syntax.metadata.allClasses.size).to eq(5)
568
+ expect(@syntax.metadata.allClasses[0].name).to eq('Class1')
569
+ expect(@syntax.metadata.allClasses[1].name).to eq('Class2')
570
+ expect(@syntax.metadata.allClasses[2].name).to eq('Class3')
571
+ expect(@syntax.metadata.allClasses[3].name).to eq('Class4')
572
+ expect(@syntax.metadata.allClasses[4].name).to eq('Class5')
573
+
574
+ end
575
+
576
+ it 'All Aggregation should be sorted by name and be unique' do
577
+ path = "spec/samples/rubySyntaxParts/" +
578
+ "aggregation/multipleAggregation.rb"
579
+
580
+ @syntax.analyse_source(path)
581
+
582
+ expect(@syntax.metadata.allAggregations.size).to eq(5)
583
+ expect(@syntax.metadata.allAggregations[0].name).to eq('Array')
584
+ expect(@syntax.metadata.allAggregations[1].name).to eq('Class1')
585
+ expect(@syntax.metadata.allAggregations[2].name).to eq('Class2')
586
+ expect(@syntax.metadata.allAggregations[3].name).to eq('Class3')
587
+ expect(@syntax.metadata.allAggregations[4].name).to eq('Set')
588
+ end
589
+
590
+ it 'Ruby default classes should not be present in Aggregation' do
591
+ path = "spec/samples/rubySyntaxParts/" +
592
+ "aggregation/multipleAggregation.rb"
593
+
594
+ @syntax.analyse_source(path)
473
595
 
596
+ expect(@syntax.fileElements[0].classes[4].aggregations.size).to eq(3)
597
+ expect(@syntax.fileElements[0].classes[4].aggregations[0].name)
598
+ .to eq('Class1')
599
+ expect(@syntax.fileElements[0].classes[4].aggregations[1].name)
600
+ .to eq('Class2')
601
+ expect(@syntax.fileElements[0].classes[4].aggregations[2].name)
602
+ .to eq('Class3')
474
603
  end
475
604
 
476
605
  end