kuniri 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +43 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +18 -0
  5. data/.yardopts +1 -0
  6. data/COPYING +661 -0
  7. data/Gemfile +14 -0
  8. data/Guardfile +8 -0
  9. data/README.md +102 -0
  10. data/Rakefile +114 -0
  11. data/bin/kuniri +53 -0
  12. data/data/attribute_lang.rb +131 -0
  13. data/data/class_lang.rb +77 -0
  14. data/data/conditional_lang.rb +71 -0
  15. data/data/constructor_lang.rb +34 -0
  16. data/data/end_block_lang.rb +30 -0
  17. data/data/extern_requirement_lang.rb +45 -0
  18. data/data/function_behavior_lang.rb +113 -0
  19. data/data/lang_syntax.rb +111 -0
  20. data/data/module_namespace_lang.rb +43 -0
  21. data/data/repetition_lang.rb +62 -0
  22. data/data/token_lang.rb +55 -0
  23. data/data/variable_global_lang.rb +118 -0
  24. data/kuniri.gemspec +24 -0
  25. data/lib/kuniri/core/configuration/language_available.rb +7 -0
  26. data/lib/kuniri/core/configuration/log_available.rb +7 -0
  27. data/lib/kuniri/core/configuration/monitor_available.rb +13 -0
  28. data/lib/kuniri/core/kuniri.rb +78 -0
  29. data/lib/kuniri/core/setting.rb +143 -0
  30. data/lib/kuniri/error/configuration_file_error.rb +12 -0
  31. data/lib/kuniri/error/language_error.rb +12 -0
  32. data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +73 -0
  33. data/lib/kuniri/language/abstract_container/structured_and_oo/class.rb +51 -0
  34. data/lib/kuniri/language/abstract_container/structured_and_oo/comment.rb +57 -0
  35. data/lib/kuniri/language/abstract_container/structured_and_oo/conditional.rb +42 -0
  36. data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +52 -0
  37. data/lib/kuniri/language/abstract_container/structured_and_oo/end_block.rb +27 -0
  38. data/lib/kuniri/language/abstract_container/structured_and_oo/extern_requirement.rb +36 -0
  39. data/lib/kuniri/language/abstract_container/structured_and_oo/function_behavior.rb +55 -0
  40. data/lib/kuniri/language/abstract_container/structured_and_oo/module_namespace.rb +36 -0
  41. data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +42 -0
  42. data/lib/kuniri/language/abstract_container/structured_and_oo/variable_behaviour.rb +53 -0
  43. data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +67 -0
  44. data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +26 -0
  45. data/lib/kuniri/language/container_data/structured_and_oo/basic_data.rb +18 -0
  46. data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +77 -0
  47. data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +23 -0
  48. data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +18 -0
  49. data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +26 -0
  50. data/lib/kuniri/language/container_data/structured_and_oo/file_element.rb +77 -0
  51. data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +52 -0
  52. data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +21 -0
  53. data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +20 -0
  54. data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +18 -0
  55. data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +23 -0
  56. data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +22 -0
  57. data/lib/kuniri/language/language.rb +222 -0
  58. data/lib/kuniri/language/language_factory.rb +48 -0
  59. data/lib/kuniri/language/ruby/attribute_ruby.rb +134 -0
  60. data/lib/kuniri/language/ruby/class_ruby.rb +83 -0
  61. data/lib/kuniri/language/ruby/comment_ruby.rb +84 -0
  62. data/lib/kuniri/language/ruby/conditional_ruby.rb +77 -0
  63. data/lib/kuniri/language/ruby/constructor_ruby.rb +36 -0
  64. data/lib/kuniri/language/ruby/end_block_ruby.rb +33 -0
  65. data/lib/kuniri/language/ruby/extern_requirement_ruby.rb +49 -0
  66. data/lib/kuniri/language/ruby/function_behavior_ruby.rb +120 -0
  67. data/lib/kuniri/language/ruby/module_namespace_ruby.rb +47 -0
  68. data/lib/kuniri/language/ruby/repetition_ruby.rb +68 -0
  69. data/lib/kuniri/language/ruby/ruby_syntax.rb +117 -0
  70. data/lib/kuniri/language/ruby/token_ruby.rb +59 -0
  71. data/lib/kuniri/language/ruby/variable_behaviour_ruby.rb +83 -0
  72. data/lib/kuniri/language/ruby/variable_global_ruby.rb +123 -0
  73. data/lib/kuniri/parser/parser.rb +45 -0
  74. data/lib/kuniri/parser/parser_xml.rb +128 -0
  75. data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +51 -0
  76. data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +94 -0
  77. data/lib/kuniri/state_machine/OO_structured_fsm/comment_state.rb +76 -0
  78. data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +92 -0
  79. data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +71 -0
  80. data/lib/kuniri/state_machine/OO_structured_fsm/function_state.rb +82 -0
  81. data/lib/kuniri/state_machine/OO_structured_fsm/idle_state.rb +80 -0
  82. data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +59 -0
  83. data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +69 -0
  84. data/lib/kuniri/state_machine/OO_structured_fsm/module_state.rb +79 -0
  85. data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +92 -0
  86. data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +85 -0
  87. data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +8 -0
  88. data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +49 -0
  89. data/lib/kuniri/util/html_logger.rb +41 -0
  90. data/lib/kuniri/util/logger.rb +34 -0
  91. data/lib/kuniri/util/txt_logger.rb +29 -0
  92. data/lib/kuniri/version.rb +3 -0
  93. data/lib/kuniri.rb +5 -0
  94. data/other/analyseFile.asta +0 -0
  95. data/spec/core/kuniri_spec.rb +14 -0
  96. data/spec/core/setting_spec.rb +114 -0
  97. data/spec/language/abstract_container/attribute_spec.rb +13 -0
  98. data/spec/language/abstract_container/class_spec.rb +13 -0
  99. data/spec/language/abstract_container/comment_spec.rb +31 -0
  100. data/spec/language/abstract_container/conditional_spec.rb +13 -0
  101. data/spec/language/abstract_container/constructor_spec.rb +13 -0
  102. data/spec/language/abstract_container/end_block_spec.rb +14 -0
  103. data/spec/language/abstract_container/module_namespace_spec.rb +13 -0
  104. data/spec/language/abstract_container/repetition_spec.rb +13 -0
  105. data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +32 -0
  106. data/spec/language/container_data/structured_and_oo/class_data_spec.rb +121 -0
  107. data/spec/language/container_data/structured_and_oo/conditional_data_spec.rb +34 -0
  108. data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +46 -0
  109. data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +26 -0
  110. data/spec/language/container_data/structured_and_oo/file_element_spec.rb +91 -0
  111. data/spec/language/container_data/structured_and_oo/function_data_spec.rb +22 -0
  112. data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +20 -0
  113. data/spec/language/container_data/structured_and_oo/repetition_data_spec.rb +34 -0
  114. data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +39 -0
  115. data/spec/language/language_factory_spec.rb +64 -0
  116. data/spec/language/language_spec.rb +74 -0
  117. data/spec/language/ruby/attribute_ruby_spec.rb +126 -0
  118. data/spec/language/ruby/class_ruby_spec.rb +102 -0
  119. data/spec/language/ruby/comment_ruby_spec.rb +78 -0
  120. data/spec/language/ruby/conditional_ruby_spec.rb +106 -0
  121. data/spec/language/ruby/constructor_ruby_spec.rb +57 -0
  122. data/spec/language/ruby/end_block_ruby_spec.rb +62 -0
  123. data/spec/language/ruby/function_behavior_ruby_spec.rb +246 -0
  124. data/spec/language/ruby/module_namespace_ruby_spec.rb +55 -0
  125. data/spec/language/ruby/repetition_ruby_spec.rb +33 -0
  126. data/spec/language/ruby/ruby_syntax_spec.rb +482 -0
  127. data/spec/language/ruby/variable_ruby_spec.rb +134 -0
  128. data/spec/parser/parser_spec.rb +25 -0
  129. data/spec/samples/rubySyntaxParts/attribute/simpleAttribute.rb +15 -0
  130. data/spec/samples/rubySyntaxParts/class/simpleClass.rb +19 -0
  131. data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +33 -0
  132. data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_global.rb +20 -0
  133. data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +23 -0
  134. data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_global.rb +16 -0
  135. data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +28 -0
  136. data/spec/samples/rubySyntaxParts/conditionalStatment/methodConditional.rb +42 -0
  137. data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +0 -0
  138. data/spec/samples/rubySyntaxParts/conditionalStatment/simpleConditional.rb +43 -0
  139. data/spec/samples/rubySyntaxParts/constructor/simpleConstructor.rb +27 -0
  140. data/spec/samples/rubySyntaxParts/extern/multipleLineExternRequirement.rb +0 -0
  141. data/spec/samples/rubySyntaxParts/extern/requireRelative.rb +6 -0
  142. data/spec/samples/rubySyntaxParts/extern/simpleExternRequirement.rb +14 -0
  143. data/spec/samples/rubySyntaxParts/fullCode/simpleCodeWithConditional.rb +18 -0
  144. data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +19 -0
  145. data/spec/samples/rubySyntaxParts/function/simpleFunction.rb +29 -0
  146. data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +13 -0
  147. data/spec/samples/rubySyntaxParts/module/simpleModule.rb +12 -0
  148. data/spec/samples/rubySyntaxParts/repetition/simpleRepetition.rb +28 -0
  149. data/spec/samples/rubySyntaxParts/variable/simpleVariable.rb +13 -0
  150. data/spec/spec_helper.rb +20 -0
  151. data/spec/state_machine/OO_structured_fsm/attribute_state_spec.rb +44 -0
  152. data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +90 -0
  153. data/spec/state_machine/OO_structured_fsm/comment_state_spec.rb +30 -0
  154. data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +83 -0
  155. data/spec/state_machine/OO_structured_fsm/constructor_state_spec.rb +48 -0
  156. data/spec/state_machine/OO_structured_fsm/function_state_spec.rb +41 -0
  157. data/spec/state_machine/OO_structured_fsm/idle_state_spec.rb +101 -0
  158. data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +62 -0
  159. data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +42 -0
  160. data/spec/state_machine/OO_structured_fsm/module_state_spec.rb +54 -0
  161. data/spec/state_machine/OO_structured_fsm/oo_structured_state_spec.rb +0 -0
  162. data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +83 -0
  163. data/spec/state_machine/OO_structured_fsm/variable_state_spec.rb +40 -0
  164. data/spec/util/html_logger_spec.rb +31 -0
  165. data/spec/util/logger_spec.rb +20 -0
  166. data/spec/util/txt_logger_spec.rb +31 -0
  167. metadata +326 -0
