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,33 @@
|
|
1
|
+
=begin
|
2
|
+
This is the
|
3
|
+
first class
|
4
|
+
of this file.
|
5
|
+
=end
|
6
|
+
|
7
|
+
class Xpto
|
8
|
+
|
9
|
+
|
10
|
+
=begin
|
11
|
+
Constructor
|
12
|
+
initialize
|
13
|
+
=end
|
14
|
+
def initialize
|
15
|
+
puts "Nothing else matters..."
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
=begin
|
20
|
+
First method
|
21
|
+
=end
|
22
|
+
def methodOne
|
23
|
+
puts "Wake up!"
|
24
|
+
end
|
25
|
+
|
26
|
+
=begin
|
27
|
+
methodTwo
|
28
|
+
=end
|
29
|
+
def methodTwo
|
30
|
+
puts "I don't think you trust!"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
=begin
|
2
|
+
Comment 1:
|
3
|
+
Multiple line.
|
4
|
+
=end
|
5
|
+
|
6
|
+
require_relative 'simple_multiple_line_comment_class.rb'
|
7
|
+
|
8
|
+
=begin
|
9
|
+
Global Function
|
10
|
+
number one
|
11
|
+
multiple line
|
12
|
+
=end
|
13
|
+
def global_function
|
14
|
+
puts "It's me, global function!"
|
15
|
+
end
|
16
|
+
|
17
|
+
=begin
|
18
|
+
global
|
19
|
+
=end
|
20
|
+
@globalVariable
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Comment 1: class
|
2
|
+
class Xpto
|
3
|
+
|
4
|
+
# Comment 2: constructor
|
5
|
+
def initialize
|
6
|
+
puts "Nothing"
|
7
|
+
end
|
8
|
+
|
9
|
+
# Comment 3: method
|
10
|
+
def method_1
|
11
|
+
return nil
|
12
|
+
end
|
13
|
+
|
14
|
+
# Comment 4: Combo 1
|
15
|
+
# Comment 5: Combo 2
|
16
|
+
def method_2 (krakatoa, abc)
|
17
|
+
puts "Nothing..."
|
18
|
+
end
|
19
|
+
|
20
|
+
# Comment 6: Attribute
|
21
|
+
@magicAttribute
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# First comment
|
2
|
+
require_relative "simple_single_line_comment_class"
|
3
|
+
|
4
|
+
# Comment 2
|
5
|
+
def global_function_1
|
6
|
+
puts "nothing else..."
|
7
|
+
end
|
8
|
+
|
9
|
+
# Combo comment p1
|
10
|
+
# Combo comment p2
|
11
|
+
def global_function_2
|
12
|
+
puts "COMBOOOO"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Comment 4
|
16
|
+
@variable
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class simple1
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
if a > b
|
5
|
+
x = 8
|
6
|
+
end
|
7
|
+
|
8
|
+
case x
|
9
|
+
when 3
|
10
|
+
y = 9
|
11
|
+
when 8
|
12
|
+
y = 11
|
13
|
+
when 90
|
14
|
+
y = -1
|
15
|
+
else
|
16
|
+
y = 0
|
17
|
+
end
|
18
|
+
|
19
|
+
if u && y
|
20
|
+
u = 0
|
21
|
+
elsif u == 1
|
22
|
+
u = 9
|
23
|
+
else
|
24
|
+
u = 10
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class SimpleClass1
|
2
|
+
|
3
|
+
def method1
|
4
|
+
if x > 3
|
5
|
+
x = 4
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def method2 (b, c)
|
10
|
+
if b && c
|
11
|
+
u = 89
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def method3 (b)
|
16
|
+
if b == 3
|
17
|
+
u = 9
|
18
|
+
elsif b < 7
|
19
|
+
u = 200
|
20
|
+
else
|
21
|
+
k = 0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def method4 (x)
|
26
|
+
unless x
|
27
|
+
i = 9
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def method5 (y)
|
32
|
+
case y
|
33
|
+
when 5
|
34
|
+
return 8
|
35
|
+
when 3
|
36
|
+
return 's'
|
37
|
+
else
|
38
|
+
return 2
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
def simple1
|
2
|
+
|
3
|
+
if 3 > 2
|
4
|
+
x = 3
|
5
|
+
end
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
def simple2
|
10
|
+
|
11
|
+
if 7 > 2
|
12
|
+
y = 8
|
13
|
+
end
|
14
|
+
|
15
|
+
if "a" < "k"
|
16
|
+
j = "k"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def simple3
|
22
|
+
|
23
|
+
if 3 > 2
|
24
|
+
p = 7
|
25
|
+
elsif 67 < 40
|
26
|
+
p = 12
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def simple4(p)
|
32
|
+
|
33
|
+
case p
|
34
|
+
when 2
|
35
|
+
x = 3
|
36
|
+
when 4
|
37
|
+
y = 12
|
38
|
+
when 7
|
39
|
+
k = 9
|
40
|
+
else
|
41
|
+
u = 8
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Simple1
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
end
|
5
|
+
|
6
|
+
end
|
7
|
+
|
8
|
+
class Simple2
|
9
|
+
def initialize (param)
|
10
|
+
end
|
11
|
+
|
12
|
+
def abc
|
13
|
+
end
|
14
|
+
|
15
|
+
def xpto
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
class Simple2
|
21
|
+
|
22
|
+
def gjh
|
23
|
+
end
|
24
|
+
def initialize (param)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
def simpleFunction1
|
2
|
+
end
|
3
|
+
|
4
|
+
def simpleFunction2 (param)
|
5
|
+
end
|
6
|
+
|
7
|
+
def simpleFunction3 (param)
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
def simpleFunction4 (param)
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def simpleFunction5 (param1, param2)
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def simpleFunction6 (param1)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def simpleFunction7(param1, param2)
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class SimpleClass
|
2
|
+
|
3
|
+
def simple1
|
4
|
+
i = 0
|
5
|
+
num = 5
|
6
|
+
|
7
|
+
while i < num do
|
8
|
+
i += 1
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def simple2 (i, num)
|
13
|
+
until i > num do
|
14
|
+
puts("Inside the loop i = ")
|
15
|
+
i += 1;
|
16
|
+
end
|
17
|
+
|
18
|
+
for i in 0..5
|
19
|
+
puts "Value of local variable is"
|
20
|
+
end
|
21
|
+
|
22
|
+
begin
|
23
|
+
puts("Inside the loop i = " )
|
24
|
+
i += 1
|
25
|
+
end while i < num
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib/kuniri'))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'config'))
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require 'rspec'
|
6
|
+
require 'coveralls'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.order = 'random'
|
10
|
+
end
|
11
|
+
|
12
|
+
Dir[File.join(File.dirname(__FILE__), "../config/**" , "**.rb")].each do |f|
|
13
|
+
require_relative f
|
14
|
+
end
|
15
|
+
|
16
|
+
Dir[File.join(File.dirname(__FILE__), "../lib/kuniri/**" , "**.rb")].each do |f|
|
17
|
+
require_relative f
|
18
|
+
end
|
19
|
+
|
20
|
+
Coveralls.wear!
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../../spec_helper.rb'
|
2
|
+
|
3
|
+
RSpec.describe StateMachine::OOStructuredFSM::AttributeState do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@languageState = Languages::RubySyntax.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "#Correct flow." do
|
10
|
+
it "Attribute state." do
|
11
|
+
@languageState.class_capture
|
12
|
+
@languageState.attribute_capture
|
13
|
+
expect(@languageState.state)
|
14
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::AttributeState)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "Going back to class." do
|
18
|
+
@languageState.class_capture
|
19
|
+
@languageState.attribute_capture
|
20
|
+
expect(@languageState.state)
|
21
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::AttributeState)
|
22
|
+
@languageState.class_capture
|
23
|
+
expect(@languageState.state)
|
24
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ClassState)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "#Uncorrect flow." do
|
29
|
+
it "From attribute state, try go to invalid state." do
|
30
|
+
@languageState.class_capture
|
31
|
+
@languageState.attribute_capture
|
32
|
+
expect{@languageState.method_capture}
|
33
|
+
.to raise_error(NotImplementedError)
|
34
|
+
expect{@languageState.function_capture}
|
35
|
+
.to raise_error(NotImplementedError)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
after :each do
|
41
|
+
@languageState = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe StateMachine::OOStructuredFSM::ClassState do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@classStateTest = Languages::RubySyntax.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Class state, correct flow." do
|
10
|
+
it "Idle to class." do
|
11
|
+
@classStateTest.class_capture
|
12
|
+
expect(@classStateTest.state)
|
13
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ClassState)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "Class to idle." do
|
17
|
+
@classStateTest.class_capture
|
18
|
+
@classStateTest.idle_capture
|
19
|
+
expect(@classStateTest.state)
|
20
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::IdleState)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "Class to method." do
|
24
|
+
@classStateTest.class_capture
|
25
|
+
@classStateTest.method_capture
|
26
|
+
expect(@classStateTest.state)
|
27
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::MethodState)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "Method to class." do
|
31
|
+
@classStateTest.class_capture
|
32
|
+
@classStateTest.method_capture
|
33
|
+
@classStateTest.class_capture
|
34
|
+
expect(@classStateTest.state)
|
35
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ClassState)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "Class to attribute." do
|
39
|
+
@classStateTest.class_capture
|
40
|
+
@classStateTest.attribute_capture
|
41
|
+
expect(@classStateTest.state)
|
42
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::AttributeState)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "Attribute to class." do
|
46
|
+
@classStateTest.class_capture
|
47
|
+
@classStateTest.attribute_capture
|
48
|
+
@classStateTest.class_capture
|
49
|
+
expect(@classStateTest.state)
|
50
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ClassState)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "Class to constructor." do
|
54
|
+
@classStateTest.class_capture
|
55
|
+
@classStateTest.constructor_capture
|
56
|
+
expect(@classStateTest.state)
|
57
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ConstructorState)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "Constructor to class." do
|
61
|
+
@classStateTest.class_capture
|
62
|
+
@classStateTest.constructor_capture
|
63
|
+
@classStateTest.class_capture
|
64
|
+
expect(@classStateTest.state)
|
65
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ClassState)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "Module to class" do
|
69
|
+
@classStateTest.class_capture
|
70
|
+
@classStateTest.module_capture
|
71
|
+
@classStateTest.class_capture
|
72
|
+
expect(@classStateTest.state)
|
73
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ClassState)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
context "Wrong state, incorrect flow." do
|
79
|
+
it "Wrong state change." do
|
80
|
+
@classStateTest.class_capture
|
81
|
+
expect{@classStateTest.variable_capture}
|
82
|
+
.to raise_error(NotImplementedError)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
after :each do
|
87
|
+
@classStateTest = nil
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe StateMachine::OOStructuredFSM::CommentState do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@rubyTest = Languages::RubySyntax.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Correct flow" do
|
10
|
+
|
11
|
+
it "Idle to comment." do
|
12
|
+
@rubyTest.state.comment_capture
|
13
|
+
expect(@rubyTest.state)
|
14
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::CommentState)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "Class to comment." do
|
18
|
+
@rubyTest.state.class_capture
|
19
|
+
@rubyTest.state.comment_capture
|
20
|
+
expect(@rubyTest.state)
|
21
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::CommentState)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
after :each do
|
27
|
+
@rubyTest = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe StateMachine::OOStructuredFSM::ConditionalState do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@conditionalTest = Languages::RubySyntax.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Correct flow, function." do
|
10
|
+
it "Idle to global function, to conditional." do
|
11
|
+
@conditionalTest.state.function_capture
|
12
|
+
@conditionalTest.state.conditional_capture
|
13
|
+
expect(@conditionalTest.state)
|
14
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ConditionalState)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "Conditional to idle." do
|
18
|
+
@conditionalTest.state.function_capture
|
19
|
+
@conditionalTest.state.conditional_capture
|
20
|
+
@conditionalTest.state.function_capture
|
21
|
+
expect(@conditionalTest.state)
|
22
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::FunctionState)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "Correct flow, method." do
|
27
|
+
it "Idle to class, method, and conditional." do
|
28
|
+
@conditionalTest.state.class_capture
|
29
|
+
@conditionalTest.state.method_capture
|
30
|
+
@conditionalTest.state.conditional_capture
|
31
|
+
expect(@conditionalTest.state)
|
32
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ConditionalState)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "Conditional to idle (method)." do
|
36
|
+
@conditionalTest.state.class_capture
|
37
|
+
@conditionalTest.state.method_capture
|
38
|
+
@conditionalTest.state.conditional_capture
|
39
|
+
@conditionalTest.state.method_capture
|
40
|
+
expect(@conditionalTest.state)
|
41
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::MethodState)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "Correct flow, constructor." do
|
46
|
+
it "Idle to constructor, and conditional." do
|
47
|
+
@conditionalTest.state.class_capture
|
48
|
+
@conditionalTest.state.constructor_capture
|
49
|
+
@conditionalTest.state.conditional_capture
|
50
|
+
expect(@conditionalTest.state)
|
51
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ConditionalState)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "Conditional to idle (constructor)." do
|
55
|
+
@conditionalTest.state.class_capture
|
56
|
+
@conditionalTest.state.constructor_capture
|
57
|
+
@conditionalTest.state.conditional_capture
|
58
|
+
@conditionalTest.state.constructor_capture
|
59
|
+
expect(@conditionalTest.state)
|
60
|
+
.to be_instance_of(StateMachine::OOStructuredFSM::ConstructorState)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "Incorrect flow." do
|
65
|
+
it "Try to access IdleState, to ConditionalState." do
|
66
|
+
expect{@conditionalTest.state.conditional_capture}
|
67
|
+
.to raise_error(NotImplementedError)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "Try to jump from Conditional state to idle." do
|
71
|
+
@conditionalTest.state.class_capture
|
72
|
+
@conditionalTest.state.method_capture
|
73
|
+
@conditionalTest.state.conditional_capture
|
74
|
+
expect{@conditionalTest.state.class_capture}
|
75
|
+
.to raise_error(NotImplementedError)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
after :each do
|
80
|
+
@constructorTest = nil
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|