kuniri 0.0.1 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,105 @@
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/.kuniri5.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
+ target = "./spec/language/ruby/global_test/conditional/" +
13
+ "constructorVeryMixConditional.xml"
14
+ @output = File.open(target, "r")
15
+ end
16
+
17
+ RSpec.shared_examples "Constructor with conditional" do |regex, description|
18
+ it "Method: #{description}" do
19
+ repetition = nil
20
+ @output.each do |line|
21
+ repetition = line =~ regex
22
+ break unless repetition.nil?
23
+ end
24
+ expect(repetition).not_to be_nil
25
+ end
26
+ end
27
+
28
+ context "Test mix repetition" do
29
+
30
+ message = "Find: case p"
31
+ regex = /\s+<case\sexpression="p"\slevel="0"\/?>/
32
+ include_examples "Constructor with conditional" , regex, message
33
+
34
+ message = "Constructor: Find: when 2"
35
+ regex = /\s+<when\sexpression="2"\slevel="0"\/?>/
36
+ include_examples "Constructor with conditional" , regex, message
37
+
38
+ message = "Constructor: Find: if xpto == level1"
39
+ regex = /\s+<if\sexpression="xpto == 'level1'"\slevel="1"\/?>/
40
+ include_examples "Constructor with conditional" , regex, message
41
+
42
+ message = "Constructor: Find: else"
43
+ regex = /\s+<else\slevel="1"\/?>/
44
+ include_examples "Constructor with conditional" , regex, message
45
+
46
+ message = "Constructor: Find: when 4"
47
+ regex = /\s+<when\sexpression="4"\slevel="0"\/?>/
48
+ include_examples "Constructor with conditional" , regex, message
49
+
50
+ message = "Constructor: Find: if xpto1 == level1"
51
+ regex = /\s+<if\sexpression="xpto1 == 'level1'"\slevel="1"\/?>/
52
+ include_examples "Constructor with conditional" , regex, message
53
+
54
+ message = "Constructor: Find: if xpto2 == level2"
55
+ regex = /\s+<if\sexpression="xpto2 == 'level2'"\slevel="2"\/?>/
56
+ include_examples "Constructor with conditional" , regex, message
57
+
58
+ message = "Constructor: Find: if xpto3 == level3"
59
+ regex = /\s+<if\sexpression="xpto3 == 'level3'"\slevel="3"\/?>/
60
+ include_examples "Constructor with conditional" , regex, message
61
+
62
+ message = "Constructor: Find: elsif abc == level3"
63
+ regex = /\s+<elsif\sexpression="abc == 'level3'"\slevel="3"\/?>/
64
+ include_examples "Constructor with conditional" , regex, message
65
+
66
+ message = "Constructor: Find: elsif level3"
67
+ regex = /\s+<else\slevel="3"\/?>/
68
+ include_examples "Constructor with conditional" , regex, message
69
+
70
+ message = "Constructor: Find: elsif banana == level1"
71
+ regex = /\s+<elsif\sexpression="banana == 'level1'"\slevel="1"\/?>/
72
+ include_examples "Constructor with conditional" , regex, message
73
+
74
+ message = "Constructor: Find: when 7"
75
+ regex = /\s+<when\sexpression="7"\slevel="0"\/?>/
76
+ include_examples "Constructor with conditional" , regex, message
77
+
78
+ message = "Constructor: Find: unless abc == level1"
79
+ regex = /\s+<unless\sexpression="abc == 'level1'"\slevel="1"\/?>/
80
+ include_examples "Constructor with conditional" , regex, message
81
+
82
+ message = "Constructor: Find: if xpto == level2"
83
+ regex = /\s+<if\sexpression="xpto == 'level2'"\slevel="2"\/?>/
84
+ include_examples "Constructor with conditional" , regex, message
85
+
86
+ message = "Constructor: Find: case x"
87
+ regex = /\s+<case\sexpression="x"\slevel="3"\/?>/
88
+ include_examples "Constructor with conditional" , regex, message
89
+
90
+ message = "Constructor: Find: when 6"
91
+ regex = /\s+<when\sexpression="6"\slevel="3"\/?>/
92
+ include_examples "Constructor with conditional" , regex, message
93
+
94
+ message = "Constructor: Find: when 7"
95
+ regex = /\s+<when\sexpression="7"\slevel="3"\/?>/
96
+ include_examples "Constructor with conditional" , regex, message
97
+
98
+ end
99
+
100
+ after :each do
101
+ @kuniri = nil
102
+ @output = nil
103
+ end
104
+
105
+ end
@@ -0,0 +1,94 @@
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/.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
+ target = "./spec/language/ruby/global_test/conditional/output.xml"
13
+ @output = File.open(target, "r")
14
+ end
15
+
16
+ RSpec.shared_examples "Function with conditional" 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 "Simple cases of conditional" do
28
+
29
+ message = "Should have simple if"
30
+ regex = /\s+<if\sexpression="x == 99" level="0"\/?>/
31
+ include_examples "Function with conditional" , regex, message
32
+
33
+ message = "Should have simple if else"
34
+ regex = /\s+<if\sexpression="x == 47" level="0"\/?>/
35
+ include_examples "Function with conditional" , regex, message
36
+
37
+ message = "Else conditional"
38
+ regex = /\s+<else level="0"\/?>/
39
+ include_examples "Function with conditional" , regex, message
40
+
41
+ message = "Should have simple if and elsif"
42
+ regex = /\s+<if\sexpression="x == 555"\slevel="0"\/?>/
43
+ include_examples "Function with conditional" , regex, message
44
+
45
+ message = "Find: elsif x == 777"
46
+ regex = /\s+<elsif\sexpression="x == 777"\slevel="0"\/?>/
47
+ include_examples "Function with conditional" , regex, message
48
+
49
+ message = "Find: elsif x == 777"
50
+ regex = /\s+<elsif\sexpression="x == 111"\slevel="0"\/?>/
51
+ include_examples "Function with conditional" , regex, message
52
+
53
+ message = "Find: if xpto == 778"
54
+ regex = /\s+<if\sexpression="xpto == 778"\slevel="0"\/?>/
55
+ include_examples "Function with conditional" , regex, message
56
+
57
+ message = "Find: if xpto == 778"
58
+ regex = /\s+<elsif\sexpression="abc == 555"\slevel="0"\/?>/
59
+ include_examples "Function with conditional" , regex, message
60
+
61
+ message = "Find: elsif asdf == 'a'"
62
+ regex = /\s+<elsif\sexpression="asdf == 'a'"\slevel="0"\/?>/
63
+ include_examples "Function with conditional" , regex, message
64
+
65
+ message = "Find: else"
66
+ regex = /\s+<else\slevel="0"\/?>/
67
+ include_examples "Function with conditional" , regex, message
68
+
69
+ end
70
+
71
+ context "Verify open and close xml" do
72
+ it "Should verify the opening-closing structure" do
73
+ @stack = []
74
+ @output.each do |line|
75
+ next if line =~ /<\?xml.*/
76
+ next if line =~ /.*\/>/
77
+
78
+ if line =~ /\s*<\/(\w*)>/
79
+ expect(@stack.last).to eq($1)
80
+ @stack.pop
81
+ elsif line =~ /\s*<(\w*)(.*)>/
82
+ @stack.push $1
83
+ end
84
+ end
85
+ expect(@stack.size).to eq(0)
86
+ end
87
+ end
88
+
89
+ after :each do
90
+ @kuniri = nil
91
+ @output = nil
92
+ end
93
+
94
+ end
@@ -0,0 +1,56 @@
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/.kuniri1.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
+ target = "./spec/language/ruby/global_test/conditional/output1.xml"
13
+ @output = File.open(target, "r")
14
+ end
15
+
16
+ RSpec.shared_examples "Nested conditional" do |regex, description|
17
+ it "Nested: #{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 "Function with nested conditional" do
28
+
29
+ message = "Find: if xpto == 'level0'"
30
+ regex = /\s+<if\sexpression="xpto == 'level0'"\slevel="0"\/?>/
31
+ include_examples "Nested conditional" , regex, message
32
+
33
+ message = "Find: if abc == 'level1'"
34
+ regex = /\s+<if\sexpression="abc == 'level1'"\slevel="1"\/?>/
35
+ include_examples "Nested conditional" , regex, message
36
+
37
+ message = "Find: if xyz == 'level0'"
38
+ regex = /\s+<if\sexpression="xyz == 'level0'"\slevel="0"\/?>/
39
+ include_examples "Nested conditional" , regex, message
40
+
41
+ message = "Find: if abc == 'level1'"
42
+ regex = /\s+<if\sexpression="abc == 'level1'" level="1"\/?>/
43
+ include_examples "Nested conditional" , regex, message
44
+
45
+ message = "Find: else"
46
+ regex = /\s+<else level="1"\/?>/
47
+ include_examples "Nested conditional" , regex, message
48
+
49
+ end
50
+
51
+ after :each do
52
+ @kuniri = nil
53
+ @output = nil
54
+ end
55
+
56
+ end
@@ -0,0 +1,109 @@
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/.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
+ target = "./spec/language/ruby/global_test/conditional/" +
13
+ "methodVeryMixConditional.xml"
14
+ @output = File.open(target, "r")
15
+ end
16
+
17
+ RSpec.shared_examples "Method with mix conditional" do |regex, description|
18
+ it "Method: #{description}" do
19
+ conditional = nil
20
+ @output.each do |line|
21
+ conditional = line =~ regex
22
+ break unless conditional.nil?
23
+ end
24
+ expect(conditional).not_to be_nil
25
+ end
26
+ end
27
+
28
+ context "Method with mix conditional" do
29
+
30
+ message = "Find: case p"
31
+ regex = /\s+<case\sexpression="p"\slevel="0"\/?>/
32
+ include_examples "Method with mix conditional" , regex, message
33
+
34
+ message = "Find: when 2"
35
+ regex = /\s+<when\sexpression="2"\slevel="0"\/?>/
36
+ include_examples "Method with mix conditional" , regex, message
37
+
38
+ message = "Find: if xpto == 'level1'"
39
+ regex = /\s+<if\sexpression="xpto == 'level1'"\slevel="1"\/?>/
40
+ include_examples "Method with mix conditional" , regex, message
41
+
42
+ message = "Find: else"
43
+ regex = /\s+<else\slevel="1"\/?>/
44
+ include_examples "Method with mix conditional" , regex, message
45
+
46
+ message = "Find: when 4"
47
+ regex = /\s+<when\sexpression="4"\slevel="0"\/?>/
48
+ include_examples "Method with mix conditional" , regex, message
49
+
50
+ message = "Find: if xpto1 == 'level1'"
51
+ regex = /\s+<if\sexpression="xpto1 == 'level1'"\slevel="1"\/?>/
52
+ include_examples "Method with mix conditional" , regex, message
53
+
54
+ message = "Find: if xpto2 == 'level2'"
55
+ regex = /\s+<if\sexpression="xpto2 == 'level2'"\slevel="2"\/?>/
56
+ include_examples "Method with mix conditional" , regex, message
57
+
58
+ message = "Find: if xpto3 == 'level3'"
59
+ regex = /\s+<if\sexpression="xpto3 == 'level3'"\slevel="3"\/?>/
60
+ include_examples "Method with mix conditional" , regex, message
61
+
62
+ message = "Find: elsif abc == 'level3'"
63
+ regex = /\s+<elsif\sexpression="abc == 'level3'"\slevel="3"\/?>/
64
+ include_examples "Method with mix conditional" , regex, message
65
+
66
+ message = "Find: else"
67
+ regex = /\s+<else\slevel="3"\/?>/
68
+ include_examples "Method with mix conditional" , regex, message
69
+
70
+ message = "Find: elsif banana == 'level1'"
71
+ regex = /\s+<elsif\sexpression="banana == 'level1'"\slevel="1"\/?>/
72
+ include_examples "Method with mix conditional" , regex, message
73
+
74
+ message = "Find: when 7"
75
+ regex = /\s+<when\sexpression="7"\slevel="0"\/?>/
76
+ include_examples "Method with mix conditional" , regex, message
77
+
78
+ message = "Find: unless abc == 'level1'"
79
+ regex = /\s+<unless\sexpression="abc == 'level1'"\slevel="1"\/?>/
80
+ include_examples "Method with mix conditional" , regex, message
81
+
82
+ message = "Find: if xpto == 'level2'"
83
+ regex = /\s+<if\sexpression="xpto == 'level2'"\slevel="2"\/?>/
84
+ include_examples "Method with mix conditional" , regex, message
85
+
86
+ message = "Find: if xpto == 'level2'"
87
+ regex = /\s+<if\sexpression="xpto == 'level2'"\slevel="2"\/?>/
88
+ include_examples "Method with mix conditional" , regex, message
89
+
90
+ message = "Find: if x == 'level3'"
91
+ regex = /\s+<case\sexpression="x"\slevel="3"\/?>/
92
+ include_examples "Method with mix conditional" , regex, message
93
+
94
+ message = "Find: when 6"
95
+ regex = /\s+<when\sexpression="6"\slevel="3"\/?>/
96
+ include_examples "Method with mix conditional" , regex, message
97
+
98
+ message = "Find: when 6"
99
+ regex = /\s+<when\sexpression="7"\slevel="3"\/?>/
100
+ include_examples "Method with mix conditional" , regex, message
101
+
102
+ end
103
+
104
+ after :each do
105
+ @kuniri = nil
106
+ @output = nil
107
+ end
108
+
109
+ end
@@ -0,0 +1,61 @@
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/.kuniri3.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
+ target = "./spec/language/ruby/global_test/conditional/" +
13
+ "veryDeepConditionalStructure.xml"
14
+ @output = File.open(target, "r")
15
+ end
16
+
17
+ RSpec.shared_examples "Deep conditional" do |regex, description|
18
+ it "Method: #{description}" do
19
+ conditional = nil
20
+ @output.each do |line|
21
+ conditional = line =~ regex
22
+ break unless conditional.nil?
23
+ end
24
+ expect(conditional).not_to be_nil
25
+ end
26
+ end
27
+
28
+ context "Very deep conditional" do
29
+
30
+ message = "Find: if conditional0 == 'level0'"
31
+ regex = /\s+<if\sexpression="conditional0 == 'level0'"\slevel="0"\/?>/
32
+ include_examples "Constructor with conditional" , regex, message
33
+
34
+ message = "Find: if conditional1 == 'level1'"
35
+ regex = /\s+<if\sexpression="conditional1 == 'level1'"\slevel="1"\/?>/
36
+ include_examples "Constructor with conditional" , regex, message
37
+
38
+ message = "Find: if conditional2 == 'level2'"
39
+ regex = /\s+<if\sexpression="conditional2 == 'level2'"\slevel="2"\/?>/
40
+ include_examples "Constructor with conditional" , regex, message
41
+
42
+ message = "Find: if conditional2 == 'level2'"
43
+ regex = /\s+<if\sexpression="conditional15 == 'level15'"\slevel="15"\/?>/
44
+ include_examples "Constructor with conditional" , regex, message
45
+
46
+ message = "Find: if conditional19 == 'level19'"
47
+ regex = /\s+<if\sexpression="conditional19 == 'level19'"\slevel="19"\/?>/
48
+ include_examples "Constructor with conditional" , regex, message
49
+
50
+ message = "Find: elsif firstElse == 'level19'"
51
+ regex = /\s+<elsif\sexpression="firstElse == 'level19'"\slevel="19"\/?>/
52
+ include_examples "Constructor with conditional" , regex, message
53
+
54
+ end
55
+
56
+ after :each do
57
+ @kuniri = nil
58
+ @output = nil
59
+ end
60
+
61
+ end
@@ -0,0 +1,105 @@
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/.kuniri4.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
+ target = "./spec/language/ruby/global_test/conditional/" +
13
+ "veryMixConditional.xml"
14
+ @output = File.open(target, "r")
15
+ end
16
+
17
+ RSpec.shared_examples "Very mix conditional" do |regex, description|
18
+ it "Method: #{description}" do
19
+ conditional = nil
20
+ @output.each do |line|
21
+ conditional = line =~ regex
22
+ break unless conditional.nil?
23
+ end
24
+ expect(conditional).not_to be_nil
25
+ end
26
+ end
27
+
28
+ context "Very mix with conditional" do
29
+
30
+ message = "Find: case p"
31
+ regex = /\s+<case\sexpression="p"\slevel="0"\/?>/
32
+ include_examples "Very mix conditional" , regex, message
33
+
34
+ message = "Find: when 2"
35
+ regex = /\s+<when\sexpression="2"\slevel="0"\/?>/
36
+ include_examples "Very mix conditional" , regex, message
37
+
38
+ message = "Find: if xpto == 'level1'"
39
+ regex = /\s+<if\sexpression="xpto == 'level1'"\slevel="1"\/?>/
40
+ include_examples "Very mix conditional" , regex, message
41
+
42
+ message = "Find: else"
43
+ regex = /\s+<else\slevel="1"\/?>/
44
+ include_examples "Very mix conditional" , regex, message
45
+
46
+ message = "Find: when 4"
47
+ regex = /\s+<when\sexpression="4"\slevel="0"\/?>/
48
+ include_examples "Very mix conditional" , regex, message
49
+
50
+ message = "Find: if xpto1 == 'level1'"
51
+ regex = /\s+<if\sexpression="xpto1 == 'level1'"\slevel="1"\/?>/
52
+ include_examples "Very mix conditional" , regex, message
53
+
54
+ message = "Find: if xpto2 == 'level2'"
55
+ regex = /\s+<if\sexpression="xpto2 == 'level2'"\slevel="2"\/?>/
56
+ include_examples "Very mix conditional" , regex, message
57
+
58
+ message = "Find: if xpto3 == 'level3'"
59
+ regex = /\s+<if\sexpression="xpto3 == 'level3'"\slevel="3"\/?>/
60
+ include_examples "Very mix conditional" , regex, message
61
+
62
+ message = "Find: elsif abc == 'level3'"
63
+ regex = /\s+<elsif\sexpression="abc == 'level3'"\slevel="3"\/?>/
64
+ include_examples "Very mix conditional" , regex, message
65
+
66
+ message = "Find: else"
67
+ regex = /\s+<else\slevel="3"\/?>/
68
+ include_examples "Very mix conditional" , regex, message
69
+
70
+ message = "Find: elsif banana == 'level1'"
71
+ regex = /\s+<elsif\sexpression="banana == 'level1'"\slevel="1"\/?>/
72
+ include_examples "Very mix conditional" , regex, message
73
+
74
+ message = "Find: when 7"
75
+ regex = /\s+<when\sexpression="7"\slevel="0"\/?>/
76
+ include_examples "Very mix conditional" , regex, message
77
+
78
+ message = "Find: unless abc == 'level1'"
79
+ regex = /\s+<unless\sexpression="abc == 'level1'"\slevel="1"\/?>/
80
+ include_examples "Very mix conditional" , regex, message
81
+
82
+ message = "Find: if xpto == 'level2'"
83
+ regex = /\s+<if\sexpression="xpto == 'level2'"\slevel="2"\/?>/
84
+ include_examples "Very mix conditional" , regex, message
85
+
86
+ message = "Find: case x"
87
+ regex = /\s+<case\sexpression="x"\slevel="3"\/?>/
88
+ include_examples "Very mix conditional" , regex, message
89
+
90
+ message = "Find: when 6"
91
+ regex = /\s+<when\sexpression="6"\slevel="3"\/?>/
92
+ include_examples "Very mix conditional" , regex, message
93
+
94
+ message = "Find: when 7"
95
+ regex = /\s+<when\sexpression="7"\slevel="3"\/?>/
96
+ include_examples "Very mix conditional" , regex, message
97
+
98
+ end
99
+
100
+ after :each do
101
+ @kuniri = nil
102
+ @output = nil
103
+ end
104
+
105
+ end