cauldron 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/Gemfile +2 -0
  2. data/Rakefile +7 -0
  3. data/VERSION +1 -1
  4. data/features/cauldron_generates_runtime_method.feature +3 -2
  5. data/features/step_definitions/cauldron_steps.rb +0 -1
  6. data/features/support/method_1.example +3 -0
  7. data/features/support/method_2.example +6 -0
  8. data/lib/Chain.rb +140 -264
  9. data/lib/CodeHandler.rb +0 -4
  10. data/lib/ScopeDependencies.rb +1 -0
  11. data/lib/Theory.rb +12 -15
  12. data/lib/UnifiedChain.rb +265 -8
  13. data/lib/cauldron.rb +1 -1
  14. data/lib/cauldron/demos.rb +280 -0
  15. data/lib/cauldron/pot.rb +56 -30
  16. data/lib/cauldron/sexp2cauldron.rb +109 -126
  17. data/lib/cauldron/terminal.rb +5 -74
  18. data/lib/core/ClassMethodCallContainer.rb +14 -0
  19. data/lib/core/Container.rb +12 -2
  20. data/lib/core/InstanceCallContainer.rb +30 -4
  21. data/lib/core/TheoryGenerator.rb +2 -9
  22. data/lib/core/assignment/Equal.rb +1 -1
  23. data/lib/core/assignment/Equivalent.rb +1 -1
  24. data/lib/core/assignment/NotEqual.rb +1 -1
  25. data/lib/core/call_container/CallContainer.rb +7 -1
  26. data/lib/core/instance_call/Chop.rb +0 -9
  27. data/lib/core/instance_call/instance_calls.rb +8 -0
  28. data/lib/core/instance_call/length_equal.rb +1 -1
  29. data/lib/core/requirement/Requirement.rb +1 -0
  30. data/lib/core/runtime_class/class_names.rb +12 -12
  31. data/lib/core/runtime_method/ActsAsRuntimeMethod.rb +0 -7
  32. data/lib/core/runtime_method/RuntimeMethod.rb +59 -45
  33. data/lib/core/statement/ActsAsStatement.rb +1 -1
  34. data/lib/core/statement/ArrayAccess.rb +28 -2
  35. data/lib/core/statement/OpenStatement.rb +7 -0
  36. data/lib/core/statement/Statement.rb +22 -18
  37. data/lib/core/statement/TheoryStatement.rb +8 -1
  38. data/lib/core/syntax/Addition.rb +3 -2
  39. data/lib/core/syntax/If.rb +8 -0
  40. data/lib/core/syntax/Return.rb +1 -1
  41. data/lib/core/variable/BaseVariable.rb +0 -2
  42. data/lib/core/variable/MethodParameter.rb +4 -31
  43. data/lib/core/variable/Unknown.rb +1 -5
  44. data/lib/implemented_chain.rb +3 -2
  45. data/lib/required.rb +0 -1
  46. data/lib/ruby_code/String.rb +0 -17
  47. data/lib/theories.rb +25 -1
  48. data/lib/theory/TheoryAction.rb +35 -5
  49. data/lib/theory/TheoryChainValidator.rb +10 -8
  50. data/lib/theory/TheoryComponent.rb +17 -0
  51. data/lib/theory/TheoryConnector.rb +76 -9
  52. data/lib/theory/TheoryDependent.rb +2 -2
  53. data/lib/theory/TheoryImplementation.rb +7 -7
  54. data/lib/util/ClassEvaluation.rb +2 -7
  55. data/lib/util/MethodValidation.rb +10 -6
  56. data/lib/util/Parser.rb +26 -20
  57. data/lib/util/StringToTheory.rb +27 -3
  58. data/spec/cauldron/chain_spec.rb +24 -0
  59. data/spec/cauldron/demos_spec.rb +30 -0
  60. data/spec/cauldron/pot_spec.rb +66 -0
  61. data/spec/cauldron/runtime_method_spec.rb +47 -5
  62. data/spec/cauldron/sexp_2_cauldron_spec.rb +92 -0
  63. data/spec/cauldron/terminal_spec.rb +1 -1
  64. data/spec/cauldron/theory_action_spec.rb +20 -0
  65. data/spec/cauldron/theory_connector_spec.rb +52 -0
  66. data/spec/cauldron/theory_spec.rb +59 -0
  67. data/spec/cauldron/unified_chain_spec.rb +102 -0
  68. data/spec/spec_helper.rb +10 -1
  69. data/tasks/theory_tasks.rake +274 -0
  70. data/test/fixtures/implementation_results/0/dump +0 -0
  71. data/test/fixtures/theories/0/dump +0 -0
  72. data/test/fixtures/theories/1/dump +0 -0
  73. data/test/fixtures/theories/10/dump +0 -0
  74. data/test/fixtures/theories/11/dump +0 -0
  75. data/test/fixtures/theories/12/dump +0 -0
  76. data/test/fixtures/theories/13/declaration.txt +1 -1
  77. data/test/fixtures/theories/13/desc +1 -1
  78. data/test/fixtures/theories/13/dump +0 -0
  79. data/test/fixtures/theories/14/dump +0 -0
  80. data/test/fixtures/theories/15/dump +0 -0
  81. data/test/fixtures/theories/16/dump +0 -0
  82. data/test/fixtures/theories/17/dump +0 -0
  83. data/test/fixtures/theories/18/dump +0 -0
  84. data/test/fixtures/theories/19/dump +0 -0
  85. data/test/fixtures/theories/2/dump +0 -0
  86. data/test/fixtures/theories/20/declaration.txt +1 -1
  87. data/test/fixtures/theories/20/desc +1 -1
  88. data/test/fixtures/theories/20/dump +0 -0
  89. data/test/fixtures/theories/3/dump +0 -0
  90. data/test/fixtures/theories/4/dump +0 -0
  91. data/test/fixtures/theories/5/dump +0 -0
  92. data/test/fixtures/theories/6/dump +0 -0
  93. data/test/fixtures/theories/7/dump +0 -0
  94. data/test/fixtures/theories/8/dump +0 -0
  95. data/test/fixtures/theories/9/dump +0 -0
  96. data/test/fixtures/theory_implementations/0/declaration.txt +1 -1
  97. data/test/fixtures/theory_implementations/0/dump +0 -0
  98. data/test/fixtures/theory_implementations/1/declaration.txt +11 -0
  99. data/test/fixtures/theory_implementations/1/dump +0 -0
  100. data/test/fixtures/theory_implementations/2/declaration.txt +11 -0
  101. data/test/fixtures/theory_implementations/2/dump +0 -0
  102. data/test/output/simple_method.txt +0 -1
  103. data/test/tc_contextual_variables.rb +2 -41
  104. data/test/tc_describe.rb +1 -2
  105. data/test/tc_method.rb +2 -5
  106. data/test/unit/core/runtime_method/tc_realised_runtime_method.rb +5 -3
  107. data/test/unit/core/runtime_method/tc_runtime_method.rb +34 -56
  108. data/test/unit/core/statement/tc_block_statement.rb +2 -0
  109. data/test/unit/core/statement/tc_open_statement.rb +15 -6
  110. data/test/unit/core/statement/tc_statement.rb +4 -5
  111. data/test/unit/core/statement/tc_statement_dependencies.rb +1 -0
  112. data/test/unit/core/statement/tc_theory_statement.rb +2 -0
  113. data/test/unit/core/syntax/tc_if_container.rb +5 -5
  114. data/test/unit/core/tc_theory_generator_heavy.rb +1 -1
  115. data/test/unit/core/tracking/tc_history.rb +3 -1
  116. data/test/unit/core/variable/tc_method_parameter_variable.rb +2 -2
  117. data/test/unit/tc_chain_with_case_1.rb +1 -1
  118. data/test/unit/tc_method_usage.rb +1 -1
  119. data/test/unit/tc_theory.rb +8 -2
  120. data/test/unit/theory/tc_theory_action.rb +37 -5
  121. data/test/unit/theory/tc_theory_chain_validator.rb +3 -3
  122. data/test/unit/theory/tc_theory_connector.rb +2 -37
  123. data/test/unit/theory/tc_theory_dependent.rb +2 -0
  124. data/test/unit/theory/tc_theory_implementation.rb +5 -1
  125. data/test/unit/theory/tc_theory_result.rb +3 -2
  126. data/test/unit/util/tc_method_validation.rb +4 -1
  127. data/test/unit/util/tc_parser.rb +2 -0
  128. data/test/unit/util/tc_string_to_theory.rb +3 -2
  129. data/tmp/runtime_method_evaluation.rb +7 -4
  130. metadata +59 -13
  131. data/lib/core/syntax/IfContainer.rb +0 -100
