cauldron 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/Gemfile +6 -0
  2. data/Gemfile.lock +63 -0
  3. data/History.md +5 -0
  4. data/Rakefile +62 -16
  5. data/VERSION +1 -1
  6. data/cauldron.gemspec +463 -0
  7. data/cauldron/lib/cauldron.rb +1 -1
  8. data/features/cauldron_generates_runtime_method.feature +7 -4
  9. data/features/cauldron_generates_single_paramter_methods.feature +25 -0
  10. data/features/cauldron_interactive_start_terminal.feature +17 -0
  11. data/features/cauldron_quit_terminal.feature +9 -0
  12. data/features/cauldron_start_terminal.feature +0 -1
  13. data/features/step_definitions/cauldron_steps.rb +10 -5
  14. data/features/step_definitions/terminal_steps.rb +27 -0
  15. data/features/support/env.rb +2 -0
  16. data/features/support/hooks.rb +15 -0
  17. data/lib/Chain.rb +3 -3
  18. data/lib/Mapping.rb +1 -0
  19. data/lib/PartialChain.rb +253 -0
  20. data/lib/Theory.rb +28 -4
  21. data/lib/UnifiedChain.rb +94 -125
  22. data/lib/cauldron.rb +3 -0
  23. data/lib/cauldron/demos.rb +4 -4
  24. data/lib/cauldron/env.rb +1 -0
  25. data/lib/cauldron/pot.rb +42 -38
  26. data/lib/cauldron/terminal.rb +19 -3
  27. data/lib/cauldron/util/home.rb +21 -0
  28. data/lib/cauldron/util/saver.rb +45 -0
  29. data/lib/core/Container.rb +1 -1
  30. data/lib/core/runtime_method/ActsAsRuntimeMethod.rb +28 -28
  31. data/lib/core/runtime_method/RuntimeMethod.rb +6 -23
  32. data/lib/core/statement/ActsAsStatement.rb +0 -96
  33. data/lib/core/statement/BlockStatement.rb +1 -1
  34. data/lib/core/statement/OpenStatement.rb +1 -1
  35. data/lib/core/statement/Statement.rb +39 -94
  36. data/lib/core/statement/TheoryStatement.rb +1 -1
  37. data/lib/core/syntax/BlockContainer.rb +0 -28
  38. data/lib/core/variable/MethodParameter.rb +1 -1
  39. data/lib/required.rb +2 -14
  40. data/lib/theories.rb +0 -1
  41. data/lib/theory/ActionImplementation.rb +1 -1
  42. data/lib/theory/TheoryAction.rb +2 -2
  43. data/lib/theory/TheoryConnector.rb +11 -14
  44. data/lib/theory/TheoryImplementation.rb +10 -9
  45. data/lib/util/MethodWriter.rb +10 -10
  46. data/sandbox.rb +23 -0
  47. data/spec/cauldron/pot_spec.rb +62 -10
  48. data/spec/cauldron/runtime_method_spec.rb +31 -17
  49. data/spec/cauldron/saver_spec.rb +45 -0
  50. data/spec/cauldron/terminal_spec.rb +10 -1
  51. data/spec/cauldron/theory_spec.rb +4 -4
  52. data/spec/cauldron/unified_chain_spec.rb +38 -0
  53. data/spec/spec_helper.rb +3 -1
  54. data/tasks/development_tasks.rake +4 -0
  55. data/tasks/theory_tasks.rake +16 -20
  56. data/test/fixtures/theories/0/desc +6 -6
  57. data/test/fixtures/theories/0/dump +0 -0
  58. data/test/fixtures/theories/1/desc +7 -7
  59. data/test/fixtures/theories/1/dump +0 -0
  60. data/test/fixtures/theories/10/desc +13 -13
  61. data/test/fixtures/theories/10/dump +0 -0
  62. data/test/fixtures/theories/11/desc +10 -10
  63. data/test/fixtures/theories/11/dump +0 -0
  64. data/test/fixtures/theories/12/desc +9 -9
  65. data/test/fixtures/theories/12/dump +0 -0
  66. data/test/fixtures/theories/13/desc +16 -16
  67. data/test/fixtures/theories/13/dump +0 -0
  68. data/test/fixtures/theories/14/desc +16 -16
  69. data/test/fixtures/theories/14/dump +0 -0
  70. data/test/fixtures/theories/15/desc +10 -10
  71. data/test/fixtures/theories/15/dump +0 -0
  72. data/test/fixtures/theories/16/desc +10 -10
  73. data/test/fixtures/theories/16/dump +0 -0
  74. data/test/fixtures/theories/17/desc +7 -7
  75. data/test/fixtures/theories/17/dump +0 -0
  76. data/test/fixtures/theories/18/desc +7 -7
  77. data/test/fixtures/theories/18/dump +0 -0
  78. data/test/fixtures/theories/19/desc +7 -7
  79. data/test/fixtures/theories/19/dump +0 -0
  80. data/test/fixtures/theories/2/desc +6 -6
  81. data/test/fixtures/theories/2/dump +0 -0
  82. data/test/fixtures/theories/20/desc +13 -13
  83. data/test/fixtures/theories/20/dump +0 -0
  84. data/test/fixtures/theories/3/desc +7 -7
  85. data/test/fixtures/theories/3/dump +0 -0
  86. data/test/fixtures/theories/4/desc +7 -7
  87. data/test/fixtures/theories/4/dump +0 -0
  88. data/test/fixtures/theories/5/desc +6 -6
  89. data/test/fixtures/theories/5/dump +0 -0
  90. data/test/fixtures/theories/6/desc +7 -7
  91. data/test/fixtures/theories/6/dump +0 -0
  92. data/test/fixtures/theories/7/desc +7 -7
  93. data/test/fixtures/theories/7/dump +0 -0
  94. data/test/fixtures/theories/8/desc +7 -7
  95. data/test/fixtures/theories/8/dump +0 -0
  96. data/test/fixtures/theories/9/desc +16 -16
  97. data/test/fixtures/theories/9/dump +0 -0
  98. data/test/fixtures/theory_implementations/0/dump +0 -0
  99. data/test/fixtures/theory_implementations/2/dump +0 -0
  100. data/test/ts_complete.rb +1 -10
  101. data/test/unit/core/runtime_method/tc_realised_runtime_method.rb +1 -0
  102. data/test/unit/core/runtime_method/tc_runtime_method.rb +16 -39
  103. data/test/unit/core/statement/tc_block_statement.rb +3 -3
  104. data/test/unit/core/statement/tc_open_statement.rb +4 -4
  105. data/test/unit/core/statement/tc_statement.rb +2 -147
  106. data/test/unit/core/statement/tc_theory_statement.rb +1 -1
  107. data/test/unit/theory/tc_theory_dependent.rb +3 -3
  108. data/test/unit/theory/tc_theory_result.rb +5 -5
  109. data/test/unit/util/tc_method_validation.rb +45 -45
  110. data/test/unit/util/tc_parser.rb +1 -1
  111. data/test/unit/util/tc_string_to_theory.rb +2 -2
  112. metadata +74 -48
  113. data/lib/ScopeDependencies.rb +0 -8
  114. data/lib/core/statement/StatementDependencies.rb +0 -271
  115. data/lib/core/structure/DeclareNewInstanceStructure.rb +0 -49
  116. data/lib/core/structure/DeclareRuntimeMethodStructure.rb +0 -34
  117. data/lib/core/structure/DeclareVariableAsLiteralStructure.rb +0 -31
  118. data/lib/core/structure/DeclareVariableAsVariableStructure.rb +0 -52
  119. data/lib/core/structure/FixnumAdditionStructure.rb +0 -56
  120. data/lib/core/structure/InstanceCallContainerStructure.rb +0 -50
  121. data/lib/core/structure/InstanceCallStructure.rb +0 -53
  122. data/lib/core/structure/InstanceMethodCallStructure.rb +0 -21
  123. data/lib/core/structure/ReturnStructure.rb +0 -20
  124. data/lib/core/structure/StatementStructure.rb +0 -11
  125. data/test/unit/core/statement/tc_statement_dependencies.rb +0 -147
  126. data/test/unit/core/structure/tc_declare_new_instance_structure.rb +0 -41
  127. data/test/unit/core/structure/tc_declare_variable_as_literal_structure.rb +0 -41
  128. data/test/unit/core/structure/tc_declare_variable_as_variable_structure.rb +0 -66
  129. data/test/unit/core/structure/tc_instance_call_container_structure.rb +0 -41
  130. data/test/unit/core/structure/tc_return_structure.rb +0 -32
  131. data/test/unit/tc_instance_call_structure.rb +0 -35
  132. data/test/unit/tc_statement_structure_2.rb +0 -43
