kuniri 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,39 @@
|
|
1
|
+
require_relative '../../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Languages::VariableGlobalData do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@variableData = Languages::VariableGlobalData.new("abc")
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Get name" do
|
10
|
+
it "Check correct name" do
|
11
|
+
expect(@variableData.name).to eq("abc")
|
12
|
+
|
13
|
+
@variableData.name = "newName"
|
14
|
+
expect(@variableData.name).to eq("newName")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "Get value" do
|
19
|
+
it "Check value" do
|
20
|
+
@variableData.value = 1
|
21
|
+
expect(@variableData.value).to eq(1)
|
22
|
+
|
23
|
+
@variableData.value = "valueOne"
|
24
|
+
expect(@variableData.value).to eq("valueOne")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "Get type" do
|
29
|
+
it "Check type value" do
|
30
|
+
@variableData.type = "array"
|
31
|
+
expect(@variableData.type).to eq("array")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
after :all do
|
36
|
+
@variableData = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Languages::LanguageFactory do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@factory = Languages::LanguageFactory.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "When have supprt to language." do
|
10
|
+
it "Ruby support." do
|
11
|
+
expect(@factory.get_language("ruby").is_a?(Languages::RubySyntax))
|
12
|
+
.to be true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "When have not support." do
|
17
|
+
it "Python support." do
|
18
|
+
expect{@factory.get_language("python")}.to raise_error(
|
19
|
+
Error::LanguageError)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "vhdl support." do
|
23
|
+
expect{@factory.get_language("vhdl")}.to raise_error(
|
24
|
+
Error::LanguageError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "C support." do
|
28
|
+
expect{@factory.get_language("c")}.to raise_error(
|
29
|
+
Error::LanguageError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "C++ support." do
|
33
|
+
expect{@factory.get_language("cplusplus")}.to raise_error(
|
34
|
+
Error::LanguageError)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "Java support." do
|
38
|
+
expect{@factory.get_language("java")}.to raise_error(
|
39
|
+
Error::LanguageError)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "Assembly arm support." do
|
43
|
+
expect{@factory.get_language("assemblyarm")}.to raise_error(
|
44
|
+
Error::LanguageError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "PHP support." do
|
48
|
+
expect{@factory.get_language("php")}.to raise_error(
|
49
|
+
Error::LanguageError)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "Nothing." do
|
53
|
+
expect{@factory.get_language("")}.to raise_error(
|
54
|
+
Error::LanguageError)
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
after :all do
|
61
|
+
@factory = nil
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Languages::Language do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@abstractLanguage = Languages::Language.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'When try to call analyse_source' do
|
10
|
+
it "Try to call unimplemented method." do
|
11
|
+
expect{@abstractLanguage.analyse_source}.to raise_error(
|
12
|
+
NotImplementedError)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'When try to call comment_extract' do
|
17
|
+
it "Try to call comment_extract in abstract class." do
|
18
|
+
expect{@abstractLanguage.comment_extract}.to raise_error(
|
19
|
+
NotImplementedError)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'When try to call method_extract' do
|
24
|
+
it "Try to call method_extract" do
|
25
|
+
expect{@abstractLanguage.method_extract}.to raise_error(
|
26
|
+
NotImplementedError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "When try to call class_extract" do
|
31
|
+
it "Try to call class_extract" do
|
32
|
+
expect{@abstractLanguage.class_extract}.to raise_error(
|
33
|
+
NotImplementedError)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "When try to call attribute_extract" do
|
38
|
+
it "Try to call attribute_extract" do
|
39
|
+
expect{@abstractLanguage.attribute_extract}.to raise_error(
|
40
|
+
NotImplementedError)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "When try to call global_variable_extract" do
|
45
|
+
it "Try to call global_variable_extract." do
|
46
|
+
expect{@abstractLanguage.global_variable_extract}.to raise_error(
|
47
|
+
NotImplementedError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "When try to call extern_requirement_extract" do
|
52
|
+
it "Try to call extern_requirement_extract" do
|
53
|
+
expect{@abstractLanguage.extern_requirement_extract}.to raise_error(
|
54
|
+
NotImplementedError)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "When try to call get_name" do
|
59
|
+
it "Try to call get_name" do
|
60
|
+
expect(@abstractLanguage.get_name).to eq(nil)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "When try to call get_path" do
|
65
|
+
it "Try to call get_path" do
|
66
|
+
expect(@abstractLanguage.get_path).to eq(nil)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
after :all do
|
71
|
+
@abstractLanguage = nil
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Languages::Ruby::AttributeRuby do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@rubyAttr = Languages::Ruby::AttributeRuby.new
|
7
|
+
@singleResult = "value"
|
8
|
+
@multiResult = ["value1", "value2", "value3", "value4"]
|
9
|
+
end
|
10
|
+
|
11
|
+
context "When is a single attribute with @" do
|
12
|
+
it "Simple case with @" do
|
13
|
+
captured = @rubyAttr.get_attribute("@value")[0]
|
14
|
+
expect(captured.name).to eq(@singleResult)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "Whitespace before" do
|
18
|
+
captured = @rubyAttr.get_attribute(" @value")[0]
|
19
|
+
expect(captured.name).to eq(@singleResult)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "Between whitespace" do
|
23
|
+
captured = @rubyAttr.get_attribute(" @value ")[0]
|
24
|
+
expect(captured.name).to eq(@singleResult)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "When is a single attribute with attr_e" do
|
29
|
+
it "With attr_write" do
|
30
|
+
captured = @rubyAttr.get_attribute("attr_write :value")[0]
|
31
|
+
expect(captured.name).to eq(@singleResult)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "With attr_read" do
|
35
|
+
captured = @rubyAttr.get_attribute("attr_read :value")[0]
|
36
|
+
expect(captured.name).to eq(@singleResult)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "With attr_accessor" do
|
40
|
+
captured = @rubyAttr.get_attribute("attr_accessor :value")[0]
|
41
|
+
expect(captured.name).to eq(@singleResult)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "With whitespace before attr_write" do
|
45
|
+
captured = @rubyAttr.get_attribute(" attr_write :value")[0]
|
46
|
+
expect(captured.name).to eq(@singleResult)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "With whitespace before attr_write" do
|
50
|
+
captured = @rubyAttr.get_attribute(" attr_write :value")[0]
|
51
|
+
expect(captured.name).to eq(@singleResult)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "With whitespace before and after attr_read" do
|
55
|
+
captured = @rubyAttr.get_attribute(" attr_read :value ")[0]
|
56
|
+
expect(captured.name).to eq(@singleResult)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
RSpec.shared_examples "Multiple declaration" do |input, description|
|
61
|
+
|
62
|
+
it ": #{description}" do
|
63
|
+
listResult = []
|
64
|
+
capturedList = @rubyAttr.get_attribute(input)
|
65
|
+
capturedList.each do |element|
|
66
|
+
listResult.push(element.name)
|
67
|
+
end
|
68
|
+
expect(listResult).to match_array(@multiResult)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
context "When multiple declarations with comma" do
|
74
|
+
input = "@value1, @value2, @value3, @value4"
|
75
|
+
message = "Use only one space."
|
76
|
+
include_examples "Multiple declaration", input, message
|
77
|
+
|
78
|
+
message = "Whitespace in the beginning."
|
79
|
+
include_examples "Multiple declaration", " " + input, message
|
80
|
+
|
81
|
+
message = "Whitespace in the end."
|
82
|
+
include_examples "Multiple declaration", input + " ", message
|
83
|
+
|
84
|
+
message = "Whitespace in the beginning and in the end."
|
85
|
+
include_examples "Multiple declaration", " " + input + " ", message
|
86
|
+
|
87
|
+
message = "White space after comma."
|
88
|
+
include_examples "Multiple declaration", input.gsub(/,/, ", "), message
|
89
|
+
|
90
|
+
message = "Whitespace before and after comma."
|
91
|
+
include_examples "Multiple declaration", input.gsub(/,/, " , "), message
|
92
|
+
|
93
|
+
message = "Many whitespace before and after comma."
|
94
|
+
include_examples "Multiple declaration", input.gsub(/,/, " , "), message
|
95
|
+
|
96
|
+
input = "@value1 = 3, @value2 = 1, @value3 = 324, @value4=28"
|
97
|
+
message = "Assignment."
|
98
|
+
include_examples "Multiple declaration", input, message
|
99
|
+
|
100
|
+
input = "@value1 = 3, @value2 = 1, @value3, @value4=28"
|
101
|
+
message = "Partial Assignment."
|
102
|
+
include_examples "Multiple declaration", input, message
|
103
|
+
end
|
104
|
+
|
105
|
+
context "# Multiple declaration (equal)" do
|
106
|
+
input = "@value1 = @value2 = @value3 = @value4"
|
107
|
+
message = "Separated by equal."
|
108
|
+
include_examples "Multiple declaration", input, message
|
109
|
+
|
110
|
+
message = "Whitespace in the beginning."
|
111
|
+
include_examples "Multiple declaration", " " + input, message
|
112
|
+
|
113
|
+
message = "Whitespace in the end."
|
114
|
+
include_examples "Multiple declaration", input + " "
|
115
|
+
|
116
|
+
message = "Whitespace in before and after the input."
|
117
|
+
include_examples "Multiple declaration", " " + input + " ", message
|
118
|
+
|
119
|
+
message = "Whitespace between equal."
|
120
|
+
include_examples "Multiple declaration", input.gsub(/=/, " = "), message
|
121
|
+
end
|
122
|
+
|
123
|
+
after :all do
|
124
|
+
@rubyAttr = nil
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Languages::Ruby::ClassRuby do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@classRuby = Languages::Ruby::ClassRuby.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "When is class without inheritance" do
|
10
|
+
it "Ordinary class declaration." do
|
11
|
+
classNameCaptured = @classRuby.get_class("class Xpto").name
|
12
|
+
expect(classNameCaptured).to eq("Xpto")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "Class declaration with whitespace." do
|
16
|
+
classNameCaptured = @classRuby.get_class(" class Xpto").name
|
17
|
+
expect(classNameCaptured).to eq("Xpto")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "Class declaration between whitespace." do
|
21
|
+
classNameCaptured = @classRuby.get_class(" class Xpto ").name
|
22
|
+
expect(classNameCaptured).to eq("Xpto")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "Class declaration with whitespace in the beginning." do
|
26
|
+
classNameCaptured = @classRuby.get_class(" class Xpto").name
|
27
|
+
expect(classNameCaptured).to eq("Xpto")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "Class declaration with whitespace in the end." do
|
31
|
+
classNameCaptured = @classRuby.get_class("class Xpto ").name
|
32
|
+
expect(classNameCaptured).to eq("Xpto")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "Class declaration delimited by whitespace." do
|
36
|
+
classNameCaptured = @classRuby.get_class(" class Xpto ").name
|
37
|
+
expect(classNameCaptured).to eq("Xpto")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "Class declaration with a few whitespace." do
|
41
|
+
classNameCaptured = @classRuby.get_class(" class Xpto ").name
|
42
|
+
expect(classNameCaptured).to eq("Xpto")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "Class declaration with whitespace in the beginning." do
|
46
|
+
classNameCaptured = @classRuby.get_class(" class Xpto").name
|
47
|
+
expect(classNameCaptured).to eq("Xpto")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "Class declaration ended with whitespace." do
|
51
|
+
classNameCaptured = @classRuby.get_class("class Xpto ").name
|
52
|
+
expect(classNameCaptured).to eq("Xpto")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "Class declaration with many whitespace." do
|
56
|
+
classNameCaptured = @classRuby.get_class(" class Xpto ").name
|
57
|
+
expect(classNameCaptured).to eq("Xpto")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "Class declaration with tab." do
|
61
|
+
classNameCaptured = @classRuby.get_class(" class Xpto ").name
|
62
|
+
expect(classNameCaptured).to eq("Xpto")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "When with inheritance" do
|
67
|
+
it "Simple class inheritance." do
|
68
|
+
classNameCaptured = @classRuby.get_class("class Xpto < Abc").name
|
69
|
+
expect(classNameCaptured).to eq("Xpto")
|
70
|
+
end
|
71
|
+
|
72
|
+
it "Class inheritance with whitespace in the beginning." do
|
73
|
+
classNameCaptured = @classRuby.get_class(" class Xpto < Abc").name
|
74
|
+
expect(classNameCaptured).to eq("Xpto")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "Class inheritance with whitespace between <." do
|
78
|
+
classNameCaptured = @classRuby.get_class("class Xpto < Abc").name
|
79
|
+
expect(classNameCaptured).to eq("Xpto")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "Class inheritance with many whitespace." do
|
83
|
+
classNameCaptured = @classRuby.get_class(" class Xpto < Abc ").name
|
84
|
+
expect(classNameCaptured).to eq("Xpto")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "Class inheritance with many whitespace between <." do
|
88
|
+
classNameCaptured = @classRuby.get_class("class Xpto < Abc").name
|
89
|
+
expect(classNameCaptured).to eq("Xpto")
|
90
|
+
end
|
91
|
+
|
92
|
+
it "Class inheritance with whitespace in the corners." do
|
93
|
+
classNameCaptured = @classRuby.get_class(" class Xpto < Abc ").name
|
94
|
+
expect(classNameCaptured).to eq("Xpto")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
after :all do
|
99
|
+
@classRuby = nil
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Languages::Ruby::CommentRuby do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@rubyComment = Languages::Ruby::CommentRuby.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "When it is a single line comment." do
|
10
|
+
|
11
|
+
it "Simple case of single line comment." do
|
12
|
+
comment = @rubyComment.get_comment("# Comment 1")
|
13
|
+
expect(comment).to eq(" Comment 1")
|
14
|
+
|
15
|
+
comment = @rubyComment.get_comment("# Comment number 2")
|
16
|
+
expect(comment).to eq(" Comment number 2")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "Comment with multiple spaces." do
|
20
|
+
comment = @rubyComment.get_comment(" # Comment 1")
|
21
|
+
expect(comment).to eq(" Comment 1")
|
22
|
+
|
23
|
+
comment = @rubyComment.get_comment(" # Comment 2")
|
24
|
+
expect(comment).to eq(" Comment 2")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "Check if is a single line comment." do
|
28
|
+
comment = @rubyComment.is_single_line_comment?(" # Comment")
|
29
|
+
expect(comment).to eq(true)
|
30
|
+
|
31
|
+
comment = @rubyComment.is_single_line_comment?(" # Comment ")
|
32
|
+
expect(comment).to eq(true)
|
33
|
+
|
34
|
+
comment = @rubyComment.is_single_line_comment?(" =begin")
|
35
|
+
expect(comment).to eq(false)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "No comment." do
|
39
|
+
comment = @rubyComment.get_comment("class Xpto")
|
40
|
+
expect(comment).to eq(nil)
|
41
|
+
|
42
|
+
comment = @rubyComment.get_comment("@value")
|
43
|
+
expect(comment).to eq(nil)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "When it is a multiple line comment" do
|
49
|
+
|
50
|
+
it "Simple case that indicates multiple line." do
|
51
|
+
comment = @rubyComment.is_multiple_line_comment?("=begin")
|
52
|
+
expect(comment).to eq(true)
|
53
|
+
|
54
|
+
comment = @rubyComment.is_multiple_line_comment?(" =begin")
|
55
|
+
expect(comment).to eq(false)
|
56
|
+
|
57
|
+
comment = @rubyComment.is_multiple_line_comment?(" =begin ")
|
58
|
+
expect(comment).to eq(false)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "Find final of multiple line comment." do
|
62
|
+
comment = @rubyComment.is_multiple_line_comment_end?(" =end")
|
63
|
+
expect(comment).to eq(false)
|
64
|
+
|
65
|
+
comment = @rubyComment.is_multiple_line_comment_end?("=end")
|
66
|
+
expect(comment).to eq(true)
|
67
|
+
|
68
|
+
comment = @rubyComment.is_multiple_line_comment_end?("no")
|
69
|
+
expect(comment).to eq(false)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
after :all do
|
75
|
+
@rubyComment = nil
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Languages::Ruby::ConditionalRuby do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@conditionalRuby = Languages::Ruby::ConditionalRuby.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "When it is if statment." do
|
10
|
+
it "Simple if statment." do
|
11
|
+
input = "if x < 3"
|
12
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
13
|
+
expect(conditionalCaptured).to eq("x < 3")
|
14
|
+
|
15
|
+
input = "if 2 < 3"
|
16
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
17
|
+
expect(conditionalCaptured).to eq("2 < 3")
|
18
|
+
|
19
|
+
input = "if abc && xpto"
|
20
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
21
|
+
expect(conditionalCaptured).to eq("abc && xpto")
|
22
|
+
|
23
|
+
input = "if x == 222222"
|
24
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
25
|
+
expect(conditionalCaptured).to eq("x == 222222")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "Simple if statment with spaces." do
|
29
|
+
input = " if x == y"
|
30
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
31
|
+
expect(conditionalCaptured).to eq("x == y")
|
32
|
+
|
33
|
+
input = " if k && u && y || x "
|
34
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
35
|
+
expect(conditionalCaptured).to eq("k && u && y || x")
|
36
|
+
|
37
|
+
input = " if k && u && y"
|
38
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
39
|
+
expect(conditionalCaptured).to eq("k && u && y")
|
40
|
+
|
41
|
+
input = " if k"
|
42
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
43
|
+
expect(conditionalCaptured).to eq("k")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "Using unless statment" do
|
49
|
+
it "Simple unless statment." do
|
50
|
+
input = "unless a > b"
|
51
|
+
unlessCaptured = @conditionalRuby.get_conditional(input).expression
|
52
|
+
expect(unlessCaptured).to eq("a > b")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "Simple unless statment with spaces." do
|
56
|
+
input = " unless a > b "
|
57
|
+
unlessCaptured = @conditionalRuby.get_conditional(input).expression
|
58
|
+
expect(unlessCaptured).to eq("a > b")
|
59
|
+
|
60
|
+
input = " unless a && b "
|
61
|
+
unlessCaptured = @conditionalRuby.get_conditional(input).expression
|
62
|
+
expect(unlessCaptured).to eq("a && b")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "Using elsif" do
|
67
|
+
it "Simple elsif statment." do
|
68
|
+
input = "elsif n > m"
|
69
|
+
elsifCaptured = @conditionalRuby.get_conditional(input).expression
|
70
|
+
expect(elsifCaptured).to eq("n > m")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "Simple elsif statement with spaces." do
|
74
|
+
input = " elsif n > m "
|
75
|
+
elsifCaptured = @conditionalRuby.get_conditional(input).expression
|
76
|
+
expect(elsifCaptured).to eq("n > m")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "When is case statment." do
|
81
|
+
it "Simple case statment." do
|
82
|
+
input = "case options"
|
83
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
84
|
+
expect(conditionalCaptured).to eq("options")
|
85
|
+
|
86
|
+
input = "case abc"
|
87
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
88
|
+
expect(conditionalCaptured).to eq("abc")
|
89
|
+
end
|
90
|
+
|
91
|
+
it "Case with spaces" do
|
92
|
+
input = " case abc "
|
93
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
94
|
+
expect(conditionalCaptured).to eq("abc")
|
95
|
+
|
96
|
+
input = " case abc "
|
97
|
+
conditionalCaptured = @conditionalRuby.get_conditional(input).expression
|
98
|
+
expect(conditionalCaptured).to eq("abc")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
after :each do
|
103
|
+
@conditionalRuby = nil
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Languages::Ruby::ConstructorRuby do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@constructor = Languages::Ruby::ConstructorRuby.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "When constructor without parameter" do
|
10
|
+
it "Simple declaration" do
|
11
|
+
input = "def initialize"
|
12
|
+
expect(@constructor.get_constructor(input).name)
|
13
|
+
.to eq("initialize")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "With spaces in the begin" do
|
17
|
+
input = " def initialize"
|
18
|
+
expect(@constructor.get_constructor(input).name)
|
19
|
+
.to eq("initialize")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "With spaces in the begin and between initialize" do
|
23
|
+
input = " def initialize"
|
24
|
+
expect(@constructor.get_constructor(input).name)
|
25
|
+
.to eq("initialize")
|
26
|
+
input = " def initialize"
|
27
|
+
expect(@constructor.get_constructor(input).name)
|
28
|
+
.to eq("initialize")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "With spaces in the end" do
|
32
|
+
input = "def initialize "
|
33
|
+
expect(@constructor.get_constructor(input).name)
|
34
|
+
.to eq("initialize")
|
35
|
+
input = "def initialize "
|
36
|
+
expect(@constructor.get_constructor(input).name)
|
37
|
+
.to eq("initialize")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "With spaces in both sides" do
|
41
|
+
input = " def initialize "
|
42
|
+
expect(@constructor.get_constructor(input).name)
|
43
|
+
.to eq("initialize")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "No constructor" do
|
47
|
+
input = " def methodX"
|
48
|
+
expect(@constructor.get_constructor(input))
|
49
|
+
.to eq(nil)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
after :all do
|
54
|
+
@constructor = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|