kuniri 0.0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -7
- data/COPYING +160 -656
- data/Gemfile +4 -3
- data/README.md +57 -27
- data/Rakefile +3 -1
- data/bin/kuniri +50 -26
- data/data/aggregation_lang.rb +33 -0
- data/data/attribute_lang.rb +14 -87
- data/data/class_lang.rb +19 -41
- data/data/comment_lang.rb +52 -0
- data/data/conditional_lang.rb +14 -41
- data/data/constructor_lang.rb +4 -12
- data/data/end_block_lang.rb +7 -6
- data/data/extern_requirement_lang.rb +10 -17
- data/data/function_behavior_lang.rb +17 -66
- data/data/global_function_lang.rb +26 -0
- data/data/lang_syntax.rb +82 -49
- data/data/method_lang.rb +26 -0
- data/data/module_namespace_lang.rb +8 -13
- data/data/repetition_lang.rb +19 -32
- data/data/token_lang.rb +2 -44
- data/data/variable_behaviour_lang.rb +43 -0
- data/data/variable_global_lang.rb +13 -72
- data/kuniri.gemspec +4 -4
- data/lib/kuniri/core/configuration/language_available.rb +2 -2
- data/lib/kuniri/core/kuniri.rb +32 -24
- data/lib/kuniri/core/setting.rb +51 -85
- data/lib/kuniri/error/parser_error.rb +9 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/aggregation.rb +29 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +0 -40
- data/lib/kuniri/language/abstract_container/structured_and_oo/global_tokens.rb +20 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +9 -1
- data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +0 -35
- data/lib/kuniri/language/container_data/structured_and_oo/aggregation_data.rb +23 -0
- data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +4 -2
- data/lib/kuniri/language/container_data/structured_and_oo/basic_structure.rb +24 -0
- data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +13 -19
- data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +2 -13
- data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +2 -0
- data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +11 -6
- data/lib/kuniri/language/container_data/structured_and_oo/{file_element.rb → file_element_data.rb} +11 -9
- data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +58 -11
- data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +3 -3
- data/lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb +55 -0
- data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +5 -4
- data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +3 -1
- data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +2 -13
- data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +2 -0
- data/lib/kuniri/language/language.rb +37 -11
- data/lib/kuniri/language/metadata.rb +29 -0
- data/lib/kuniri/language/ruby/aggregation_ruby.rb +37 -0
- data/lib/kuniri/language/ruby/attribute_ruby.rb +23 -38
- data/lib/kuniri/language/ruby/class_ruby.rb +2 -10
- data/lib/kuniri/language/ruby/conditional_ruby.rb +20 -6
- data/lib/kuniri/language/ruby/constructor_ruby.rb +5 -7
- data/lib/kuniri/language/ruby/end_block_ruby.rb +1 -1
- data/lib/kuniri/language/ruby/function_behavior_ruby.rb +1 -9
- data/lib/kuniri/language/ruby/global_function_ruby.rb +32 -0
- data/lib/kuniri/language/ruby/method_ruby.rb +33 -0
- data/lib/kuniri/language/ruby/repetition_ruby.rb +60 -14
- data/lib/kuniri/language/ruby/ruby_syntax.rb +76 -49
- data/lib/kuniri/parser/output_factory.rb +29 -0
- data/lib/kuniri/parser/output_format.rb +134 -0
- data/lib/kuniri/parser/parser.rb +3 -7
- data/lib/kuniri/parser/xml_builder_engine.rb +94 -0
- data/lib/kuniri/parser/xml_output_format.rb +143 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/aggregation_state.rb +45 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +0 -1
- data/lib/kuniri/state_machine/OO_structured_fsm/basic_structure_state.rb +182 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +12 -3
- data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +11 -68
- data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +7 -52
- data/lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb +86 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +2 -3
- data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +8 -50
- data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +6 -1
- data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +10 -59
- data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +4 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +0 -1
- data/lib/kuniri/version.rb +1 -1
- data/other/analyseFile.asta +0 -0
- data/spec/core/kuniri_spec.rb +2 -1
- data/spec/core/setting_spec.rb +35 -61
- data/spec/language/abstract_container/aggregation_spec.rb +13 -0
- data/spec/language/abstract_container/extern_requirement_spec.rb +13 -0
- data/spec/language/container_data/structured_and_oo/aggregation_data_spec.rb +29 -0
- data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +9 -2
- data/spec/language/container_data/structured_and_oo/class_data_spec.rb +1 -46
- data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +32 -2
- data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +31 -7
- data/spec/language/container_data/structured_and_oo/{file_element_spec.rb → file_element_data_spec.rb} +21 -5
- data/spec/language/container_data/structured_and_oo/function_abstract_spec.rb +213 -0
- data/spec/language/container_data/structured_and_oo/function_data_spec.rb +31 -2
- data/spec/language/container_data/structured_and_oo/manager_basic_structure_data_spec.rb +150 -0
- data/spec/language/container_data/structured_and_oo/method_data_spec.rb +80 -0
- data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +7 -1
- data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +9 -0
- data/spec/language/language_factory_spec.rb +1 -1
- data/spec/language/language_spec.rb +46 -9
- data/spec/language/ruby/aggregation_ruby_spec.rb +80 -0
- data/spec/language/ruby/class_ruby_spec.rb +66 -6
- data/spec/language/ruby/constructor_ruby_spec.rb +1 -1
- data/spec/language/ruby/end_block_ruby_spec.rb +11 -0
- data/spec/language/ruby/extern_requirement_ruby_spec.rb +59 -0
- data/spec/language/ruby/function_behavior_ruby_spec.rb +54 -2
- data/spec/language/ruby/global_test/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/complete_class_ruby_spec.rb +161 -0
- data/spec/language/ruby/global_test/conditional/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri1.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri2.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri3.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri4.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri5.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri6.yml +4 -0
- data/spec/language/ruby/global_test/conditional/a_lot_of_conditionals_spec.rb +92 -0
- data/spec/language/ruby/global_test/conditional/constructor_very_mix_conditional_spec.rb +105 -0
- data/spec/language/ruby/global_test/conditional/function_with_conditional_spec.rb +94 -0
- data/spec/language/ruby/global_test/conditional/function_with_nested_conditional_spec.rb +56 -0
- data/spec/language/ruby/global_test/conditional/method_very_mix_conditional_spec.rb +109 -0
- data/spec/language/ruby/global_test/conditional/very_deep_conditional_structure_spec.rb +61 -0
- data/spec/language/ruby/global_test/conditional/very_mix_conditional_spec.rb +105 -0
- data/spec/language/ruby/global_test/conditionalAndRepetition/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/conditionalAndRepetition/mix_conditional_repetition_spec.rb +57 -0
- data/spec/language/ruby/global_test/repetition/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri2.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri3.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri4.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri5.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri6.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri7.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri8.yml +4 -0
- data/spec/language/ruby/global_test/repetition/complete_class_integrity.rb +41 -0
- data/spec/language/ruby/global_test/repetition/complete_class_until_loop_spec.rb +42 -0
- data/spec/language/ruby/global_test/repetition/complete_class_while_loop_spec.rb +41 -0
- data/spec/language/ruby/global_test/repetition/complete_class_with_repetition_spec.rb +42 -0
- data/spec/language/ruby/global_test/repetition/constructor_with_mix_repetition_spec.rb +57 -0
- data/spec/language/ruby/global_test/repetition/method_with_mix_repetition_spec.rb +59 -0
- data/spec/language/ruby/global_test/repetition/very_mix_repetition_spec.rb +61 -0
- data/spec/language/ruby/global_test/repetition/very_nested_repetition_spec.rb +65 -0
- data/spec/language/ruby/method_ruby_spec.rb +52 -0
- data/spec/language/ruby/repetition_ruby_spec.rb +175 -8
- data/spec/language/ruby/ruby_syntax_spec.rb +213 -84
- data/spec/parser/output_factory_spec.rb +32 -0
- data/spec/parser/output_format_spec.rb +83 -0
- data/spec/parser/parser_spec.rb +7 -0
- data/spec/parser/xmlSchemaValidate/.kuniri1.yml +3 -0
- data/spec/parser/xmlSchemaValidate/.kuniri2.yml +3 -0
- data/spec/parser/xmlSchemaValidate/.kuniri3.yml +3 -0
- data/spec/parser/xmlSchemaValidate/class_data.xsd +99 -0
- data/spec/parser/xmlSchemaValidate/fullCodeTwo.xsd +119 -0
- data/spec/parser/xmlSchemaValidate/fullCodeWithComments.xsd +146 -0
- data/spec/parser/xmlSchemaValidate/simpleFunction.xsd +25 -0
- data/spec/parser/xmlSchemaValidate/validate_xml_spec.rb +52 -0
- data/spec/parser/xml_builder_engine_spec.rb +258 -0
- data/spec/parser/xml_output_format_spec.rb +274 -0
- data/spec/samples/rubySyntaxParts/aggregation/classAggregation.rb +37 -0
- data/spec/samples/rubySyntaxParts/aggregation/constructorAggregation.rb +36 -0
- data/spec/samples/rubySyntaxParts/aggregation/methodAggregation.rb +36 -0
- data/spec/samples/rubySyntaxParts/aggregation/multipleAggregation.rb +59 -0
- data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +7 -0
- data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +2 -1
- data/spec/samples/rubySyntaxParts/conditionalStatment/aLotOfConditionals.rb +42 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/commonCasesOfConditionals.rb +47 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +1 -1
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorMixConditional.rb +41 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/methodMixConditional.rb +41 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/mixConditionalWithRepetition.rb +20 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +61 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/veryDeepConditionalStructure.rb +48 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/veryMixConditional.rb +37 -0
- data/spec/samples/rubySyntaxParts/fullCode/fullCodeTwo.rb +56 -0
- data/spec/samples/rubySyntaxParts/fullCode/fullCodeWithComments.rb +64 -0
- data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +9 -1
- data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +2 -0
- data/spec/samples/rubySyntaxParts/repetition/beginWithWhileLoopInClass.rb +10 -0
- data/spec/samples/rubySyntaxParts/repetition/constructorWithMixRepetition.rb +22 -0
- data/spec/samples/rubySyntaxParts/repetition/forLoopInClass.rb +7 -0
- data/spec/samples/rubySyntaxParts/repetition/methodWithMixRepetition.rb +19 -0
- data/spec/samples/rubySyntaxParts/repetition/mixConditionalRepetition.rb +17 -0
- data/spec/samples/rubySyntaxParts/repetition/untilLoopInClass.rb +16 -0
- data/spec/samples/rubySyntaxParts/repetition/veryMixRepetition.rb +28 -0
- data/spec/samples/rubySyntaxParts/repetition/veryNestedRepetition.rb +17 -0
- data/spec/samples/rubySyntaxParts/repetition/whileLoopInClass.rb +12 -0
- data/spec/state_machine/OO_structured_fsm/aggregation_state_spec.rb +67 -0
- data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +15 -0
- data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +64 -0
- data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +3 -3
- data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +18 -0
- data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +27 -0
- metadata +195 -28
- data/lib/kuniri/core/configuration/monitor_available.rb +0 -13
- data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +0 -52
- data/lib/kuniri/parser/parser_xml.rb +0 -128
- data/spec/language/abstract_container/constructor_spec.rb +0 -13
- data/spec/util/html_logger_spec.rb +0 -31
- data/spec/util/logger_spec.rb +0 -20
- data/spec/util/txt_logger_spec.rb +0 -31
@@ -35,7 +35,7 @@ RSpec.describe Languages::ClassData do
|
|
35
35
|
attributes.each do |nameElement|
|
36
36
|
listOfAttributes.push(Languages::AttributeData.new(nameElement))
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
@classData.add_attribute(listOfAttributes)
|
40
40
|
|
41
41
|
attributeList = @classData.attributes
|
@@ -50,22 +50,6 @@ RSpec.describe Languages::ClassData do
|
|
50
50
|
|
51
51
|
end
|
52
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
53
|
RSpec.shared_examples "Add method" do |methods, description|
|
70
54
|
|
71
55
|
it ": #{description}" do
|
@@ -85,35 +69,6 @@ RSpec.describe Languages::ClassData do
|
|
85
69
|
|
86
70
|
end
|
87
71
|
|
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
72
|
after :each do
|
118
73
|
@classData = nil
|
119
74
|
end
|
@@ -34,11 +34,41 @@ RSpec.describe Languages::ConstructorData do
|
|
34
34
|
condiditonal.type = "IF"
|
35
35
|
condiditonal.expression = "x > 3"
|
36
36
|
@constructorData.add_conditional(condiditonal)
|
37
|
-
|
38
|
-
|
37
|
+
all = @constructorData.managerCondAndLoop.basicStructure
|
38
|
+
expect(all[0].instance_of?(Languages::ConditionalData)).to eq(true)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
context "When instantiating" do
|
43
|
+
it "Does not set name" do
|
44
|
+
@constructorData = Languages::ConstructorData.new(nil)
|
45
|
+
expect(@constructorData.name).to be_nil
|
46
|
+
@constructorData = Languages::ConstructorData.new(1)
|
47
|
+
expect(@constructorData.name).to be_nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "Copy from FunctionAbstract to constructor" do
|
52
|
+
it "Simple copy" do
|
53
|
+
lalala = Languages::FunctionAbstract.new("lalala")
|
54
|
+
lalala.comments = "abc"
|
55
|
+
|
56
|
+
condiditonal = Languages::ConditionalData.new
|
57
|
+
condiditonal.type = "IF"
|
58
|
+
condiditonal.expression = "x > 3"
|
59
|
+
lalala.add_conditional(condiditonal)
|
60
|
+
|
61
|
+
@constructorData << lalala
|
62
|
+
expect(@constructorData.name).to eq("lalala")
|
63
|
+
expect(@constructorData.comments).to eq("abc")
|
64
|
+
expect(@constructorData.comments).to eq("abc")
|
65
|
+
all = @constructorData.managerCondAndLoop.basicStructure
|
66
|
+
expect(all[0].instance_of?(Languages::ConditionalData)).to eq(true)
|
67
|
+
expect(@constructorData.type).to eq("CONSTRUCTOR")
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
42
72
|
after :each do
|
43
73
|
@constructorData = nil
|
44
74
|
end
|
@@ -2,25 +2,49 @@ require_relative '../../../spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Languages::ExternRequirementData do
|
4
4
|
|
5
|
-
before :
|
5
|
+
before :each do
|
6
6
|
@externRequirement = Languages::ExternRequirementData.new("xpto")
|
7
7
|
end
|
8
8
|
|
9
9
|
context "Using constructor to create data container." do
|
10
10
|
it "Create container" do
|
11
|
-
expect(@externRequirement.
|
11
|
+
expect(@externRequirement.library).to eq("xpto")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "Does not set name" do
|
15
|
+
@externRequirement = Languages::ExternRequirementData.new(nil)
|
16
|
+
expect(@externRequirement.library).to be_nil
|
17
|
+
@externRequirement = Languages::ExternRequirementData.new(1)
|
18
|
+
expect(@externRequirement.library).to be_nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "When set library" do
|
23
|
+
it "Set library." do
|
24
|
+
@externRequirement.set_library("spec/samples/emptyFile")
|
25
|
+
expect(@externRequirement.library).to eq("spec/samples/emptyFile")
|
12
26
|
end
|
13
27
|
end
|
14
28
|
|
15
29
|
context "When set path" do
|
16
30
|
it "Set path." do
|
17
|
-
@externRequirement.
|
18
|
-
expect(@externRequirement.
|
31
|
+
@externRequirement.set_library("xpto")
|
32
|
+
expect(@externRequirement.library).to eq("xpto")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "Does not set library" do
|
36
|
+
@externRequirement = Languages::ExternRequirementData.new("xpto")
|
37
|
+
@externRequirement.set_library(1)
|
38
|
+
expect(@externRequirement.library).to eq("xpto")
|
39
|
+
@externRequirement.set_library(nil)
|
40
|
+
expect(@externRequirement.library).to eq("xpto")
|
41
|
+
@externRequirement.set_library("")
|
42
|
+
expect(@externRequirement.library).to eq("xpto")
|
19
43
|
end
|
20
|
-
end
|
44
|
+
end
|
21
45
|
|
22
|
-
after :
|
46
|
+
after :each do
|
23
47
|
@externRequirement = nil
|
24
48
|
end
|
25
49
|
|
26
|
-
end
|
50
|
+
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require_relative '../../../spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe Languages::
|
3
|
+
RSpec.describe Languages::FileElementData do
|
4
4
|
|
5
5
|
before :each do
|
6
|
-
@fileElement = Languages::
|
6
|
+
@fileElement = Languages::FileElementData.new ("test")
|
7
7
|
@globalFunction1 = Languages::FunctionData.new("xpto")
|
8
8
|
@globalFunction2 = Languages::FunctionData.new("second")
|
9
9
|
@globalVariable1 = [Languages::VariableGlobalData.new("var1")]
|
10
10
|
@globalVariable2 = [Languages::VariableGlobalData.new("var2")]
|
11
|
+
@globalVariable3 = Languages::VariableGlobalData.new("var3")
|
11
12
|
@externFile1 = Languages::ExternRequirementData.new ("/dir/1")
|
12
13
|
@externFile2 = Languages::ExternRequirementData.new ("/dir/2")
|
13
14
|
@class1 = Languages::ClassData.new
|
@@ -54,6 +55,11 @@ RSpec.describe Languages::FileElement do
|
|
54
55
|
expect(variables).to match_array(["var1", "var2"])
|
55
56
|
end
|
56
57
|
|
58
|
+
it "Add one global variable as single parameter." do
|
59
|
+
@fileElement.add_global_variable(@globalVariable3)
|
60
|
+
expect(@fileElement.global_variables[0].name == "var3").to be true
|
61
|
+
end
|
62
|
+
|
57
63
|
it "Add non global variable." do
|
58
64
|
@fileElement.add_global_variable(["xpto"])
|
59
65
|
expect(@fileElement.global_variables).to match_array([])
|
@@ -64,7 +70,7 @@ RSpec.describe Languages::FileElement do
|
|
64
70
|
context "When add external files." do
|
65
71
|
it "Add one external element." do
|
66
72
|
@fileElement.add_extern_requirement(@externFile1)
|
67
|
-
expect(@fileElement.extern_requirements[0].
|
73
|
+
expect(@fileElement.extern_requirements[0].library == "/dir/1").to be true
|
68
74
|
end
|
69
75
|
|
70
76
|
it "Add two external elements." do
|
@@ -72,7 +78,7 @@ RSpec.describe Languages::FileElement do
|
|
72
78
|
@fileElement.add_extern_requirement(@externFile2)
|
73
79
|
extern = []
|
74
80
|
@fileElement.extern_requirements.each do |externs|
|
75
|
-
extern.push(externs.
|
81
|
+
extern.push(externs.library)
|
76
82
|
end
|
77
83
|
expect(extern).to match_array(["/dir/1", "/dir/2"])
|
78
84
|
end
|
@@ -84,8 +90,18 @@ RSpec.describe Languages::FileElement do
|
|
84
90
|
|
85
91
|
end
|
86
92
|
|
93
|
+
context "When instantiating" do
|
94
|
+
it "Does not set name" do
|
95
|
+
@fileElement = Languages::FileElementData.new(nil)
|
96
|
+
expect(@fileElement.name).to be_nil
|
97
|
+
@fileElement = Languages::FileElementData.new(1)
|
98
|
+
expect(@fileElement.name).to be_nil
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
87
103
|
after :each do
|
88
104
|
@fileElement = nil
|
89
105
|
end
|
90
106
|
|
91
|
-
end
|
107
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
require_relative '../../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Languages::FunctionAbstract do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@functionAbstract = Languages::FunctionAbstract.new "Test"
|
7
|
+
@conditional = Languages::ConditionalData.new
|
8
|
+
@repetition = Languages::RepetitionData.new
|
9
|
+
end
|
10
|
+
|
11
|
+
context "When adding a parameter" do
|
12
|
+
it "Adds a parameter" do
|
13
|
+
@functionAbstract.add_parameters("a")
|
14
|
+
expect(@functionAbstract.parameters).to eq(["a"])
|
15
|
+
end
|
16
|
+
|
17
|
+
it "Adds a parameter with assignment" do
|
18
|
+
@functionAbstract.add_parameters({"key" => "a"})
|
19
|
+
expect(@functionAbstract.parameters).to eq([{"key" => "a"}])
|
20
|
+
end
|
21
|
+
|
22
|
+
it "Adds multiple parameters" do
|
23
|
+
@functionAbstract.add_parameters("a")
|
24
|
+
@functionAbstract.add_parameters("b")
|
25
|
+
@functionAbstract.add_parameters("c")
|
26
|
+
expect(@functionAbstract.parameters).to eq(["a", "b", "c"])
|
27
|
+
end
|
28
|
+
|
29
|
+
it "Adds multiple parameters with assignment" do
|
30
|
+
@functionAbstract.add_parameters({"key1" => "a"})
|
31
|
+
@functionAbstract.add_parameters({"key2" => "b"})
|
32
|
+
@functionAbstract.add_parameters({"key3" => "c"})
|
33
|
+
expect(@functionAbstract.parameters).to eq([{"key1" => "a"},
|
34
|
+
{"key2" => "b"},
|
35
|
+
{"key3" => "c"}])
|
36
|
+
end
|
37
|
+
|
38
|
+
it "adds an integer as a parameter" do
|
39
|
+
@functionAbstract.add_parameters(12)
|
40
|
+
expect(@functionAbstract.parameters).to_not eq([12])
|
41
|
+
end
|
42
|
+
|
43
|
+
it "Adds a hash with more than one element as a parameter" do
|
44
|
+
@functionAbstract.add_parameters({"key1" => "a", "key2" => "b"})
|
45
|
+
expect(@functionAbstract.parameters).to_not eq([{"key1" => "a",
|
46
|
+
"key2" => "b"}])
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
context "When adding a conditional" do
|
52
|
+
it "Adds a conditional" do
|
53
|
+
@functionAbstract.add_conditional(@conditional)
|
54
|
+
functionConditional = @functionAbstract.managerCondAndLoop.basicStructure
|
55
|
+
expect(functionConditional).to eq([@conditional])
|
56
|
+
end
|
57
|
+
|
58
|
+
it "Adds a string as a conditional should fail" do
|
59
|
+
@functionAbstract.add_conditional("xpto")
|
60
|
+
functionConditional = @functionAbstract.managerCondAndLoop.basicStructure
|
61
|
+
expect(functionConditional).to_not eq(["xpto"])
|
62
|
+
end
|
63
|
+
|
64
|
+
it "Adds a set of conditional" do
|
65
|
+
conditionals = []
|
66
|
+
for index in 0..5 do
|
67
|
+
conditionals[index] = Languages::ConditionalData.new
|
68
|
+
conditionals[index].expression = "xpto == #{index}"
|
69
|
+
conditionals[index].type = Languages::IF_LABEL
|
70
|
+
@functionAbstract.add_conditional(conditionals[index])
|
71
|
+
end
|
72
|
+
allConditionals = @functionAbstract.managerCondAndLoop.basicStructure
|
73
|
+
expect(allConditionals).to match_array(conditionals)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "Add a set of conditionals with different level" do
|
77
|
+
conditionals = []
|
78
|
+
for index in 0..3 do
|
79
|
+
conditionals[index] = Languages::ConditionalData.new
|
80
|
+
conditionals[index].type = Languages::IF_LABEL
|
81
|
+
end
|
82
|
+
|
83
|
+
@functionAbstract.add_conditional(conditionals[0])
|
84
|
+
@functionAbstract.add_conditional(conditionals[1], Languages::DOWN_LEVEL)
|
85
|
+
@functionAbstract.add_conditional(conditionals[2], Languages::DOWN_LEVEL)
|
86
|
+
@functionAbstract.add_conditional(conditionals[3], Languages::UP_LEVEL)
|
87
|
+
|
88
|
+
allConditional = @functionAbstract.managerCondAndLoop.basicStructure
|
89
|
+
expect(allConditional[0].level).to eq(0)
|
90
|
+
expect(allConditional[1].level).to eq(1)
|
91
|
+
expect(allConditional[2].level).to eq(2)
|
92
|
+
expect(allConditional[3].level).to eq(1)
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context "When adding a repetition" do
|
98
|
+
it "Adds a repetition" do
|
99
|
+
@functionAbstract.add_repetition(@repetition)
|
100
|
+
functionLoop = @functionAbstract.managerCondAndLoop.basicStructure
|
101
|
+
expect(functionLoop).to eq([@repetition])
|
102
|
+
end
|
103
|
+
|
104
|
+
it "Adds a string as a repetition should fail" do
|
105
|
+
@functionAbstract.add_repetition("xpto")
|
106
|
+
functionLoop = @functionAbstract.managerCondAndLoop.basicStructure
|
107
|
+
expect(functionLoop).to_not eq(["xpto"])
|
108
|
+
end
|
109
|
+
|
110
|
+
it "Add a set of loops" do
|
111
|
+
loops = []
|
112
|
+
for index in 0..5 do
|
113
|
+
loops[index] = Languages::RepetitionData.new
|
114
|
+
loops[index].type = Languages::FOR_LABEL
|
115
|
+
loops[index].expression = "true"
|
116
|
+
@functionAbstract.add_repetition(loops[index])
|
117
|
+
end
|
118
|
+
allLoops = @functionAbstract.managerCondAndLoop.basicStructure
|
119
|
+
expect(allLoops).to match_array(loops)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "Add a set of loops with different level" do
|
123
|
+
loops = []
|
124
|
+
for index in 0..3 do
|
125
|
+
loops[index] = Languages::RepetitionData.new
|
126
|
+
loops[index].type = Languages::WHILE_LABEL
|
127
|
+
end
|
128
|
+
|
129
|
+
@functionAbstract.add_repetition(loops[0])
|
130
|
+
@functionAbstract.add_repetition(loops[1], Languages::DOWN_LEVEL)
|
131
|
+
@functionAbstract.add_repetition(loops[2])
|
132
|
+
@functionAbstract.add_repetition(loops[3], Languages::UP_LEVEL)
|
133
|
+
|
134
|
+
allLoops = @functionAbstract.managerCondAndLoop.basicStructure
|
135
|
+
expect(allLoops[0].level).to eq(0)
|
136
|
+
expect(allLoops[1].level).to eq(1)
|
137
|
+
expect(allLoops[2].level).to eq(1)
|
138
|
+
expect(allLoops[3].level).to eq(0)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "Set conditional and loops mixed" do
|
143
|
+
it "Set conditionals and loops" do
|
144
|
+
conditionalOne = Languages::ConditionalData.new
|
145
|
+
conditionalOne.type = Languages::IF_LABEL
|
146
|
+
conditionalTwo = Languages::ConditionalData.new
|
147
|
+
conditionalTwo.type = Languages::ELSIF_LABEL
|
148
|
+
|
149
|
+
repetitionOne = Languages::RepetitionData.new
|
150
|
+
repetitionOne.type = Languages::FOR_LABEL
|
151
|
+
repetitionTwo = Languages::RepetitionData.new
|
152
|
+
repetitionTwo.type = Languages::WHILE_LABEL
|
153
|
+
|
154
|
+
@functionAbstract.add_conditional(conditionalOne)
|
155
|
+
@functionAbstract.add_repetition(repetitionOne, Languages::DOWN_LEVEL)
|
156
|
+
@functionAbstract.add_conditional(conditionalTwo, Languages::UP_LEVEL)
|
157
|
+
@functionAbstract.add_repetition(repetitionTwo, Languages::DOWN_LEVEL)
|
158
|
+
|
159
|
+
all = @functionAbstract.managerCondAndLoop.basicStructure
|
160
|
+
expect(all[0].level).to eq(0)
|
161
|
+
expect(all[1].level).to eq(1)
|
162
|
+
expect(all[1].type).to eq(Languages::FOR_LABEL)
|
163
|
+
expect(all[2].level).to eq(0)
|
164
|
+
expect(all[3].level).to eq(1)
|
165
|
+
expect(all[3].type).to eq(Languages::WHILE_LABEL)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "Set loops and conditionals" do
|
169
|
+
conditionalOne = Languages::ConditionalData.new
|
170
|
+
conditionalOne.type = Languages::IF_LABEL
|
171
|
+
conditionalTwo = Languages::ConditionalData.new
|
172
|
+
conditionalTwo.type = Languages::ELSIF_LABEL
|
173
|
+
|
174
|
+
repetitionOne = Languages::RepetitionData.new
|
175
|
+
repetitionOne.type = Languages::FOR_LABEL
|
176
|
+
repetitionTwo = Languages::RepetitionData.new
|
177
|
+
repetitionTwo.type = Languages::WHILE_LABEL
|
178
|
+
|
179
|
+
@functionAbstract.add_repetition(repetitionOne)
|
180
|
+
@functionAbstract.add_repetition(repetitionTwo, Languages::DOWN_LEVEL)
|
181
|
+
@functionAbstract.add_conditional(conditionalOne, Languages::DOWN_LEVEL)
|
182
|
+
@functionAbstract.add_conditional(conditionalTwo)
|
183
|
+
|
184
|
+
all = @functionAbstract.managerCondAndLoop.basicStructure
|
185
|
+
expect(all[0].level).to eq(0)
|
186
|
+
expect(all[0].type).to eq(Languages::FOR_LABEL)
|
187
|
+
expect(all[1].level).to eq(1)
|
188
|
+
expect(all[1].type).to eq(Languages::WHILE_LABEL)
|
189
|
+
expect(all[2].level).to eq(2)
|
190
|
+
expect(all[2].type).to eq(Languages::IF_LABEL)
|
191
|
+
expect(all[3].level).to eq(2)
|
192
|
+
expect(all[3].type).to eq(Languages::ELSIF_LABEL)
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
context "When instantiating" do
|
199
|
+
it "Does not set name" do
|
200
|
+
@functionAbstract = Languages::FunctionAbstract.new(nil)
|
201
|
+
expect(@functionAbstract.name).to be_nil
|
202
|
+
@functionAbstract = Languages::FunctionAbstract.new(1)
|
203
|
+
expect(@functionAbstract.name).to be_nil
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
after :each do
|
208
|
+
@functionAbstract = nil
|
209
|
+
@conditional = nil
|
210
|
+
@repetition = nil
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
@@ -2,7 +2,7 @@ require_relative '../../../spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Languages::FunctionData do
|
4
4
|
|
5
|
-
before :
|
5
|
+
before :each do
|
6
6
|
@functionData = Languages::FunctionData.new("globalFunction")
|
7
7
|
end
|
8
8
|
|
@@ -15,7 +15,36 @@ RSpec.describe Languages::FunctionData do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
context "When instantiating" do
|
19
|
+
it "Does not set name" do
|
20
|
+
@functionData = Languages::FunctionData.new(nil)
|
21
|
+
expect(@functionData.name).to be_nil
|
22
|
+
@functionData = Languages::FunctionData.new(1)
|
23
|
+
expect(@functionData.name).to be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "Copy from FunctionAbstract to FunctionData" do
|
28
|
+
it "Verify copy" do
|
29
|
+
lalala = Languages::FunctionAbstract.new("lalala")
|
30
|
+
lalala.comments = "abc"
|
31
|
+
|
32
|
+
condiditonal = Languages::ConditionalData.new
|
33
|
+
condiditonal.type = Languages::IF_LABEL
|
34
|
+
condiditonal.expression = "x > 3"
|
35
|
+
lalala.add_conditional(condiditonal)
|
36
|
+
|
37
|
+
@functionData << lalala
|
38
|
+
expect(@functionData.name).to eq("lalala")
|
39
|
+
expect(@functionData.comments).to eq("abc")
|
40
|
+
expect(@functionData.comments).to eq("abc")
|
41
|
+
all = @functionData.managerCondAndLoop.basicStructure
|
42
|
+
expect(all[0].instance_of?(Languages::ConditionalData)).to eq(true)
|
43
|
+
expect(@functionData.type).to eq("GLOBALFUNCTION")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
after :each do
|
19
48
|
@functionData = nil
|
20
49
|
end
|
21
50
|
|