@@ -6,60 +6,86 @@ module Cauldron
6
6
  VERSION = '0-01'
7
7
 
8
8
  def initialize()
9
-
9
+ #StandardLogger.instance.level = Logger::FATAL
10
10
  end
11
11
 
12
12
  def brew(test_cases)
13
13
 
14
- # * Load each of the theories from the directory
15
- saved_theory_file_paths = Dir.glob(File.join(theory_repository_path,'*','dump'))
16
- theories = saved_theory_file_paths.collect {|x| Marshal.load(File.open(x,'r'))}
14
+ chains = complete_chains(test_cases)
15
+ if chains.empty?
16
+ raise StandardError.new('Failed to generate a chain for this problem')
17
+ end
18
+
19
+ # => TODO This probably shouldn't be needed
20
+ written_chains = chains.collect {|x| x.write}
21
+ unique_written_chains = written_chains.uniq
22
+ unique_chains = []
23
+ chains.each do |x|
24
+ unless unique_chains.any? {|y| y.write == x.write}
25
+ unique_chains << x
26
+ end
27
+ end
28
+ chains = unique_chains
29
+
30
+ runtime_method = RuntimeMethod.new(MethodUsage.new(MethodParameter.new))
31
+ chains.each do |chain|
32
+
33
+ unified_chain = chain.unify_chain
34
+ implementation_permutations = unified_chain.implementation_permuatations(runtime_method.copy,test_cases.copy,Mapping.new)
35
+
36
+ # Go through each of the permutations and create the runtime method for the chain
37
+ validator = TheoryChainValidator.new
38
+ begin
39
+ result = validator.build(runtime_method.copy,test_cases.copy,implementation_permutations)
40
+ rescue StandardError => e
41
+ StandardLogger.instance.warning e
42
+ next
43
+ end
44
+ return result
45
+ end
46
+ return nil
47
+
48
+ end
49
+
50
+ def complete_chains(test_cases)
51
+
52
+ theories = saved_theories
17
53
 
