kuniri 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +43 -0
- data/.rspec +2 -0
- data/.travis.yml +18 -0
- data/.yardopts +1 -0
- data/COPYING +661 -0
- data/Gemfile +14 -0
- data/Guardfile +8 -0
- data/README.md +102 -0
- data/Rakefile +114 -0
- data/bin/kuniri +53 -0
- data/data/attribute_lang.rb +131 -0
- data/data/class_lang.rb +77 -0
- data/data/conditional_lang.rb +71 -0
- data/data/constructor_lang.rb +34 -0
- data/data/end_block_lang.rb +30 -0
- data/data/extern_requirement_lang.rb +45 -0
- data/data/function_behavior_lang.rb +113 -0
- data/data/lang_syntax.rb +111 -0
- data/data/module_namespace_lang.rb +43 -0
- data/data/repetition_lang.rb +62 -0
- data/data/token_lang.rb +55 -0
- data/data/variable_global_lang.rb +118 -0
- data/kuniri.gemspec +24 -0
- data/lib/kuniri/core/configuration/language_available.rb +7 -0
- data/lib/kuniri/core/configuration/log_available.rb +7 -0
- data/lib/kuniri/core/configuration/monitor_available.rb +13 -0
- data/lib/kuniri/core/kuniri.rb +78 -0
- data/lib/kuniri/core/setting.rb +143 -0
- data/lib/kuniri/error/configuration_file_error.rb +12 -0
- data/lib/kuniri/error/language_error.rb +12 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +73 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/class.rb +51 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/comment.rb +57 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/conditional.rb +42 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +52 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/end_block.rb +27 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/extern_requirement.rb +36 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/function_behavior.rb +55 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/module_namespace.rb +36 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +42 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/variable_behaviour.rb +53 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +67 -0
- data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +26 -0
- data/lib/kuniri/language/container_data/structured_and_oo/basic_data.rb +18 -0
- data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +77 -0
- data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +23 -0
- data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +18 -0
- data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +26 -0
- data/lib/kuniri/language/container_data/structured_and_oo/file_element.rb +77 -0
- data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +52 -0
- data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +21 -0
- data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +20 -0
- data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +18 -0
- data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +23 -0
- data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +22 -0
- data/lib/kuniri/language/language.rb +222 -0
- data/lib/kuniri/language/language_factory.rb +48 -0
- data/lib/kuniri/language/ruby/attribute_ruby.rb +134 -0
- data/lib/kuniri/language/ruby/class_ruby.rb +83 -0
- data/lib/kuniri/language/ruby/comment_ruby.rb +84 -0
- data/lib/kuniri/language/ruby/conditional_ruby.rb +77 -0
- data/lib/kuniri/language/ruby/constructor_ruby.rb +36 -0
- data/lib/kuniri/language/ruby/end_block_ruby.rb +33 -0
- data/lib/kuniri/language/ruby/extern_requirement_ruby.rb +49 -0
- data/lib/kuniri/language/ruby/function_behavior_ruby.rb +120 -0
- data/lib/kuniri/language/ruby/module_namespace_ruby.rb +47 -0
- data/lib/kuniri/language/ruby/repetition_ruby.rb +68 -0
- data/lib/kuniri/language/ruby/ruby_syntax.rb +117 -0
- data/lib/kuniri/language/ruby/token_ruby.rb +59 -0
- data/lib/kuniri/language/ruby/variable_behaviour_ruby.rb +83 -0
- data/lib/kuniri/language/ruby/variable_global_ruby.rb +123 -0
- data/lib/kuniri/parser/parser.rb +45 -0
- data/lib/kuniri/parser/parser_xml.rb +128 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +51 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +94 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/comment_state.rb +76 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +92 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +71 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/function_state.rb +82 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/idle_state.rb +80 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +59 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +69 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/module_state.rb +79 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +92 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +85 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +8 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +49 -0
- data/lib/kuniri/util/html_logger.rb +41 -0
- data/lib/kuniri/util/logger.rb +34 -0
- data/lib/kuniri/util/txt_logger.rb +29 -0
- data/lib/kuniri/version.rb +3 -0
- data/lib/kuniri.rb +5 -0
- data/other/analyseFile.asta +0 -0
- data/spec/core/kuniri_spec.rb +14 -0
- data/spec/core/setting_spec.rb +114 -0
- data/spec/language/abstract_container/attribute_spec.rb +13 -0
- data/spec/language/abstract_container/class_spec.rb +13 -0
- data/spec/language/abstract_container/comment_spec.rb +31 -0
- data/spec/language/abstract_container/conditional_spec.rb +13 -0
- data/spec/language/abstract_container/constructor_spec.rb +13 -0
- data/spec/language/abstract_container/end_block_spec.rb +14 -0
- data/spec/language/abstract_container/module_namespace_spec.rb +13 -0
- data/spec/language/abstract_container/repetition_spec.rb +13 -0
- data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +32 -0
- data/spec/language/container_data/structured_and_oo/class_data_spec.rb +121 -0
- data/spec/language/container_data/structured_and_oo/conditional_data_spec.rb +34 -0
- data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +46 -0
- data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +26 -0
- data/spec/language/container_data/structured_and_oo/file_element_spec.rb +91 -0
- data/spec/language/container_data/structured_and_oo/function_data_spec.rb +22 -0
- data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +20 -0
- data/spec/language/container_data/structured_and_oo/repetition_data_spec.rb +34 -0
- data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +39 -0
- data/spec/language/language_factory_spec.rb +64 -0
- data/spec/language/language_spec.rb +74 -0
- data/spec/language/ruby/attribute_ruby_spec.rb +126 -0
- data/spec/language/ruby/class_ruby_spec.rb +102 -0
- data/spec/language/ruby/comment_ruby_spec.rb +78 -0
- data/spec/language/ruby/conditional_ruby_spec.rb +106 -0
- data/spec/language/ruby/constructor_ruby_spec.rb +57 -0
- data/spec/language/ruby/end_block_ruby_spec.rb +62 -0
- data/spec/language/ruby/function_behavior_ruby_spec.rb +246 -0
- data/spec/language/ruby/module_namespace_ruby_spec.rb +55 -0
- data/spec/language/ruby/repetition_ruby_spec.rb +33 -0
- data/spec/language/ruby/ruby_syntax_spec.rb +482 -0
- data/spec/language/ruby/variable_ruby_spec.rb +134 -0
- data/spec/parser/parser_spec.rb +25 -0
- data/spec/samples/rubySyntaxParts/attribute/simpleAttribute.rb +15 -0
- data/spec/samples/rubySyntaxParts/class/simpleClass.rb +19 -0
- data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +33 -0
- data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_global.rb +20 -0
- data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +23 -0
- data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_global.rb +16 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +28 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/methodConditional.rb +42 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +0 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/simpleConditional.rb +43 -0
- data/spec/samples/rubySyntaxParts/constructor/simpleConstructor.rb +27 -0
- data/spec/samples/rubySyntaxParts/extern/multipleLineExternRequirement.rb +0 -0
- data/spec/samples/rubySyntaxParts/extern/requireRelative.rb +6 -0
- data/spec/samples/rubySyntaxParts/extern/simpleExternRequirement.rb +14 -0
- data/spec/samples/rubySyntaxParts/fullCode/simpleCodeWithConditional.rb +18 -0
- data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +19 -0
- data/spec/samples/rubySyntaxParts/function/simpleFunction.rb +29 -0
- data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +13 -0
- data/spec/samples/rubySyntaxParts/module/simpleModule.rb +12 -0
- data/spec/samples/rubySyntaxParts/repetition/simpleRepetition.rb +28 -0
- data/spec/samples/rubySyntaxParts/variable/simpleVariable.rb +13 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/state_machine/OO_structured_fsm/attribute_state_spec.rb +44 -0
- data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +90 -0
- data/spec/state_machine/OO_structured_fsm/comment_state_spec.rb +30 -0
- data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +83 -0
- data/spec/state_machine/OO_structured_fsm/constructor_state_spec.rb +48 -0
- data/spec/state_machine/OO_structured_fsm/function_state_spec.rb +41 -0
- data/spec/state_machine/OO_structured_fsm/idle_state_spec.rb +101 -0
- data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +62 -0
- data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +42 -0
- data/spec/state_machine/OO_structured_fsm/module_state_spec.rb +54 -0
- data/spec/state_machine/OO_structured_fsm/oo_structured_state_spec.rb +0 -0
- data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +83 -0
- data/spec/state_machine/OO_structured_fsm/variable_state_spec.rb +40 -0
- data/spec/util/html_logger_spec.rb +31 -0
- data/spec/util/logger_spec.rb +20 -0
- data/spec/util/txt_logger_spec.rb +31 -0
- metadata +326 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Languages::Ruby::EndBlockRuby do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@endBlock = Languages::Ruby::EndBlockRuby.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context "When the end of block is isolate in one line." do
|
|
10
|
+
it "No end in the line" do
|
|
11
|
+
isEnd = @endBlock.has_end_of_block?("class Xpto")
|
|
12
|
+
expect(isEnd).to eq(false)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "Find simple situation of end." do
|
|
16
|
+
isEnd = @endBlock.has_end_of_block?("end")
|
|
17
|
+
expect(isEnd).to eq(true)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "Find end of block with spaces in the begin." do
|
|
21
|
+
isEnd = @endBlock.has_end_of_block?(" end")
|
|
22
|
+
expect(isEnd).to eq(true)
|
|
23
|
+
isEnd = @endBlock.has_end_of_block?(" end")
|
|
24
|
+
expect(isEnd).to eq(true)
|
|
25
|
+
isEnd = @endBlock.has_end_of_block?(" end")
|
|
26
|
+
expect(isEnd).to eq(true)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "Find end of block with space after." do
|
|
30
|
+
isEnd = @endBlock.has_end_of_block?("end ")
|
|
31
|
+
expect(isEnd).to eq(true)
|
|
32
|
+
isEnd = @endBlock.has_end_of_block?("end ")
|
|
33
|
+
expect(isEnd).to eq(true)
|
|
34
|
+
isEnd = @endBlock.has_end_of_block?("end ")
|
|
35
|
+
expect(isEnd).to eq(true)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "Find end of block with space in the begin and in the end." do
|
|
39
|
+
isEnd = @endBlock.has_end_of_block?(" end ")
|
|
40
|
+
expect(isEnd).to eq(true)
|
|
41
|
+
isEnd = @endBlock.has_end_of_block?(" end ")
|
|
42
|
+
expect(isEnd).to eq(true)
|
|
43
|
+
isEnd = @endBlock.has_end_of_block?(" end ")
|
|
44
|
+
expect(isEnd).to eq(true)
|
|
45
|
+
isEnd = @endBlock.has_end_of_block?(" end ")
|
|
46
|
+
expect(isEnd).to eq(true)
|
|
47
|
+
isEnd = @endBlock.has_end_of_block?(" end ")
|
|
48
|
+
expect(isEnd).to eq(true)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
#context "end in the same line of other instructions" do
|
|
54
|
+
# TODO: This is the hardest cases. Do it!
|
|
55
|
+
#end
|
|
56
|
+
|
|
57
|
+
after :all do
|
|
58
|
+
@endBlock = nil
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Languages::Ruby::FunctionBehaviorRuby do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@functionBehaviorRuby = Languages::Ruby::FunctionBehaviorRuby.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context "When method without parameters" do
|
|
10
|
+
it "Common declaration." do
|
|
11
|
+
input = "def xpto_method"
|
|
12
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
13
|
+
.to eq("xpto_method")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "With whitespace in the beginning." do
|
|
17
|
+
input = " def xpto_method"
|
|
18
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
19
|
+
.to eq("xpto_method")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "With whitespace at the end." do
|
|
23
|
+
input = "def xpto_method "
|
|
24
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
25
|
+
.to eq("xpto_method")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "Between whitespace." do
|
|
29
|
+
input = " def xpto_method "
|
|
30
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
31
|
+
.to eq("xpto_method")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "Whitespace between def and method name." do
|
|
35
|
+
input = "def xpto_method"
|
|
36
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
37
|
+
.to eq("xpto_method")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "Whitespace in the beginning and between def." do
|
|
41
|
+
input = " def xpto_method"
|
|
42
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
43
|
+
.to eq("xpto_method")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "Whitespace between def and in the end." do
|
|
47
|
+
input = "def xpto_method "
|
|
48
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
49
|
+
.to eq("xpto_method")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "Tab in the beginning and space in the end." do
|
|
53
|
+
input = " def xpto_method "
|
|
54
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
55
|
+
.to eq("xpto_method")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "Whitespace in the beginning and in the end." do
|
|
59
|
+
input = " def xpto_method "
|
|
60
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
61
|
+
.to eq("xpto_method")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "Many whitespace between def." do
|
|
65
|
+
input = " def xpto_method"
|
|
66
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
67
|
+
.to eq("xpto_method")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "Whitespace in the beginning, between and in the end" do
|
|
71
|
+
input = " def xpto_method "
|
|
72
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
73
|
+
.to eq("xpto_method")
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
context "With parameters" do
|
|
78
|
+
it "Take method name" do
|
|
79
|
+
input = "def xpto_method(a, b, c, d)\n"
|
|
80
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
81
|
+
.to eq("xpto_method")
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "Whitespace in the beginning." do
|
|
85
|
+
input = " def xpto_method(a, b, c, d)\n"
|
|
86
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
87
|
+
.to eq("xpto_method")
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "Whitespace in the end." do
|
|
91
|
+
input = "def xpto_method(a, b, c, d) \n"
|
|
92
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
93
|
+
.to eq("xpto_method")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "Between whitespace." do
|
|
97
|
+
input = " def xpto_method(a, b, c, d) \n"
|
|
98
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
99
|
+
.to eq("xpto_method")
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "Spaces between parameters." do
|
|
103
|
+
input = "def xpto_method (a, b, c, d)\n"
|
|
104
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
105
|
+
.to eq("xpto_method")
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "Many whitespace between method name and parameters." do
|
|
109
|
+
input = " def xpto_method (a, b, c, d)\n"
|
|
110
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
111
|
+
.to eq("xpto_method")
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "Many whitespace between method declaration." do
|
|
115
|
+
input = " def xpto_method ( a , b , c , d ) \n"
|
|
116
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
117
|
+
.to eq("xpto_method")
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "Different whitespace patterns." do
|
|
121
|
+
input = " def xpto_method ( a, b, c, d ) \n"
|
|
122
|
+
expect(@functionBehaviorRuby.get_function(input).name)
|
|
123
|
+
.to eq("xpto_method")
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
context "When has parameters and parenthesis." do
|
|
128
|
+
it "One parameter" do
|
|
129
|
+
input = "def xpto_method(a)"
|
|
130
|
+
|
|
131
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
132
|
+
expect(methodOne.parameters).to match_array(["a"])
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "Two parameters" do
|
|
136
|
+
input = "def xpto_method(a, b)"
|
|
137
|
+
|
|
138
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
139
|
+
expect(methodOne.parameters).to match_array(["a", "b"])
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "Three parameters" do
|
|
143
|
+
input = "def xpto_method(a, ab, abc)"
|
|
144
|
+
|
|
145
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
146
|
+
expect(methodOne.parameters).to match_array(["a", "ab", "abc"])
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it "Three parameters, with whitespace." do
|
|
150
|
+
input = "def xpto_method (a, ab , abc) "
|
|
151
|
+
|
|
152
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
153
|
+
expect(methodOne.parameters).to match_array(["a", "ab", "abc"])
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
it "One parameter with assignment" do
|
|
158
|
+
input = "def xpto_method(a=3)"
|
|
159
|
+
|
|
160
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
161
|
+
expect(methodOne.parameters).to match_array([{"a"=>"3"}])
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it "Two parameters with assignment" do
|
|
165
|
+
input = "def xpto_method(a=4, b=7)"
|
|
166
|
+
|
|
167
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
168
|
+
expect(methodOne.parameters).to match_array([{"a"=>"4"}, {"b"=>"7"}])
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "Parameters with whitespace between them." do
|
|
172
|
+
input = "def xpto_method(a=7, b=8, c = 0, d = 324)"
|
|
173
|
+
|
|
174
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
175
|
+
expect(methodOne.parameters).to match_array([{"a"=>"7"}, {"b"=>"8"},
|
|
176
|
+
{"c"=>"0"}, {"d"=>"324"}])
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it "Parameters with whitespace between assignment." do
|
|
180
|
+
input = "def xpto_method(a = 7,b =8, c = 0,d = 324)"
|
|
181
|
+
|
|
182
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
183
|
+
expect(methodOne.parameters).to match_array([{"a"=>"7"}, {"b"=>"8"},
|
|
184
|
+
{"c"=>"0"}, {"d"=>"324"}])
|
|
185
|
+
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it "No parameter, just parenthesis" do
|
|
189
|
+
input = "def xpto_method()"
|
|
190
|
+
|
|
191
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
192
|
+
expect(methodOne.parameters).to eq([])
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
context "When has parameters and no parenthesis." do
|
|
198
|
+
it "No parenthesis, and one parameter" do
|
|
199
|
+
input = "def xpto_method x"
|
|
200
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
201
|
+
expect(methodOne.parameters).to match_array(["x"])
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it "One parameter, with space at the end." do
|
|
205
|
+
input = "def xpto_method x "
|
|
206
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
207
|
+
expect(methodOne.parameters).to match_array(["x"])
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it "One parameter, with space in the end and in the begining." do
|
|
211
|
+
input = "def xpto_method x "
|
|
212
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
213
|
+
expect(methodOne.parameters).to match_array(["x"])
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
it "One parameter, multiple spaces" do
|
|
217
|
+
input = " def xpto_method x "
|
|
218
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
219
|
+
expect(methodOne.parameters).to match_array(["x"])
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it "Two parameters" do
|
|
223
|
+
input = "def xpto_method x,y"
|
|
224
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
225
|
+
expect(methodOne.parameters).to match_array(["x", "y"])
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it "Three parameters" do
|
|
229
|
+
input = "def xpto_method x, abcde, xyz"
|
|
230
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
231
|
+
expect(methodOne.parameters).to match_array(["x", "abcde", "xyz"])
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
it "Multiple parameters with many spaces" do
|
|
235
|
+
input = " def xpto_method x , m, nda , t "
|
|
236
|
+
methodOne = @functionBehaviorRuby.get_function(input)
|
|
237
|
+
expect(methodOne.parameters).to match_array(["x", "m", "nda", "t"])
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
after :all do
|
|
243
|
+
@functionBehaviorRuby = nil
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Languages::Ruby::ModuleNamespaceRuby do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@modules = Languages::Ruby::ModuleNamespaceRuby.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context "Common case of module declarations" do
|
|
10
|
+
it "Module on corner." do
|
|
11
|
+
capturedModule = @modules.get_module("module Abc")
|
|
12
|
+
expect(capturedModule.name).to eq("Abc")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "Module with space before." do
|
|
16
|
+
capturedModule = @modules.get_module(" module Xpto")
|
|
17
|
+
expect(capturedModule.name).to eq("Xpto")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "Module with space after." do
|
|
21
|
+
capturedModule = @modules.get_module("module TestOne ")
|
|
22
|
+
expect(capturedModule.name).to eq("TestOne")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "Module with space after, and before." do
|
|
26
|
+
capturedModule = @modules.get_module(" module BeforeAfter ")
|
|
27
|
+
expect(capturedModule.name).to eq("BeforeAfter")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "Module with space between keyword and name." do
|
|
31
|
+
capturedModule = @modules.get_module("module SpaceBetween")
|
|
32
|
+
expect(capturedModule.name).to eq("SpaceBetween")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "Module with space between keyword, and before." do
|
|
36
|
+
capturedModule =
|
|
37
|
+
@modules.get_module(" module SpaceBetweenBefore")
|
|
38
|
+
expect(capturedModule.name).to eq("SpaceBetweenBefore")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "Module with space before keyword, and after." do
|
|
42
|
+
capturedModule = @modules.get_module("module SpaceBetweenAfter ")
|
|
43
|
+
expect(capturedModule.name).to eq("SpaceBetweenAfter")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "Module with space before keyword, between, and after" do
|
|
47
|
+
capturedModule = @modules.get_module(" module BeforeBetweenAfter ")
|
|
48
|
+
expect(capturedModule.name).to eq("BeforeBetweenAfter")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
after :all do
|
|
53
|
+
@module = nil
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Languages::Ruby::RepetitionRuby do
|
|
4
|
+
|
|
5
|
+
before :each do
|
|
6
|
+
@repetitionRuby = Languages::Ruby::RepetitionRuby.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context "When it is if statment." do
|
|
10
|
+
it "Simple if statment." do
|
|
11
|
+
input = "while gets do"
|
|
12
|
+
repetitionCaptured = @repetitionRuby.get_repetition(input).expression
|
|
13
|
+
expect(repetitionCaptured).to eq("gets")
|
|
14
|
+
|
|
15
|
+
input = "while 2 < 3 do"
|
|
16
|
+
repetitionCaptured = @repetitionRuby.get_repetition(input).expression
|
|
17
|
+
expect(repetitionCaptured).to eq("2 < 3")
|
|
18
|
+
|
|
19
|
+
#input = "for x.range(0,1)"
|
|
20
|
+
#repetitionCaptured = @repetitionRuby.get_repetition(input).expression
|
|
21
|
+
#expect(repetitionCaptured).to eq("x.range(0,1)")
|
|
22
|
+
|
|
23
|
+
input = "while x == 222222 do"
|
|
24
|
+
repetitionCaptured = @repetitionRuby.get_repetition(input).expression
|
|
25
|
+
expect(repetitionCaptured).to eq("x == 222222")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
after :each do
|
|
30
|
+
@repetitionRuby = nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|