cauldron 0.1.0 → 0.1.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.
- data/Gemfile +2 -0
- data/Rakefile +7 -0
- data/VERSION +1 -1
- data/features/cauldron_generates_runtime_method.feature +3 -2
- data/features/step_definitions/cauldron_steps.rb +0 -1
- data/features/support/method_1.example +3 -0
- data/features/support/method_2.example +6 -0
- data/lib/Chain.rb +140 -264
- data/lib/CodeHandler.rb +0 -4
- data/lib/ScopeDependencies.rb +1 -0
- data/lib/Theory.rb +12 -15
- data/lib/UnifiedChain.rb +265 -8
- data/lib/cauldron.rb +1 -1
- data/lib/cauldron/demos.rb +280 -0
- data/lib/cauldron/pot.rb +56 -30
- data/lib/cauldron/sexp2cauldron.rb +109 -126
- data/lib/cauldron/terminal.rb +5 -74
- data/lib/core/ClassMethodCallContainer.rb +14 -0
- data/lib/core/Container.rb +12 -2
- data/lib/core/InstanceCallContainer.rb +30 -4
- data/lib/core/TheoryGenerator.rb +2 -9
- data/lib/core/assignment/Equal.rb +1 -1
- data/lib/core/assignment/Equivalent.rb +1 -1
- data/lib/core/assignment/NotEqual.rb +1 -1
- data/lib/core/call_container/CallContainer.rb +7 -1
- data/lib/core/instance_call/Chop.rb +0 -9
- data/lib/core/instance_call/instance_calls.rb +8 -0
- data/lib/core/instance_call/length_equal.rb +1 -1
- data/lib/core/requirement/Requirement.rb +1 -0
- data/lib/core/runtime_class/class_names.rb +12 -12
- data/lib/core/runtime_method/ActsAsRuntimeMethod.rb +0 -7
- data/lib/core/runtime_method/RuntimeMethod.rb +59 -45
- data/lib/core/statement/ActsAsStatement.rb +1 -1
- data/lib/core/statement/ArrayAccess.rb +28 -2
- data/lib/core/statement/OpenStatement.rb +7 -0
- data/lib/core/statement/Statement.rb +22 -18
- data/lib/core/statement/TheoryStatement.rb +8 -1
- data/lib/core/syntax/Addition.rb +3 -2
- data/lib/core/syntax/If.rb +8 -0
- data/lib/core/syntax/Return.rb +1 -1
- data/lib/core/variable/BaseVariable.rb +0 -2
- data/lib/core/variable/MethodParameter.rb +4 -31
- data/lib/core/variable/Unknown.rb +1 -5
- data/lib/implemented_chain.rb +3 -2
- data/lib/required.rb +0 -1
- data/lib/ruby_code/String.rb +0 -17
- data/lib/theories.rb +25 -1
- data/lib/theory/TheoryAction.rb +35 -5
- data/lib/theory/TheoryChainValidator.rb +10 -8
- data/lib/theory/TheoryComponent.rb +17 -0
- data/lib/theory/TheoryConnector.rb +76 -9
- data/lib/theory/TheoryDependent.rb +2 -2
- data/lib/theory/TheoryImplementation.rb +7 -7
- data/lib/util/ClassEvaluation.rb +2 -7
- data/lib/util/MethodValidation.rb +10 -6
- data/lib/util/Parser.rb +26 -20
- data/lib/util/StringToTheory.rb +27 -3
- data/spec/cauldron/chain_spec.rb +24 -0
- data/spec/cauldron/demos_spec.rb +30 -0
- data/spec/cauldron/pot_spec.rb +66 -0
- data/spec/cauldron/runtime_method_spec.rb +47 -5
- data/spec/cauldron/sexp_2_cauldron_spec.rb +92 -0
- data/spec/cauldron/terminal_spec.rb +1 -1
- data/spec/cauldron/theory_action_spec.rb +20 -0
- data/spec/cauldron/theory_connector_spec.rb +52 -0
- data/spec/cauldron/theory_spec.rb +59 -0
- data/spec/cauldron/unified_chain_spec.rb +102 -0
- data/spec/spec_helper.rb +10 -1
- data/tasks/theory_tasks.rake +274 -0
- data/test/fixtures/implementation_results/0/dump +0 -0
- data/test/fixtures/theories/0/dump +0 -0
- data/test/fixtures/theories/1/dump +0 -0
- data/test/fixtures/theories/10/dump +0 -0
- data/test/fixtures/theories/11/dump +0 -0
- data/test/fixtures/theories/12/dump +0 -0
- data/test/fixtures/theories/13/declaration.txt +1 -1
- data/test/fixtures/theories/13/desc +1 -1
- data/test/fixtures/theories/13/dump +0 -0
- data/test/fixtures/theories/14/dump +0 -0
- data/test/fixtures/theories/15/dump +0 -0
- data/test/fixtures/theories/16/dump +0 -0
- data/test/fixtures/theories/17/dump +0 -0
- data/test/fixtures/theories/18/dump +0 -0
- data/test/fixtures/theories/19/dump +0 -0
- data/test/fixtures/theories/2/dump +0 -0
- data/test/fixtures/theories/20/declaration.txt +1 -1
- data/test/fixtures/theories/20/desc +1 -1
- data/test/fixtures/theories/20/dump +0 -0
- data/test/fixtures/theories/3/dump +0 -0
- data/test/fixtures/theories/4/dump +0 -0
- data/test/fixtures/theories/5/dump +0 -0
- data/test/fixtures/theories/6/dump +0 -0
- data/test/fixtures/theories/7/dump +0 -0
- data/test/fixtures/theories/8/dump +0 -0
- data/test/fixtures/theories/9/dump +0 -0
- data/test/fixtures/theory_implementations/0/declaration.txt +1 -1
- data/test/fixtures/theory_implementations/0/dump +0 -0
- data/test/fixtures/theory_implementations/1/declaration.txt +11 -0
- data/test/fixtures/theory_implementations/1/dump +0 -0
- data/test/fixtures/theory_implementations/2/declaration.txt +11 -0
- data/test/fixtures/theory_implementations/2/dump +0 -0
- data/test/output/simple_method.txt +0 -1
- data/test/tc_contextual_variables.rb +2 -41
- data/test/tc_describe.rb +1 -2
- data/test/tc_method.rb +2 -5
- data/test/unit/core/runtime_method/tc_realised_runtime_method.rb +5 -3
- data/test/unit/core/runtime_method/tc_runtime_method.rb +34 -56
- data/test/unit/core/statement/tc_block_statement.rb +2 -0
- data/test/unit/core/statement/tc_open_statement.rb +15 -6
- data/test/unit/core/statement/tc_statement.rb +4 -5
- data/test/unit/core/statement/tc_statement_dependencies.rb +1 -0
- data/test/unit/core/statement/tc_theory_statement.rb +2 -0
- data/test/unit/core/syntax/tc_if_container.rb +5 -5
- data/test/unit/core/tc_theory_generator_heavy.rb +1 -1
- data/test/unit/core/tracking/tc_history.rb +3 -1
- data/test/unit/core/variable/tc_method_parameter_variable.rb +2 -2
- data/test/unit/tc_chain_with_case_1.rb +1 -1
- data/test/unit/tc_method_usage.rb +1 -1
- data/test/unit/tc_theory.rb +8 -2
- data/test/unit/theory/tc_theory_action.rb +37 -5
- data/test/unit/theory/tc_theory_chain_validator.rb +3 -3
- data/test/unit/theory/tc_theory_connector.rb +2 -37
- data/test/unit/theory/tc_theory_dependent.rb +2 -0
- data/test/unit/theory/tc_theory_implementation.rb +5 -1
- data/test/unit/theory/tc_theory_result.rb +3 -2
- data/test/unit/util/tc_method_validation.rb +4 -1
- data/test/unit/util/tc_parser.rb +2 -0
- data/test/unit/util/tc_string_to_theory.rb +3 -2
- data/tmp/runtime_method_evaluation.rb +7 -4
- metadata +59 -13
- data/lib/core/syntax/IfContainer.rb +0 -100
data/spec/spec_helper.rb
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
require 'cauldron'
|
|
2
2
|
|
|
3
3
|
# TODO I would rather use the module:: Cauldron structure
|
|
4
|
-
require 'required'
|
|
4
|
+
require 'required'
|
|
5
|
+
|
|
6
|
+
def strip_whitespace(ruby_code)
|
|
7
|
+
#res = ruby_code.strip.gsub(/\t{1,}/,'\t').gsub(/\s{2,}/,'\n')
|
|
8
|
+
res = ruby_code.strip.gsub(/\t/,'\t').gsub(/\s{2,}/,'\n')
|
|
9
|
+
return res.gsub('\t',"\t").gsub('\n',"\n")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
include Cauldron::Demos
|
|
13
|
+
include Cauldron::Conversion
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# http://rake.rubyforge.org/
|
|
2
|
+
# http://rake.rubyforge.org/files/doc/rakefile_rdoc.html
|
|
3
|
+
|
|
4
|
+
# TODO Need a test for the rake tasks as well
|
|
5
|
+
|
|
6
|
+
namespace :cauldren do
|
|
7
|
+
|
|
8
|
+
namespace :implementations do
|
|
9
|
+
|
|
10
|
+
desc "Re-build the theory implementations"
|
|
11
|
+
task :rebuild do
|
|
12
|
+
|
|
13
|
+
file_list = FileList.new('test/fixtures/theory_implementations/*')
|
|
14
|
+
file_list.each do |x|
|
|
15
|
+
implementation_id = x.match(/\d+$/)[0].to_i
|
|
16
|
+
|
|
17
|
+
directory_path = $LOC+File.join('test','fixtures','theories',theory_id.to_s)
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# TODO The current approach to saving the implementations - I'd like to be able
|
|
22
|
+
# to right the declarations to file.
|
|
23
|
+
|
|
24
|
+
puts 'Does not do anything'
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
desc 'Creates a new theory implementation'
|
|
29
|
+
task :create do
|
|
30
|
+
implementation_id = 0
|
|
31
|
+
|
|
32
|
+
StandardLogger.instance.warning("Caution: Creating new theory implementation #{implementation_id}")
|
|
33
|
+
directory_path = $LOC+File.join('test','fixtures','theory_implementations',implementation_id.to_s)
|
|
34
|
+
if(File.exists?(directory_path))
|
|
35
|
+
StandardLogger.instance.warning("Theory Implementation ficture already exists #{implementation_id} -cancelling")
|
|
36
|
+
exit
|
|
37
|
+
else
|
|
38
|
+
FileUtils.mkdir_p(directory_path)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# This is just updated here - nothing fancy
|
|
42
|
+
declaration = %q!
|
|
43
|
+
theory = Theory.load_theory(1)
|
|
44
|
+
potential_values = [
|
|
45
|
+
Parser.run('0'),
|
|
46
|
+
Parser.run('test_cases'),
|
|
47
|
+
Parser.run('runtime_method')
|
|
48
|
+
]
|
|
49
|
+
results = theory.rewrite_permutations(potential_values)
|
|
50
|
+
# NOTE: Rember use grep -A and -B to match particular cases
|
|
51
|
+
results[5]
|
|
52
|
+
!
|
|
53
|
+
theory_implementation = eval declaration
|
|
54
|
+
|
|
55
|
+
# Save the declaration (incase the theory needs modified
|
|
56
|
+
declaration_file = File.open(File.join(directory_path,'declaration.txt'),'w+')
|
|
57
|
+
declaration_file << declaration
|
|
58
|
+
declaration_file.close
|
|
59
|
+
|
|
60
|
+
dump_file = File.open(File.join(directory_path,'dump'),'w')
|
|
61
|
+
data = Marshal.dump(theory_implementation)
|
|
62
|
+
dump_file << data
|
|
63
|
+
dump_file.close
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
namespace :results do
|
|
68
|
+
|
|
69
|
+
desc "Creates a new theory result implementation with the supplied id"
|
|
70
|
+
task :create, :arg1 do |t,args|
|
|
71
|
+
|
|
72
|
+
# Create the directory to save the implementation result
|
|
73
|
+
directory_path = File.join('test','fixtures','implementation_results',args[:arg1])
|
|
74
|
+
if(File.exists?(directory_path))
|
|
75
|
+
StandardLogger.instance.warning("Implementation Result already exists #{args[:arg1]} -cancelling")
|
|
76
|
+
return
|
|
77
|
+
else
|
|
78
|
+
FileUtils.mkdir_p(directory_path)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
declaration =
|
|
82
|
+
%q!
|
|
83
|
+
TheoryResult.new(Parser.run("if(runtime_method.all_pass?(test_cases))\nreturn true\nend"))
|
|
84
|
+
!
|
|
85
|
+
|
|
86
|
+
# Save the declaration (incase it needs rebuilt)
|
|
87
|
+
declaration_file = File.open(File.join(directory_path,'declaration.txt'),'w+')
|
|
88
|
+
declaration_file << declaration
|
|
89
|
+
declaration_file.close
|
|
90
|
+
|
|
91
|
+
result = eval declaration
|
|
92
|
+
data = Marshal.dump(result)
|
|
93
|
+
|
|
94
|
+
dump_file = File.open(File.join(directory_path,'dump'),'w+')
|
|
95
|
+
dump_file << data
|
|
96
|
+
dump_file.close
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
namespace :chain do
|
|
105
|
+
|
|
106
|
+
desc "Create a new initial chain"
|
|
107
|
+
task :create, :chain_id do |task,args|
|
|
108
|
+
|
|
109
|
+
# Create the directory to save the initial chains into
|
|
110
|
+
directory_path = $LOC+File.join('test','fixtures','chains',args[:chain_id])
|
|
111
|
+
if(File.exists?(directory_path))
|
|
112
|
+
StandardLogger.instance.warning("A chain with the id #{args[:chain_id]} already exists")
|
|
113
|
+
return
|
|
114
|
+
else
|
|
115
|
+
FileUtils.mkdir_p(directory_path)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Create the declaration that creates the chain
|
|
119
|
+
declaration =
|
|
120
|
+
%q!
|
|
121
|
+
runtime_method = RuntimeMethod.new(MethodUsage.new(MethodParameter.new))
|
|
122
|
+
sparky = CTestCase.new
|
|
123
|
+
sparky[:params] = ['sparky']
|
|
124
|
+
sparky[:output] = 6
|
|
125
|
+
kel = CTestCase.new
|
|
126
|
+
kel[:params] = ['kel']
|
|
127
|
+
kel[:output] = 3
|
|
128
|
+
test_cases = [
|
|
129
|
+
sparky,kel
|
|
130
|
+
]
|
|
131
|
+
finish = Parser.run("if(runtime_method.all_pass?(test_cases))\nreturn true\nend")
|
|
132
|
+
|
|
133
|
+
# Generate the head theory - this is the starting point and doesn't have any dependents
|
|
134
|
+
accessors, mapping = TheoryGenerator.new.generate_accessors_and_mapping(test_cases,runtime_method,7,0)
|
|
135
|
+
|
|
136
|
+
# * Generate all the possible results of this runtime method
|
|
137
|
+
theory_results = TheoryGenerator.new.get_theory_results(accessors)
|
|
138
|
+
|
|
139
|
+
# * Create the actual head theory
|
|
140
|
+
head_theory = Theory.new([],nil,theory_results,runtime_method.copy)
|
|
141
|
+
|
|
142
|
+
intial_chain = Chain.new
|
|
143
|
+
intial_chain.form_chain(head_theory,finish,mapping)
|
|
144
|
+
intial_chain
|
|
145
|
+
!
|
|
146
|
+
|
|
147
|
+
# Save the declaration (incase it needs rebuilt)
|
|
148
|
+
declaration_file = File.open(File.join(directory_path,'declaration.txt'),'w+')
|
|
149
|
+
declaration_file << declaration
|
|
150
|
+
declaration_file.close
|
|
151
|
+
|
|
152
|
+
result = eval declaration
|
|
153
|
+
data = Marshal.dump(result)
|
|
154
|
+
|
|
155
|
+
dump_file = File.open(File.join(directory_path,'dump'),'w+')
|
|
156
|
+
dump_file << data
|
|
157
|
+
dump_file.close
|
|
158
|
+
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
desc "Load the specified chain"
|
|
162
|
+
task :load_chain, :chain_id do |task,args|
|
|
163
|
+
|
|
164
|
+
# http://stackoverflow.com/questions/825748/how-do-i-pass-command-line-arguments-to-a-rake-task
|
|
165
|
+
directory_path = $LOC+File.join('test','fixtures','chains',args[:chain_id].to_s)
|
|
166
|
+
raise StandardError.new("chain #{args[:chain_id].to_s} does not exist") unless(File.exists?(directory_path))
|
|
167
|
+
dump_file = File.open(File.join(directory_path,'dump'),'r')
|
|
168
|
+
|
|
169
|
+
return Marshal.load(dump_file)
|
|
170
|
+
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
namespace :theories do
|
|
176
|
+
|
|
177
|
+
desc "Create a new theory"
|
|
178
|
+
task :create do
|
|
179
|
+
|
|
180
|
+
theory_id = "20"
|
|
181
|
+
|
|
182
|
+
StandardLogger.instance.info("NOTE: Creating new theory fixture #{theory_id.to_s}")
|
|
183
|
+
# Does a directory for this theory fixture already exist.
|
|
184
|
+
directory_path = $LOC+File.join('test','fixtures','theories',theory_id.to_s)
|
|
185
|
+
if(File.exists?(directory_path))
|
|
186
|
+
StandardLogger.instance.warning("Theory ficture already exists #{theory_id.to_s} -cancelling")
|
|
187
|
+
exit
|
|
188
|
+
else
|
|
189
|
+
|
|
190
|
+
# Create the directory
|
|
191
|
+
FileUtils.mkdir_p(directory_path)
|
|
192
|
+
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# This is just updated here - nothing fancy
|
|
196
|
+
declaration = %q!
|
|
197
|
+
dependent_one = TheoryDependent.new(StringToTheory.run("if(var2[var3].kind_of?(CTestCase))\nreturn true\nend"))
|
|
198
|
+
dependent_two = TheoryDependent.new(
|
|
199
|
+
StringToTheory.run("if((var2[var3][:params][var6] == var2[var4][:params][var6])==false)\nreturn true\nend")
|
|
200
|
+
)
|
|
201
|
+
action = TheoryAction.new(
|
|
202
|
+
TheoryStatement.new(StringToTheory.run(
|
|
203
|
+
'OpenStatement.new(Statement.new(If.new,Container.new(var1.params[var6],Equivalent.new,var2[var3][:params][var6])))'
|
|
204
|
+
)),
|
|
205
|
+
StringToTheory.run('var1.statement_id')
|
|
206
|
+
)
|
|
207
|
+
result_one = TheoryResult.new(StringToTheory.run(
|
|
208
|
+
"if(var5.history2(var2[var3][:params]).any? { |x| x['statement_id'] == var1.last.statement_id })\nreturn true\nend"
|
|
209
|
+
))
|
|
210
|
+
result_two = TheoryResult.new(StringToTheory.run(
|
|
211
|
+
"if((var5.history2(var2[var4][:params]).any? { |x| x['statement_id'] == var1.last.statement_id })==false)\nreturn true\nend"
|
|
212
|
+
))
|
|
213
|
+
Theory.new(
|
|
214
|
+
[dependent_one,dependent_two],
|
|
215
|
+
action,
|
|
216
|
+
[result_one,result_two]
|
|
217
|
+
)
|
|
218
|
+
!
|
|
219
|
+
|
|
220
|
+
# Save the declaration (incase the theory needs modified
|
|
221
|
+
declaration_file = File.open(File.join(directory_path,'declaration.txt'),'w+')
|
|
222
|
+
declaration_file << declaration
|
|
223
|
+
declaration_file.close
|
|
224
|
+
|
|
225
|
+
theory = eval declaration
|
|
226
|
+
data = Marshal.dump(theory)
|
|
227
|
+
|
|
228
|
+
# TODO Shouldn't include colours for this description
|
|
229
|
+
desc_file = File.open(File.join(directory_path,'desc'),'w+')
|
|
230
|
+
desc_file << theory.describe
|
|
231
|
+
desc_file.close
|
|
232
|
+
|
|
233
|
+
dump_file = File.open(File.join(directory_path,'dump'),'w+')
|
|
234
|
+
dump_file << data
|
|
235
|
+
dump_file.close
|
|
236
|
+
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
desc "Re create the current theories and update their Marshal dump"
|
|
240
|
+
task :rebuild do
|
|
241
|
+
|
|
242
|
+
file_list = FileList.new('test/fixtures/theories/*')
|
|
243
|
+
file_list.each do |x|
|
|
244
|
+
theory_id = x.match(/\d+$/)[0].to_i
|
|
245
|
+
puts '* theory_id: '+theory_id.to_s
|
|
246
|
+
puts File.join('test','fixtures','theories',theory_id.to_s)
|
|
247
|
+
directory_path = File.join('test','fixtures','theories',theory_id.to_s)
|
|
248
|
+
puts directory_path
|
|
249
|
+
declaration = File.open(File.join(directory_path,'declaration.txt'),'r').read
|
|
250
|
+
|
|
251
|
+
# Save the declaration (incase the theory needs modified
|
|
252
|
+
declaration_file = File.open(File.join(directory_path,'declaration.txt'),'w+')
|
|
253
|
+
declaration_file << declaration
|
|
254
|
+
declaration_file.close
|
|
255
|
+
|
|
256
|
+
theory = eval declaration
|
|
257
|
+
data = Marshal.dump(theory)
|
|
258
|
+
|
|
259
|
+
# TODO Shouldn't include colours for this description
|
|
260
|
+
desc_file = File.open(File.join(directory_path,'desc'),'w+')
|
|
261
|
+
desc_file << theory.describe
|
|
262
|
+
desc_file.close
|
|
263
|
+
|
|
264
|
+
dump_file = File.open(File.join(directory_path,'dump'),'w+')
|
|
265
|
+
dump_file << data
|
|
266
|
+
dump_file.close
|
|
267
|
+
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
)
|
|
7
7
|
action = TheoryAction.new(
|
|
8
8
|
TheoryStatement.new(StringToTheory.run(
|
|
9
|
-
'OpenStatement.new(
|
|
9
|
+
'OpenStatement.new(Statement.new(If.new,Container.new(var1.params[var6],Equivalent.new,var2[var3][:params][var6])))'
|
|
10
10
|
)),
|
|
11
11
|
StringToTheory.run('var1.statement_id')
|
|
12
12
|
)
|
|
@@ -10,7 +10,7 @@ if:
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
action:
|
|
13
|
-
<runtime_method>.add_statement_at(OpenStatement.new(
|
|
13
|
+
<runtime_method>.add_statement_at(OpenStatement.new(Statement.new(If.new, Container.new([32mvar1[m.params[[36mvar6[m], Equivalent.new, [33mvar2[m[[34mvar3[m][:params][[36mvar6[m]))),[32mvar1[m.statement_id)
|
|
14
14
|
result:
|
|
15
15
|
if([36mvar5[m.history2([33mvar2[m[[34mvar3[m][:params]).any?{ |x| x['statement_id'] == [32mvar1[m.last.statement_id} )
|
|
16
16
|
return true
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
)
|
|
6
6
|
action = TheoryAction.new(
|
|
7
7
|
TheoryStatement.new(StringToTheory.run(
|
|
8
|
-
'OpenStatement.new(
|
|
8
|
+
'OpenStatement.new(Statement.new(If.new,Container.new(var1.params[var6],Equivalent.new,var2[var3][:params][var6])))'
|
|
9
9
|
)),
|
|
10
10
|
StringToTheory.run('var1.statement_id')
|
|
11
11
|
)
|
|
@@ -7,7 +7,7 @@ if:
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
action:
|
|
10
|
-
<runtime_method>.add_statement_at(OpenStatement.new(
|
|
10
|
+
<runtime_method>.add_statement_at(OpenStatement.new(Statement.new(If.new, Container.new([32mvar1[m.params[[36mvar6[m], Equivalent.new, [33mvar2[m[[34mvar3[m][:params][[36mvar6[m]))),[32mvar1[m.statement_id)
|
|
11
11
|
result:
|
|
12
12
|
if([36mvar5[m.history2([33mvar2[m[[34mvar3[m][:params]).any?{ |x| x['statement_id'] == [32mvar1[m.last.statement_id} )
|
|
13
13
|
return true
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
theory = Theory.load_theory(8)
|
|
3
|
+
potential_values = [
|
|
4
|
+
Parser.run('0'),
|
|
5
|
+
Parser.run('test_cases'),
|
|
6
|
+
Parser.run('runtime_method')
|
|
7
|
+
]
|
|
8
|
+
results = theory.rewrite_permutations(potential_values)
|
|
9
|
+
# NOTE: Rember use grep -A and -B to match particular cases
|
|
10
|
+
results[0]
|
|
11
|
+
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
theory = Theory.load_theory(1)
|
|
3
|
+
potential_values = [
|
|
4
|
+
Parser.run('0'),
|
|
5
|
+
Parser.run('test_cases'),
|
|
6
|
+
Parser.run('runtime_method')
|
|
7
|
+
]
|
|
8
|
+
results = theory.rewrite_permutations(potential_values)
|
|
9
|
+
# NOTE: Rember use grep -A and -B to match particular cases
|
|
10
|
+
results[4]
|
|
11
|
+
|
|
Binary file
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
# the context they are accessed.
|
|
3
3
|
#
|
|
4
4
|
|
|
5
|
+
# TODO This can go!
|
|
6
|
+
|
|
5
7
|
require 'required'
|
|
6
8
|
require 'test/unit'
|
|
7
9
|
|
|
@@ -16,47 +18,6 @@ class TestContextualVariable < Test::Unit::TestCase
|
|
|
16
18
|
RuntimeMethod.reset_global_id
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
# This test checks that variables taken on the appropriate requirements
|
|
20
|
-
# based on their position within a statement and then method.
|
|
21
|
-
#
|
|
22
|
-
# def method_1(param_1)
|
|
23
|
-
# var1 = param1.chop
|
|
24
|
-
# var2 = var1.length
|
|
25
|
-
# end
|
|
26
|
-
#
|
|
27
|
-
# where param_1 = 'test'
|
|
28
|
-
#
|
|
29
|
-
def test_method_describtion
|
|
30
|
-
|
|
31
|
-
# Create the var1 - this should haven't any requirements individually
|
|
32
|
-
var1 = Unknown.new()
|
|
33
|
-
assert_equal(0,var1.length)
|
|
34
|
-
|
|
35
|
-
# Create the first statement with var1 in it e.g. var2 = var1.chop
|
|
36
|
-
chop_call = InstanceCallContainer.new(Unknown.new,Chop.new)
|
|
37
|
-
first_statement = DeclarationStatement.new(var1,Equal.new,chop_call)
|
|
38
|
-
|
|
39
|
-
# Check that the variables inside the first statement don't have any requirements
|
|
40
|
-
assert_equal(0,first_statement[0].length)
|
|
41
|
-
assert_equal(0,first_statement[2].subject.length)
|
|
42
|
-
|
|
43
|
-
# Check that the instance call includes a requirement
|
|
44
|
-
assert_equal(1,chop_call.find_variable(chop_call.variable_id).length)
|
|
45
|
-
|
|
46
|
-
# Check that they have the correct requirements in the context of the statement
|
|
47
|
-
# TODO I think the whole Unknown class is redundent
|
|
48
|
-
assert_equal(2,first_statement.find_variable(chop_call.subject.variable_id).length)
|
|
49
|
-
|
|
50
|
-
# Confirm the length of the variable hasn't changed
|
|
51
|
-
assert_equal(0,var1.length)
|
|
52
|
-
|
|
53
|
-
# Create the second scope variable
|
|
54
|
-
var2 = Unknown.new()
|
|
55
|
-
assert_equal(0,var2.length)
|
|
56
|
-
assert_not_equal(var1.variable_id,var2.variable_id)
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
-
|
|
60
21
|
# This test checks the the declared variable in the following statement
|
|
61
22
|
#
|
|
62
23
|
# varA = varB-varC
|