18
- # Prepare the theory chain connector
19
54
  runtime_method = RuntimeMethod.new(MethodUsage.new(MethodParameter.new))
20
55
  tc = Parser.run('test_cases')
21
56
  tc_index_0 = IntrinsicLiteral.new(0)
22
57
  tc_index_1 = IntrinsicLiteral.new(1)
23
58
  param_0 = IntrinsicLiteral.new(0)
24
- real_method = Parser.run('runtime_method')
25
-
26
- # TODO Still need to include last_real_method
27
- last_real_method = Parser.run('last_runtime_method')
59
+ real_method = Parser.run('runtime_method')
28
60
 
29
61
  # Create the thoery connector and the values available
30
62
  # TODO These values should actually be retreived progressively
31
- potential_values = MappingValues.new([tc,tc_index_0,tc_index_1,param_0,real_method])
63
+ potential_values = MappingValues.new([tc,tc_index_0,tc_index_1,param_0,real_method])
32
64
  connector = TheoryConnector.new(potential_values)
33
65
 
34
66
  # Attempt to generate a complete chain for the solution
35
- chains = connector.generate_chains(runtime_method,test_cases,theories)
36
- if chains.empty?
37
- raise StandardError.new('Failed to generate a chain for this problem')
38
- end
39
-
40
- # Now validate each of the chains to check they work
41
- # chains.each do |chain|
42
- # chain_permutations = chain.unify_chain.implementation_permuatations(runtime_method,test_cases,Mapping.new)
43
- # end
44
- # TEMP just concentrate of one implementation_permutation
45
- implementation_permutations = chains.first.unify_chain.implementation_permuatations(runtime_method,test_cases,Mapping.new)
46
-
47
- # Go through each of the permutations and create the runtime method for the chain
48
- validator = TheoryChainValidator.new
49
- result = validator.build(runtime_method,test_cases,implementation_permutations)
50
- return result
51
-
67
+ chains = connector.generate_chains(runtime_method,test_cases,theories)
68
+ return chains
69
+ end
70
+
71
+ def saved_theories
72
+ saved_theory_file_paths = Dir.glob(File.join(theory_repository_path,'*','dump'))
73
+ saved_theory_file_paths.collect {|x| Marshal.load(File.open(x,'r'))}
52
74
  end
53
75
 
54
76
  def simmer(demo)
55
77
  raise StandardError.new('This demo does not work') unless demo_works?(demo)
56
78
 
57
79
  # Generate a master theory for each stage of the runtime method when following the theory chains