@@ -1,56 +0,0 @@
1
- # Example
2
- # e.g. var_a = var_b + var_c
3
- #
4
- class FixnumAdditionStructure < StatementStructure
5
-
6
- def initialize()
7
- super([Unknown,Equal,FixnumVariable,Addition,FixnumVariable])
8
- end
9
-
10
- # Returns an array of statements using the available variables that
11
- # follow the structure var = 8 + 6
12
- #
13
- # @param available An array of runtime variables that can be used in the statements
14
- # construction.
15
- #
16
- def statements(available=[])
17
-
18
- # If there aren't any fixnum variables there is nothing to return
19
- return [] unless available.any? {|x| x.pass_as?(FixnumVariable)}
20
-
21
- # First find just varaibles that can pass as FixnumVariables
22
- # NOTE: Currently I am not allowing method calls to be used
23
- fixnum_variables = available.find_all {|x| x.pass_as?(FixnumVariable) and !x.kind_of?(DefCall)}
24
-
25
- # Using the variables constuct statements
26
- possible_statements = []
27
- fixnum_variables.length.times do |x|
28
- fixnum_variables.length.times do |y|
29
- new_statement = Statement.new(Unknown.new,Equal.new,fixnum_variables[x].copy,Addition.new,fixnum_variables[y].copy)
30
- #new_statement.statement_type = DECLARATION_STATEMENT
31
- possible_statements.push(new_statement)
32
- end
33
- end
34
-
35
- # Remove mirror statements - these are additions that are essentially the
36
- # same statement written backwards.
37
- # e.g. var_c = var_a+var_b
38
- # var_d = var_b+var_a
39
- possible_statements.copy.each do |x|
40
- possible_statements.copy.each do |y|
41
- next if x.statement_id == y.statement_id
42
- if y.same_not_declared_variables?(x)
43
-
44
- # If the first variable id is lower than the secound remove it.
45
- if y[2].variable_id < y[4].variable_id
46
- possible_statements.delete_if {|z| z.statement_id == y.statement_id}
47
- end
48
- end
49
- end
50
- end
51
-
52
- return possible_statements
53
-
54
- end
55
-
56
- end
@@ -1,50 +0,0 @@
1
- # Example
2
- # e.g. 'test'.chop
3
- # e.g. 'test'.chop!
4
- #
5
- class InstanceCallContainerStructure < StatementStructure
6
-
7
- def initialize()
8
- super()
9
- end
10
-
11
- # Returns an array of possible statements that make an instance
12
- # call. They don't declare a new variables so to be in any way
13
- # relevant they must be destructive e.g.
14
- #
15
- # 'test'.chop # essential does nothing
16
- # 'test'.chop! # Changes the value ('test' represents a variable with that value)
17
- #
18
- def statements(available=[])
19
-
20
- # Exclude method calls for now - avoiding too complex statements
21
- available.delete_if {|x| x.kind_of?(DefCall)}
22
-
23
- # Go through each method call available to each of the variables
24
- results = []
25
- available.copy.each do |subject_var|
26
-
27
- # Duplicate the available variables and exclude the current one
28
- # to avoid less predicatable statements.
29
- current_available = available.copy.delete_if do |x|
30
- unless(x.kind_of?(Variable) and subject_var.kind_of?(Variable))
31
- next false
32
- end
33
- x.variable_id == subject_var.variable_id
34
- end
35
-
36
- # Create statements that use the specified instance calls
37
- subject_var.destructive_instance_calls(current_available).each do |inst_call|
38
- new_statement = Statement.new(inst_call)
39
-
40
- # TODO I'm not sure if all the instance calls are modifying - I should may have a StatementTemplate
41
- # class that foces the {:review} to be false.
42
- #new_statement.statement_type = MODIFYING_STATEMENT
43
- results.push(new_statement)
44
- end
45
- end
46
-
47
- return results
48
- end
49
-
50
- end
@@ -1,53 +0,0 @@
1
- # TODO I think this class might have been replaced with InstanceCallContainerStructure
2
- class InstanceCallStructure < Array
3
- attr_reader :instance_class, :method_call
4
-
5
- #
6
- # @param instance_class The class of the instance that should be called e.g. StringVariable
7
- # @param method_call An instance of the method_call
8
- # @param parameters The parameters that the instance method call excepts
9
- #
10
- def initialize(instance_class,method_call,*parameters)
11
- # TODO What are the two parameters an array expects
12
- super()
13
-
14
- # Declare the elements that make up the instance call
15
- @instance_class = instance_class
16
- @method_call = method_call
17
-
18
- # Add the parameters to the array
19
- parameters.each do |code|
20
- self.push(code)
21
- end
22
- end
23
-
24
- #
25
- def instance_calls(available=[])
26
-
27
- # Create an array of potential instance calls
28
- potential_instance_calls = []
29
-
30
- # Find a variable thats class is @instance_class
31
- available.each do |avail|
32
-
33
- if avail.class == @instance_class
34
-
35
- # We have a possible instance class
36
- # TODO Try with class and method call mismatch
37
- if self.length == 0
38
- potential_instance_calls.push(InstanceCallContainer.new(avail.copy,@method_call.copy))
39
- next
40
- end
41
-
42
- # Retrieve appropriate values for each of the intance calls parameters
43
-
44
-
45
- end
46
-
47
- end
48
-
49
- return potential_instance_calls
50
-
51
- end
52
-
53
- end
@@ -1,21 +0,0 @@
1
- # This a generic structure that can be used to create any number of
2
- # instance method calls. For example if it was meant to represent
3
- # an array instance it might be able to produce the statement:
4
- #
5
- # array.push(some_value)
6
- #
7
- # TODO This might duplicate the functionality of the InstanceCallContainerStructure
8
- # although I can't remember what I created that for.
9
- #
10
- class InstanceMethodCallStructure < StatementStructure
11
-
12
- #
13
- # @param instance_class The class of the instance that has a method call
14
- # @param method_call A method call instance that can be called from
15
- # instances of the supplied instance_class.
16
- #
17
- def initialize(instance_class,method_call)
18
-
19
- end
20
-
21
- end
@@ -1,20 +0,0 @@
1
- # Returns statements that return values
2
- #
3
- # Example:
4
- # return 7
5
- # return var
6
- #
7
- class ReturnStructure < StatementStructure
8
-
9
- def initialize()
10
- super()
11
- end
12
-
13
- def statements(available=[])
14
-
15
- # Create return statements using the passed variables
16
- return available.collect {|x| Statement.new(Return.new,x.copy)}
17
-
18
- end
19
-
20
- end
@@ -1,11 +0,0 @@
1
- class StatementStructure < Array
2
-
3
- DECLARATION_STATEMENT = 'declaration_statement'
4
- MODIFYING_STATEMENT = 'modifying_statement'
5
- RETURN_STATEMENT = 'return_statement'
6
- USAGE_STATEMENT = 'usage_statement'
7
- MISC_STATEMENT = 'misc_statement'
8
- BLANK_STATEMENT = 'blank_statement'
9
- IF_STATEMENT = 'if_statement'
10
-
11
- end
@@ -1,147 +0,0 @@
1
- $LOAD_PATH << File.expand_path('../../../../../lib',__FILE__)
2
-
3
- require 'required'
4
- require 'test/unit'
5
-
6
- class TestStatementDependencies < Test::Unit::TestCase
7
-
8
- def setup
9
-
10
- #
11
- # var_a = 'Wally'.chop
12
- # var_b = var_a.length
13
- # var_c = var_a.chop
14
-
15
- # Create some statements with dependencies
16
- @wally = Literal.new('Wally')
17
- @chopped_wally = Unknown.new
18
- @chop_wally = Statement.new(@chopped_wally,Equal.new,InstanceCallContainer.new(@wally,Chop.new))
19
- @chopped_length = Unknown.new
20
- @chop_length = Statement.new(@chopped_length,Equal.new,InstanceCallContainer.new(@chopped_wally,StringLength.new))
21
- @wall = Unknown.new
22
- @statement_c = Statement.new(@wall,Equal.new,InstanceCallContainer.new(@chopped_wally,Chop.new))
23
- @hermot = Literal.new('Hermot')
24
- @hermot_var = Unknown.new
25
- @declared_hermot = Statement.new(@hermot_var,Equal.new,@hermot)
26
- @hermo_wall = Unknown.new
27
- @hermo_wall_statement = Statement.new(@hermo_wall,Equal.new,InstanceCallContainer.new(@hermot_var,Chop.new),Addition.new,InstanceCallContainer.new(@chopped_wally,Chop.new))
28
-
29
- # This statement uses variables that haven't been declared in a statement
30
- @bad_statement = Statement.new(Unknown.new,Equal.new,InstanceCallContainer.new(StringVariable.new('badboy'),Chop.new))
31
-
32
- # Chopping wall
33
- @wal = Unknown.new
34
- @statement_d = Statement.new(@wal,Equal.new,InstanceCallContainer.new(@wall,Chop.new))
35
-
36
- # Create a simple set of statement dependencies that use params
37
- # var_a = MethodUsage.new
38
- # var_b = RuntimeMethod.new(var_a)
39
- @dependency_set_1 = StatementDependencies.new
40
- @var_a = Unknown.new
41
- @var_b = Unknown.new
42
- @statement_a = Statement.new(@var_a,Equal.new,ClassMethodCallContainer.new(MethodUsageClass.new,New.new))
43
- @statement_b = Statement.new(@var_b,Equal.new,ClassMethodCallContainer.new(RuntimeMethodClass.new,New.new,@var_a))
44
- @dependency_set_1.push(@statement_a)
45
- @dependency_set_1.push(@statement_b)
46
-
47
-
48
- end
49
-
50
- def teardown
51
- System.reset
52
- end
53
-
54
- def test_push
55
-
56
- # Check statements can be added
57
- statement_depenencies = StatementDependencies.new(@chop_wally)
58
- assert_equal(1,statement_depenencies.length)
59
-
60
- # Check pushing new statements
61
- statement_depenencies.push(@chop_length)
62
- assert_equal(2,statement_depenencies.length)
63
-
64
- # Check that an error is thrown if the statement dependencies can't be found
65
- assert_raises(StandardError){statement_depenencies.push(@bad_statement)}
66
-
67
- # Here we are check depenceys are found for statements with multiple variables in
68
-
69
-
70
- end
71
-
72
- def test_dependencies_for
73
-
74
- statement_depenencies = StatementDependencies.new()
75
- # hermot = 'Hermot'
76
- statement_depenencies.push(@declared_hermot)
77
-
78
- # This statement shouldn't have any depenencies
79
- assert_equal(1,statement_depenencies.dependencies_for(@declared_hermot.statement_id).length)
80
-
81
- # Add a statement dependent on the first statement
82
- # chopped_wally = 'Wally'.chop
83
- statement_depenencies.push(@chop_wally)
84
- assert_equal(1,statement_depenencies.dependencies_for(@chop_wally.statement_id).length)
85
- statement_chop_chop_wally = Statement.new(Unknown.new,Equal.new,InstanceCallContainer.new(@chopped_wally,Chop.new))
86
- statement_depenencies.push(statement_chop_chop_wally)
87
- assert_equal(2,statement_depenencies.dependencies_for(statement_chop_chop_wally.statement_id).length)
88
-
89
- # Now add a string+string statement that uses the above statement
90
- statement_depenencies.push(@hermo_wall_statement)
91
- assert_equal(3,statement_depenencies.dependencies_for(@hermo_wall_statement.statement_id).length)
92
-
93
- assert_equal(1,@dependency_set_1.dependencies_for(@statement_a.statement_id).length)
94
- assert_equal(@statement_a.statement_id,@dependency_set_1.dependencies_for(@statement_a.statement_id).first)
95
- assert_equal(2,@dependency_set_1.dependencies_for(@statement_b.statement_id).length)
96
-
97
- # Create the statement with dependencies
98
- statement_depenencies = StatementDependencies.new(@chop_wally,@chop_length,@statement_c)
99
-
100
- # Find the needed variables for the statements
101
- assert_equal(1,@chop_length.not_declared_variables.length)
102
-
103
- # First statement doesn't have any dependecies
104
- assert_equal(1,statement_depenencies.dependencies_for(@chop_wally.statement_id).length)
105
-
106
- # The secound statement has one dependency
107
- assert_equal(2,statement_depenencies.dependencies_for(@chop_length.statement_id).length)
108
- assert_equal(@chop_wally.statement_id,statement_depenencies.dependencies_for(@chop_length.statement_id).first)
109
-
110
- # The third statement also only has one dependency
111
- assert_equal(@chop_wally.statement_id,statement_depenencies.dependencies_for(@statement_c.statement_id).first)
112
-
113
- # Add a fourth statement with 2 dependencies 'Wally' then 'Wall'
114
- statement_depenencies.push(@statement_d)
115
- assert_equal(3,statement_depenencies.dependencies_for(@statement_d.statement_id).length)
116
-
117
- # Check that an error is raised when looking for depencies for a variable that doesn't exist
118
- assert_raises(StandardError){statement_depenencies.dependencies_for(@bad_statement.statement_id)}
119
-
120
- end
121
-
122
- def test_find_dependencies_for
123
- assert_equal(0,@dependency_set_1.find_dependencies_for(@statement_a).length)
124
- assert_equal(1,@dependency_set_1.find_dependencies_for(@statement_b).length)
125
-
126
- # Check that dependies are found for modified statements
127
- # var_a = 8
128
- # var_b = []
129
- # var_b.push(9)
130
- # var_b.push(10)
131
- statement_a_1 = Statement.new(Unknown.new,Equal.new,8.to_literal)
132
- statement_a_2 = Statement.new(Unknown.new,Equal.new,[].to_literal)
133
- statement_a_3 = Statement.new(InstanceCallContainer.new(statement_a_2.first.copy,Push.new,9.to_literal))
134
- statement_a_4 = Statement.new(InstanceCallContainer.new(statement_a_3.first.subject.copy,Push.new,10.to_literal))
135
- runtime_a = RuntimeMethod.new(MethodUsage.new)
136
- runtime_a.push(statement_a_1)
137
- runtime_a.push(statement_a_2)
138
- runtime_a.push(statement_a_3)
139
- runtime_a.push(statement_a_4)
140
-
141
- # Realise the method and add each of statements
142
- assert_nothing_raised(){runtime_a.realise2(ParametersContainer.new)}
143
-
144
-
145
- end
146
-
147
- end
@@ -1,41 +0,0 @@
1
- require 'required'
2
- require 'test/unit'
3
-
4
- class TestDeclareNewInstanceStructure < Test::Unit::TestCase
5
-
6
- def setup
7
-
8
- # Create the structure instance that generates the appropriate statement
9
- @statement_generator = DeclareNewInstanceStructure.new(MethodUsageClass.new,RuntimeMethodClass.new)
10
-
11
- end
12
-
13
- def teardown
14
- System.reset
15
- end
16
-
17
- def test_statements
18
-
19
- # Test that "var = MethodUsage.new" can be created
20
- assert_equal(true,@statement_generator.statements().all? {|x| x.kind_of?(Statement)})
21
- assert_equal(true,(@statement_generator.statements().select_all {|x| x.kind_of?(MethodUsageClass) }.length > 0))
22
-
23
- # Test that "var = RuntimeMethod.new(<#method_usage>")
24
- method_usage = MethodUsageVariable.new()
25
- assert_equal(1,@statement_generator.statements([method_usage]).select_all {|x| x.kind_of?(RuntimeMethodClass)}.length)
26
-
27
- # Test that a statement that declares a new fixnum as variable can be created
28
- new_statement_statement_generator = DeclareNewInstanceStructure.new(StatementClass.new)
29
- assert_equal(
30
- 1,
31
- new_statement_statement_generator.statements([5.to_literal]).select_all {|x| x.kind_of?(StatementClass)}.length
32
- )
33
- assert_equal(
34
- 'var_6 = Statement.new(Unknown.new, Equal.new, 5.to_declaration)',
35
- new_statement_statement_generator.statements([5.to_literal]).first.write
36
- )
37
-
38
-
39
- end
40
-
41
- end
@@ -1,41 +0,0 @@
1
- require 'required'
2
- require 'test/unit'
3
-
4
- class TestDeclareVariableAsLiteralStructure < Test::Unit::TestCase
5
-
6
- def setup
7
-
8
- # Create the structure instance that generates the appropriate statement
9
- @statement_generator = DeclareVariableAsLiteralStructure.new
10
-
11
-
12
- end
13
-
14
- def teardown
15
- CodeHandler.reset_global_id
16
- System.reset
17
- RuntimeMethod.reset_global_id
18
- end
19
-
20
- def test_statements
21
-
22
- # Test that "var = 7" can be created
23
- assert_equal(true,@statement_generator.statements([7.to_literal]).all? {|x| x.kind_of?(Statement)})
24
- assert_equal(1,@statement_generator.statements([7.to_literal]).length)
25
- assert_equal('var_2 = 7',@statement_generator.statements([7.to_literal]).first.write())
26
-
27
- # Test that "var = 8", "var = 'Grogg'" and 'var = []'
28
- assert_equal(true,
29
- @statement_generator.statements([
30
- 8.to_literal,'Grogg'.to_literal,[].to_literal
31
- ]).all? {|x| x.kind_of?(Statement)}
32
- )
33
- assert_equal(true,
34
- @statement_generator.statements([
35
- 8.to_literal,'Grogg'.to_literal,[].to_literal
36
- ]).contains? {|x| x.kind_of?(Literal)}
37
- )
38
-
39
- end
40
-
41
- end