@@ -0,0 +1,114 @@
1
+ require_relative '../spec_helper'
2
+
3
+ RSpec.describe Kuniri::Setting do
4
+
5
+ def write_kuniri_file(parameter)
6
+ File.open(".kuniri", 'w') do |file|
7
+ file.write("language" + parameter[0] + "\n")
8
+ file.write("source" + parameter[1] + "\n")
9
+ file.write("output" + parameter[2] + "\n")
10
+ file.write("extract" + parameter[3] + "\n")
11
+ file.write("log" + parameter[4] + "\n")
12
+ end
13
+ end
14
+
15
+ before :all do
16
+ File.open(".kuniri", 'w') do |file|
17
+ file.write("language:ruby" + "\n")
18
+ file.write("source:xpto" + "\n")
19
+ file.write("output:xpto/2" + "\n")
20
+ file.write("extract:uml,traceability" + "\n")
21
+ file.write("log:html\n")
22
+ end
23
+ @settings = Kuniri::Setting.create
24
+ end
25
+
26
+ context "When setting is created." do
27
+ it "Only one reference of Setting." do
28
+ @settingsTwo = Kuniri::Setting.create
29
+ expect((@settingsTwo == @settings)).to be true
30
+ end
31
+ end
32
+
33
+ context "When configuration file is wrong." do
34
+ it "Wrong path, get default configuration" do
35
+ defaultConf = @settings.read_configuration_file("wrong/path")
36
+ expect(defaultConf).to include(
37
+ "language" => "ruby",
38
+ "source" => "./",
39
+ "output" => "./",
40
+ "extract" => "uml",
41
+ "log" => "html")
42
+ end
43
+
44
+ it "Syntax error: not use ':'." do
45
+ write_kuniri_file(["=ruby", ":../app/", ":./", ">uml", ":html"])
46
+ expect{@settings.read_configuration_file(".kuniri")}.to raise_error(
47
+ Error::ConfigurationFileError)
48
+ end
49
+
50
+ it "Syntax error: not valid language." do
51
+ write_kuniri_file([":k", ":../app/", ":./", ":uml", ":html"])
52
+ expect{@settings.read_configuration_file(".kuniri")}.to raise_error(
53
+ Error::ConfigurationFileError)
54
+ end
55
+
56
+ it "Syntax error: wrong source directory." do
57
+ write_kuniri_file([":ruby", ":xpto/", ":./", ":uml", ":html"])
58
+ expect{@settings.read_configuration_file(".kuniri")}.to raise_error(
59
+ Error::ConfigurationFileError)
60
+ end
61
+
62
+ it "Syntax error: wrong output directory." do
63
+ write_kuniri_file([":ruby", ":../app/", ":xpto/", ":uml", ":html"])
64
+ expect{@settings.read_configuration_file(".kuniri")}.to raise_error(
65
+ Error::ConfigurationFileError)
66
+ end
67
+
68
+ it "Syntax error: wrong extract." do
69
+ write_kuniri_file([":ruby", ":../app/", ":./", ":umg", ":html"])
70
+ expect{@settings.read_configuration_file(".kuniri")}.to raise_error(
71
+ Error::ConfigurationFileError)
72
+ end
73
+
74
+ end
75
+
76
+ context "When input is correct." do
77
+ it "Correct return." do
78
+ write_kuniri_file([":ruby", ":./", ":./", ":uml", ":html"])
79
+ hash_config = @settings.read_configuration_file(".kuniri")
80
+ expect(hash_config).to include(
81
+ "language" => "ruby",
82
+ "source" => "./",
83
+ "output" => "./",
84
+ "extract" => "uml",
85
+ "log" => "html")
86
+ end
87
+
88
+ it "Correct return, different parameters." do
89
+ write_kuniri_file([":ruby", ":./", ":./", ":uml", ":txt"])
90
+ hash_config = @settings.read_configuration_file(".kuniri")
91
+ expect(hash_config).to include(
92
+ "language" => "ruby",
93
+ "source" => "./",
94
+ "output" => "./",
95
+ "extract" => "uml",
96
+ "log" => "txt")
97
+ end
98
+
99
+
100
+ it "Correct return: Case sensitive language." do
101
+ write_kuniri_file([":ruBy", ":lib/", ":./", ":uMl, traCeaBilitY", ":txt"])
102
+ expect(@settings.read_configuration_file(".kuniri")).to include(
103
+ "language" => "ruby",
104
+ "source" => "lib/",
105
+ "output" => "./",
106
+ "extract" => "uml,traceability",
107
+ "log" => "txt")
108
+ end
109
+ end
110
+
111
+ after :all do
112
+ File.delete(".kuniri")
113
+ end
114
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ RSpec.describe Languages::Attribute do
4
+
5
+ context "When not implemented" do
6
+ it "Get attribute" do
7
+ attributeAbstract = Languages::Attribute.new
8
+ expect{attributeAbstract.get_attribute("nothing")}.to raise_error(
9
+ NotImplementedError)
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ RSpec.describe Languages::Class do
4
+
5
+ context "When not implemented" do
6
+ it "Get class" do
7
+ classAbstract = Languages::Class.new
8
+ expect{classAbstract.get_class("nothing")}.to raise_error(
9
+ NotImplementedError)
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,31 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ RSpec.describe Languages::Comment do
4
+
5
+ before :all do
6
+ @commentAbstract = Languages::Comment.new
7
+ end
8
+
9
+ context "When comment is not implemented" do
10
+ it "Get comment" do
11
+ expect{@commentAbstract.get_comment("# nothing")}.to raise_error(
12
+ NotImplementedError)
13
+ end
14
+
15
+ it "Is single line comment?" do
16
+ expect{@commentAbstract.is_single_line_comment?(" # Single line")}
17
+ .to raise_error(NotImplementedError)
18
+ end
19
+
20
+ it "Is multiple line comment?" do
21
+ expect{@commentAbstract.is_multiple_line_comment?("=begin")}
22
+ .to raise_error(NotImplementedError)
23
+ end
24
+
25
+ end
26
+
27
+ after :all do
28
+ @commentAbstract = nil
29
+ end
30
+
31
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ RSpec.describe Languages::Conditional do
4
+
5
+ context "When not implemented" do
6
+ it "Get conditional." do
7
+ conditionalAbstract = Languages::Conditional.new
8
+ expect{conditionalAbstract.get_conditional("if x > y")}.to raise_error(
9
+ NotImplementedError)
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ RSpec.describe Languages::Constructor do
4
+
5
+ context "When not implemented" do
6
+ it "Get constructor" do
7
+ constructorAbstract = Languages::Constructor.new
8
+ expect{constructorAbstract.get_constructor("xpto")}.to raise_error(
9
+ NotImplementedError)
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,14 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ RSpec.describe Languages::EndBlock do
4
+
5
+ context "When not implemented" do
6
+ it "Has end of block?" do
7
+ endAbstract = Languages::EndBlock.new
8
+ expect{endAbstract.has_end_of_block?("end")}.to raise_error(
9
+ NotImplementedError)
10
+ end
11
+ end
12
+
13
+
14
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ RSpec.describe Languages::ModuleNamespace do
4
+
5
+ context "When not implemented" do
6
+ it "Get module" do
7
+ moduleAbstract = Languages::ModuleNamespace.new
8
+ expect{moduleAbstract.get_module("module Nothing")}.to raise_error(
9
+ NotImplementedError)
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ RSpec.describe Languages::Repetition do
4
+
5
+ context "When not implemented" do
6
+ it "Get repetition." do
7
+ repetitionAbstract = Languages::Repetition.new
8
+ expect{repetitionAbstract.get_repetition("do")}.to raise_error(
9
+ NotImplementedError)
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,32 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ RSpec.describe Languages::AttributeData do
4
+
5
+ before :all do
6
+ @attributeData = Languages::AttributeData.new("xpto")
7
+ end
8
+
9
+ context "# Attribute data" do
10
+ it "Get name" do
11
+ expect(@attributeData.name).to eq("xpto")
12
+
13
+ @attributeData.name = "banana"
14
+ expect(@attributeData.name).to eq("banana")
15
+ end
16
+
17
+ it "Get visibility" do
18
+ expect(@attributeData.visibility).to eq("public")
19
+
20
+ @attributeData.visibility = "private"
21
+ expect(@attributeData.visibility).to eq("private")
22
+
23
+ @attributeData.visibility = "protected"
24
+ expect(@attributeData.visibility).to eq("protected")
25
+ end
26
+ end
27
+
28
+ after :all do
29
+ @attributeData = nil
30
+ end
31
+
32
+ end
@@ -0,0 +1,121 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ RSpec.describe Languages::ClassData do
4
+
5
+ before :each do
6
+ @classData = Languages::ClassData.new
7
+ @classData.name = "Xpto"
8
+ end
9
+
10
+ context "When set and get class name" do
11
+
12
+ it "Get class name." do
13
+ expect(@classData.name).to eq("Xpto")
14
+ end
15
+
16
+ it "Set class name." do
17
+ @classData.name = "Abc"
18
+ expect(@classData.name).to eq("Abc")
19
+ end
20
+
21
+ it "Visibility." do
22
+ expect(@classData.visibility).to eq("public")
23
+
24
+ @classData.visibility = "private"
25
+ expect(@classData.visibility).to eq("private")
26
+ end
27
+ end
28
+
29
+ RSpec.shared_examples "Add attribute" do |attributes, description|
30
+
31
+ it ": #{description}" do
32
+
33
+ listOfAttributes = []
34
+
35
+ attributes.each do |nameElement|
36
+ listOfAttributes.push(Languages::AttributeData.new(nameElement))
37
+ end
38
+
39
+ @classData.add_attribute(listOfAttributes)
40
+
41
+ attributeList = @classData.attributes
42
+ listResult = []
43
+
44
+ attributeList.each do |element|
45
+ listResult.push(element.name)
46
+ end
47
+
48
+ expect(listResult).to match_array(attributes)
49
+ end
50
+
51
+ end
52
+
53
+ context "When add attribute" do
54
+ it "No attribute." do
55
+ attributes = @classData.get_attributes
56
+ expect(attributes).to eq([])
57
+ end
58
+
59
+ message = "Add 1 element."
60
+ include_examples "Add attribute", ["value1"], message
61
+
62
+ message = "Add 2 element."
63
+ include_examples "Add attribute", ["value1", "value2"], message
64
+
65
+ message = "Add 3 element."
66
+ include_examples "Add attribute", ["value1", "value2", "value3"], message
67
+ end
68
+
69
+ RSpec.shared_examples "Add method" do |methods, description|
70
+
71
+ it ": #{description}" do
72
+
73
+ methods.each do |element|
74
+ method = Languages::FunctionData.new(element)
75
+ @classData.add_method(method)
76
+ end
77
+
78
+ methodList = @classData.get_methods
79
+ listResult = []
80
+ methodList.each do |element|
81
+ listResult.push(element.name)
82
+ end
83
+ expect(listResult).to match_array(methods)
84
+ end
85
+
86
+ end
87
+
88
+
89
+ context "When add method" do
90
+ it "No method" do
91
+ methods = @classData.get_methods
92
+ expect(methods).to eq([])
93
+ end
94
+
95
+ message = "Add 1 method."
96
+ include_examples "Add method", ["method1"], message
97
+
98
+ message = "Add 2 method"
99
+ include_examples "Add method", ["method1", "method2"], message
100
+ end
101
+
102
+ context "When add constructor" do
103
+ it "Add constructors" do
104
+ constructorAdd = Languages::FunctionData.new("constructor")
105
+ @classData.add_constructor(constructorAdd)
106
+ constructors = @classData.get_constructors
107
+ expect(constructors[0].name == "constructor").to be true
108
+ end
109
+
110
+ it "Try to add non-constructor" do
111
+ @classData.add_constructor("xpto")
112
+ expect(@classData.get_constructors).to match_array([])
113
+ end
114
+
115
+ end
116
+
117
+ after :each do
118
+ @classData = nil
119
+ end
120
+
121
+ end
@@ -0,0 +1,34 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ RSpec.describe Languages::ConditionalData do
4
+
5
+ before :each do
6
+ @conditionalData = Languages::ConditionalData.new
7
+ end
8
+
9
+ context "When if conditional." do
10
+ it "Set type." do
11
+ @conditionalData.type = "if"
12
+ expect(@conditionalData.type).to eq("if")
13
+ end
14
+
15
+ it "Simple expression." do
16
+ @conditionalData.expression = "x > 3"
17
+ expect(@conditionalData.expression).to eq("x > 3")
18
+
19
+ @conditionalData.expression = "5 < 3"
20
+ expect(@conditionalData.expression).to eq("5 < 3")
21
+
22
+ @conditionalData.expression = "abc == 'x'"
23
+ expect(@conditionalData.expression).to eq("abc == 'x'")
24
+
25
+ @conditionalData.expression = "x >= 3"
26
+ expect(@conditionalData.expression).to eq("x >= 3")
27
+ end
28
+ end
29
+
30
+ after :each do
31
+ @conditional = nil
32
+ end
33
+
34
+ end
@@ -0,0 +1,46 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ RSpec.describe Languages::ConstructorData do
4
+
5
+ before :each do
6
+ @constructorData = Languages::ConstructorData.new("initialize")
7
+ end
8
+
9
+ context "When constructor without parameters" do
10
+ it "Constructor name" do
11
+ @constructorData.name = "initialize"
12
+ expect(@constructorData.name).to eq("initialize")
13
+ end
14
+ end
15
+
16
+ context "When constructor has parameter" do
17
+ it "Add 1 attributes." do
18
+ @constructorData.add_parameters("value1")
19
+ attributes = @constructorData.parameters
20
+ expect(attributes).to match_array(["value1"])
21
+ end
22
+
23
+ it "Add 2 attributes." do
24
+ @constructorData.add_parameters("value1")
25
+ @constructorData.add_parameters("value2")
26
+ attributes = @constructorData.parameters
27
+ expect(attributes).to match_array(["value1", "value2"])
28
+ end
29
+ end
30
+
31
+ context "When have codiditional statements." do
32
+ it "Simple case of conditional statment" do
33
+ condiditonal = Languages::ConditionalData.new
34
+ condiditonal.type = "IF"
35
+ condiditonal.expression = "x > 3"
36
+ @constructorData.add_conditional(condiditonal)
37
+ expect(@constructorData.conditionals[0].instance_of?(
38
+ Languages::ConditionalData)).to eq(true)
39
+ end
40
+ end
41
+
42
+ after :each do
43
+ @constructorData = nil
44
+ end
45
+
46
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ RSpec.describe Languages::ExternRequirementData do
4
+
5
+ before :all do
6
+ @externRequirement = Languages::ExternRequirementData.new("xpto")
7
+ end
8
+
9
+ context "Using constructor to create data container." do
10
+ it "Create container" do
11
+ expect(@externRequirement.name).to eq("xpto")
12
+ end
13
+ end
14
+
15
+ context "When set path" do
16
+ it "Set path." do
17
+ @externRequirement.setPath("xpto")
18
+ expect(@externRequirement.name).to eq("xpto")
19
+ end
20
+ end
21
+
22
+ after :all do
23
+ @externRequirement = nil
24
+ end
25
+
26
+ end
@@ -0,0 +1,91 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ RSpec.describe Languages::FileElement do
4
+
5
+ before :each do
6
+ @fileElement = Languages::FileElement.new ("test")
7
+ @globalFunction1 = Languages::FunctionData.new("xpto")
8
+ @globalFunction2 = Languages::FunctionData.new("second")
9
+ @globalVariable1 = [Languages::VariableGlobalData.new("var1")]
10
+ @globalVariable2 = [Languages::VariableGlobalData.new("var2")]
11
+ @externFile1 = Languages::ExternRequirementData.new ("/dir/1")
12
+ @externFile2 = Languages::ExternRequirementData.new ("/dir/2")
13
+ @class1 = Languages::ClassData.new
14
+ end
15
+
16
+ context "When add global function." do
17
+
18
+ it "Add one global function" do
19
+ @fileElement.add_global_function(@globalFunction1)
20
+ expect(@fileElement.global_functions[0].name == "xpto").to be true
21
+ end
22
+
23
+ it "Add two global functions" do
24
+ @fileElement.add_global_function(@globalFunction1)
25
+ @fileElement.add_global_function(@globalFunction2)
26
+ functionName = []
27
+ @fileElement.global_functions.each do |function|
28
+ functionName.push(function.name)
29
+ end
30
+ expect(functionName).to match_array(["xpto", "second"])
31
+ end
32
+
33
+ it "Add Non function data" do
34
+ @fileElement.add_global_function("xpto")
35
+ expect(@fileElement.global_functions).to match_array([])
36
+ end
37
+
38
+ end
39
+
40
+ context "When add global variable." do
41
+
42
+ it "Add one global variable." do
43
+ @fileElement.add_global_variable(@globalVariable1)
44
+ expect(@fileElement.global_variables[0].name == "var1").to be true
45
+ end
46
+
47
+ it "Add two global variable." do
48
+ @fileElement.add_global_variable(@globalVariable1)
49
+ @fileElement.add_global_variable(@globalVariable2)
50
+ variables = []
51
+ @fileElement.global_variables.each do |variable|
52
+ variables.push(variable.name)
53
+ end
54
+ expect(variables).to match_array(["var1", "var2"])
55
+ end
56
+
57
+ it "Add non global variable." do
58
+ @fileElement.add_global_variable(["xpto"])
59
+ expect(@fileElement.global_variables).to match_array([])
60
+ end
61
+
62
+ end
63
+
64
+ context "When add external files." do
65
+ it "Add one external element." do
66
+ @fileElement.add_extern_requirement(@externFile1)
67
+ expect(@fileElement.extern_requirements[0].name == "/dir/1").to be true
68
+ end
69
+
70
+ it "Add two external elements." do
71
+ @fileElement.add_extern_requirement(@externFile1)
72
+ @fileElement.add_extern_requirement(@externFile2)
73
+ extern = []
74
+ @fileElement.extern_requirements.each do |externs|
75
+ extern.push(externs.name)
76
+ end
77
+ expect(extern).to match_array(["/dir/1", "/dir/2"])
78
+ end
79
+
80
+ it "Add non extern requirement." do
81
+ @fileElement.add_extern_requirement("xpto")
82
+ expect(@fileElement.extern_requirements).to match_array([])
83
+ end
84
+
85
+ end
86
+
87
+ after :each do
88
+ @fileElement = nil
89
+ end
90
+
91
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ RSpec.describe Languages::FunctionData do
4
+
5
+ before :all do
6
+ @functionData = Languages::FunctionData.new("globalFunction")
7
+ end
8
+
9
+ context "When function has no parameter" do
10
+ it "Set function name" do
11
+ expect(@functionData.name).to eq("globalFunction")
12
+
13
+ @functionData.name = "xpto"
14
+ expect(@functionData.name).to eq("xpto")
15
+ end
16
+ end
17
+
18
+ after :all do
19
+ @functionData = nil
20
+ end
21
+
22
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ RSpec.describe Languages::ModuleNamespace do
4
+
5
+ before :all do
6
+ @moduleNamespace = Languages::ModuleNamespaceData.new("Simple")
7
+ end
8
+
9
+ context "Module simple behavior." do
10
+ it "Set name" do
11
+ @moduleNamespace.name = "Abc"
12
+ expect(@moduleNamespace.name).to eq("Abc")
13
+ end
14
+ end
15
+
16
+ after :all do
17
+ @moduleNamespace = nil
18
+ end
19
+
20
+ end
@@ -0,0 +1,34 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ RSpec.describe Languages::RepetitionData do
4
+
5
+ before :each do
6
+ @repetitionData = Languages::RepetitionData.new
7
+ end
8
+
9
+ context "When if conditional." do
10
+ it "Set type." do
11
+ @repetitionData.type = "while"
12
+ expect(@repetitionData.type).to eq("while")
13
+ end
14
+
15
+ it "Simple expression." do
16
+ @repetitionData.expression = "gets"
17
+ expect(@repetitionData.expression).to eq("gets")
18
+
19
+ @repetitionData.expression = "5 < 3"
20
+ expect(@repetitionData.expression).to eq("5 < 3")
21
+
22
+ @repetitionData.expression = "abc == 'x'"
23
+ expect(@repetitionData.expression).to eq("abc == 'x'")
24
+
25
+ @repetitionData.expression = "x >= 3"
26
+ expect(@repetitionData.expression).to eq("x >= 3")
27
+ end
28
+ end
29
+
30
+ after :each do
31
+ @repetitionData = nil
32
+ end
33
+
34
+ end