58
- generator = TheoryGenerator.new
59
- master_theories = generator.master_theories(demo[:chain],demo[:initial_method],demo[:test_cases])
80
+ # generator = TheoryGenerator.new
81
+ # master_theories = generator.master_theories(
82
+ # demo[:chain],
83
+ # demo[:initial_method],
84
+ # demo[:test_cases]
85
+ # )
60
86
 
61
87
  # Add each of the theories in the chain to cauldron
62
- master_theories.each {|x| save_theory(x,master_repository_path)}
88
+ #master_theories.each {|x| save_theory(x,master_repository_path)}
63
89
 
64
90
  # Save each of the simple versions of the theory
65
91
  demo[:chain].each {|x| save_theory(x,theory_repository_path)}
@@ -1,155 +1,138 @@
1
1
  require 'rubygems'
2
+ require 'ruby2ruby'
2
3
  require 'sexp_processor'
3
4
 
4
5
  module Cauldron
5
6
 
6
7
  class Sexp2Cauldron < SexpProcessor
7
8
 
9
+ VARIABLE_EXPRESSION = /var[|_]*(\d+)/
10
+
8
11
  def initialize
9
12
  super
10
- self.strict = false
11
13
  self.expected = Object
14
+ self.auto_shift_type = true
15
+ self.strict = true
12
16
  @debug[:lasgn] = nil
13
17
  @unsupported_checked = true
14
18
  end
15
19
 
16
20
  def process_lit(exp)
17
- type = exp.shift
18
21
  val = exp.shift
19
22
  return Literal.new(val)
20
23
  end
21
24
 
22
- # def in_context type, &block
23
- # # puts '-------------------------- in_context'
24
- # # warn 'kadsjflkasj kldasfj lasdkfj ldksaf'
25
- # # puts type
26
- # # puts block_given?
27
- # # pp self.context
28
- # # puts @debug.has_key?(type)
29
- # # pp &block
30
- # # puts '--------------------999999999999999'
31
- # self.context.unshift type
32
- #
33
- # yield
34
- #
35
- # self.context.shift
36
- # end
37
-
38
- # def process(exp)
39
- # puts '--------------------------------calling process===================>'
40
- # return nil if exp.nil?
41
- # exp = self.rewrite(exp) if self.context.empty?
42
- # puts '-------------------@unsupported_checked--------->>>>>>>>>>>.'
43
- # puts @unsupported_checked
44
- # puts '-------------------@unsupported_checked--------->>>>>>>>>>>.'
45
- # unless @unsupported_checked then
46
- # m = public_methods.grep(/^process_/) { |o| o.to_s.sub(/^process_/, '').to_sym }
47
- # supported = m - (m - @unsupported)
48
- #
49
- # raise UnsupportedNodeError, "#{supported.inspect} shouldn't be in @unsupported" unless supported.empty?
50
- #
51
- # @unsupported_checked = true
52
- # end
53
- #
54
- # result = self.expected.new
55
- #
56
- # type = exp.first
57
- # raise "type should be a Symbol, not: #{exp.first.inspect}" unless
58
- # Symbol === type
59
- #
60
- # in_context type do
61
- #
62
- # puts '==============================IN COTEXT('+exp.to_s+') ====================== '
63
- #
64
- # if @debug.has_key? type then
65
- # str = exp.inspect
66
- # puts "// DEBUG: #{str}" if str =~ @debug[type]
67
- # end
68
- #
69
- # exp_orig = nil
70
- # exp_orig = exp.deep_clone if $DEBUG or
71
- # @debug.has_key? type or @exceptions.has_key?(type)
72
- #
73
- # raise UnsupportedNodeError, "'#{type}' is not a supported node type" if
74
- # @unsupported.include? type
75
- #
76
- # if @debug.has_key? type then
77
- # str = exp.inspect
78
- # puts "// DEBUG (rewritten): #{str}" if str =~ @debug[type]
79
- # end
80
- #
81
- # # now do a pass with the real processor (or generic)
82
- # meth = @processors[type] || @default_method
83
- # if meth then
84
- #
85
- # if @warn_on_default and meth == @default_method then
86
- # warn "WARNING: Using default method #{meth} for #{type}"
87
- # end
88
- #
89
- # exp.shift if @auto_shift_type and meth != @default_method
90
- #
91
- # puts 'Calling method ----------'+meth.to_s
92
- # result = error_handler(type, exp_orig) do
93
- # self.send(meth, exp)
94
- # end
95
- #
96
- # raise SexpTypeError, "Result must be a #{@expected}, was #{result.class}:#{result.inspect}" unless @expected === result
97
- #
98
- # self.assert_empty(meth, exp, exp_orig) if @require_empty
99
- # else
100
- # unless @strict then
101
- # until exp.empty? do
102
- # sub_exp = exp.shift
103
- # sub_result = nil
104
- # if Array === sub_exp then
105
- # sub_result = error_handler(type, exp_orig) do
106
- # process(sub_exp)
107
- # end
108
- # raise "Result is a bad type" unless Array === sub_exp
109
- # raise "Result does not have a type in front: #{sub_exp.inspect}" unless Symbol === sub_exp.first unless sub_exp.empty?
110
- # else
111
- # sub_result = sub_exp
112
- # end
113
- # result << sub_result
114
- # end
115
- #
116
- # # NOTE: this is costly, but we are in the generic processor
117
- # # so we shouldn't hit it too much with RubyToC stuff at least.
118
- # #if Sexp === exp and not exp.sexp_type.nil? then
119
- # begin
120
- # result.sexp_type = exp.sexp_type
121
- # rescue Exception
122
- # # nothing to do, on purpose
123
- # end
124
- # else
125
- # msg = "Bug! Unknown node-type #{type.inspect} to #{self.class}"
126
- # msg += " in #{exp_orig.inspect} from #{caller.inspect}" if $DEBUG
127
- # raise UnknownNodeError, msg
128
- # end
129
- # end
130
- #
131
- # puts '--------------------------------DONE ---------------------- context'
132
- #
133
- # end
134
- #
135
- # result
136
- # end
137
- #
25
+ def in_context type, &block
26
+ self.context.unshift type
27
+ yield
28
+ self.context.shift
29
+ end
30
+
31
+ def process_str(exp)
32
+ Literal.new(exp.shift)
33
+ end
34
+
138
35
  # => Overwritten method
