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.
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
@@ -1,100 +0,0 @@
1
- # TODO I'm not sure whether to keep the IfContainer class or just drop it
2
- # and use Statement.new(If.new,Liter.new(9) etc..)
3
- # if I don't change it IfContainer should probably become a type of Statement
4
-
5
- class IfContainer < Statement
6
-
7
- def initialize(*parameters)
8
- # TODO It would be better to use super here
9
- #super(*parameters)
10
- # TODO i think this is just passed a statement - so it only ever has one parameter - I prefer it that way
11
- #parameters.each { |x| self.push(x) }
12
- parameters.each do |code|
13
- self.push(code.copy)
14
- end
15
-
16
- # TODO I might change the statement_id to be determined by the structure
17
- # of the statement.
18
- @statement_id = @@statement_id
19
- @@statement_id += 1
20
-
21
- end
22
-
23
- # Retunrs the contents of the if_container instance as string contained
24
- # within paraenthesis e.g.
25
- #
26
- # if(var_a == var_b)
27
- #
28
- def write(indent=0)
29
- line = If.new.write(indent)
30
- line += '('
31
- self.each do |x|
32
- line += x.write
33
- line += ' ' unless x.object_id == last.object_id
34
- end
35
- line += ')'
36
- return line
37
- end
38
-
39
- def describe(indent=0)
40
- line = If.new.write(indent)
41
- line += '('
42
- self.each do |x|
43
- line += x.describe
44
- line += ' ' unless x.object_id == last.object_id
45
- end
46
- line += ')'
47
- return line
48
- end
49
-
50
- def replace_theory_variables!(mapping)
51
- self.each_with_index do |x,i|
52
- if x.kind_of?(TheoryVariable) && mapping.has_key?(x.theory_variable_id)
53
- self[i] = mapping[x.theory_variable_id].copy
54
- next
55
- end
56
- self[i].replace_theory_variables!(mapping)
57
- end
58
- end
59
-
60
- # TODO Doesn't need to be here(duplicated results)
61
- def select_all(results=[],&block)
62
- results.push self if block.call(self)
63
- self.each do |x|
64
- if block.call(x)
65
- results.push(x)
66
- else
67
- end
68
- if x.respond_to?(:select_all)
69
- x.select_all(results,&block)
70
- end
71
- end
72
- return results
73
- end
74
-
75
- # Returns a duplicate of this IfContainer instance
76
- #
77
- def copy
78
- a = IfContainer.new(*self.collect {|x| x.copy})
79
- a.statement_id = @statement_id
80
- return a
81
- end
82
-
83
- # TODO Write tests for this
84
- # Returns a string containing the syntax for the container but where
85
- # all the values are literals e.g.
86
- #
87
- # if(var_a == var_b) whould become "if(6 == 7)"
88
- #
89
- def to_literal_string
90
- line = If.new.write
91
- line += '('
92
- self.each do |x|
93
- line += x.to_literal_string
94
- line += ' ' unless x.object_id == last.object_id
95
- end
96
- line += ')'
97
- return line
98
- end
99
-
100
- end