139
36
  def process_lasgn(exp)
140
- exp.shift
141
37
  next_exp = exp.shift
142
- if next_exp.to_s.match(/var(\d+)/)
143
- s = Statement.new(Unknown.new($1),Equal.new)
38
+ if next_exp.to_s.match(VARIABLE_EXPRESSION)
39
+ s = Statement.new(convert_to_variable(next_exp),Equal.new)
144
40
  end
145
-
146
- if next_exp.kind_of?(Symbol)
147
- res = process(exp.shift)
148
- s.add res
41
+ a = process(exp.shift)
42
+ s.add a
43
+ return s
44
+ end
45
+
46
+ def process_if(exp)
47
+ inner_statement_sexp = exp.shift
48
+ scope = process(exp.shift) # => The content of the if statement
49
+ exp.shift
50
+ open_statement = OpenStatement.new(Statement.new(If.new,Container.new(process(inner_statement_sexp))))
51
+ open_statement << scope unless scope.nil?
52
+ return open_statement
53
+ end
54
+
55
+ def process_return(exp)
56
+ return Statement.new(Return.new,process(exp.shift))
57
+ end
58
+
59
+ def process_call(exp)
60
+ results = []
61
+ until exp.empty?
62
+ atom = exp.shift
63
+ if atom.to_s.match(VARIABLE_EXPRESSION)
64
+ results << convert_to_variable(atom)
65
+ next
66
+ end
67
+ if atom == :==
68
+ results << Equivalent.new
69
+ next
70
+ end
71
+ next if atom.nil?
72
+ res = process(atom)
73
+ next if res.nil?
74
+ results << res
149
75
  end
150
- s
76
+ return Statement.new(*results)
151
77
  end
152
78
 
79
+ def process_arglist(exp)
80
+ return process exp.shift
81
+ end
82
+
83
+ def process_defn(exp)
84
+ type = exp.shift
85
+ args = exp.shift
86
+ scope = exp.shift
87
+
88
+ usage = (args.length==2) ? process(args) : MethodUsage.new
89
+ method_id = type.to_s.match(/method_(\d)+/)[1]
90
+ method = RuntimeMethod.new(usage,method_id)
91
+ statements = process(scope)
92
+ unless statements.nil?
93
+ statements.each do |statement|
94
+ method << statement unless statement.nil?
95
+ end
96
+ end
97
+ return method
98
+
99
+ end
100
+
101
+ def process_args(exp)
102
+ atom = exp.shift
103
+ variable_id = atom.to_s.match(VARIABLE_EXPRESSION)[1]
104
+ param = MethodParameter.new()
105
+ param.variable_id = variable_id
106
+ return MethodUsage.new(param)
107
+ end
108
+
109
+ def process_scope(exp)
110
+ block = exp.shift
111
+ res = process(block)
112
+ return res
113
+ end
114
+
115
+ def process_block(exp)
116
+ result = []
117
+ until exp.empty?
118
+ atom = exp.shift
119
+ next if atom.first == :nil
120
+ result << process(atom)
121
+ end
122
+ return result
123
+ end
124
+
125
+ def process_lvar(exp)
126
+ var = exp.shift
127
+ return convert_to_variable(var)
128
+ end
129
+
130
+ private
131
+
132
+ def convert_to_variable(variable)
133
+ return Unknown.new(variable.to_s.match(VARIABLE_EXPRESSION)[1])
134
+ end
135
+
153
136
  end
154
137
 
155
138
 
@@ -3,11 +3,12 @@ module Cauldron
3
3
  class Terminal
4
4
 
5
5
  include Cauldron::Conversion
6
+ include Cauldron::Demos
6
7
 
7
8
  attr_reader :cases
8
9
 
9
10
  def initialize(output,auto=true)
10
- @output, @cases,@auto = output, [], auto
11
+ @output, @cases, @auto = output, [], auto
11
12
  end
12
13
 
13
14
  def start
@@ -15,7 +16,8 @@ module Cauldron
15
16
  @pot = Cauldron::Pot.new
16
17
  @pot.clear
17
18
  @output.puts '* Adding example case'
18
- @pot.simmer(demo('1'))
19
+ #@pot.simmer(demo('1'))
20
+ @pot.simmer(demo_two)
19
21
 
20
22
  @output.puts "Thanks for trying Cauldron - it's at really early stage right now"
21
23
  @output.puts "in fact it can only generate a method that returns the parameter passed through"
@@ -42,78 +44,7 @@ module Cauldron
42
44
  else
43
45
  @cases << convert_to_example(separate_values(input))
44
46
  end
45
- end
46
-
47
- # => ==========================================================================
48
-
49
- def convert_to_cauldron_test_cases(cases)
50
- cases.inject([]) do |total,x|
51
- cauldron_case = CTestCase.new
52
- cauldron_case[:params] = x[0]
53
- cauldron_case[:output] = x[1]
54
- total << cauldron_case
55
- end
56
- end
57
-
58
- def demo(id)
59
-
60
- @demo_1_test_cases = convert_to_cauldron_test_cases(
61
- [
62
- [['sparky'],'sparky'],
63
- [['kel'],'kel']
64
- ]
65
- )
66
-
67
- # Create demonstration #2
68
- demo_2_test_case_1 = CTestCase.new
69
- demo_2_test_case_1[:params] = ['something']
70
- demo_2_test_case_1[:output] = 'exists'
71
- demo_2_test_case_2 = CTestCase.new
72
- demo_2_test_case_2[:params] = ['my willpower']
73
- demo_2_test_case_2[:output] = 'does not exist'
74
- demo_2_test_cases = [
75
- demo_2_test_case_1,demo_2_test_case_2
76
- ]
77
-
78
- # Create demo #1 chain
79
- # Create the head for the chain
80
- head = Theory.new([],nil,[])
81
-
82
- link_one_action = TheoryAction.new(
83
- TheoryStatement.new(StringToTheory.run('Statement.new(Return.new,var2.params[var3])')),
84
- StringToTheory.run('var1.statement_id')
85
- )
86
- # NOTE: I need to add one result so the theory can be flagged as complete - I might not need it
87
- # to be complete -
88
- link_one_result = TheoryResult.new(StringToTheory.run("if(var1.all_pass?(var2))\nreturn true\nend"))
89
- link_one = Theory.new([],link_one_action,[link_one_result])
90
- chain = Chain.new
91
- chain = chain.add_link(head).first
92
- chain = chain.add_link(
93
- link_one,
94
- {
95
- 1=>IntrinsicRuntimeMethod.new,
96
- 2=>IntrinsicTestCases.new,
97
- 3=>IntrinsicLiteral.new(0)
98
- }
99
- ).first
100
-
101
- # Now implement the chain
102
- implemented_chain = chain.implement
103
-
104
- # TODO It should generate the values too.(TheoryGenerator)
105
- @demo_1 = {
106
- :initial_method=>RuntimeMethod.new(MethodUsage.new(MethodParameter.new)),
107
- :test_cases=>@demo_1_test_cases,
108
- :chain=>chain,
109
- :values=>{}
110
- }
111
-
112
- if id == '1'
113
- return @demo_1
114
- end
115
-
116
- end
47
+ end
117
48
 
118
49
  end
119
50