cauldron 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -0
- data/Gemfile.lock +63 -0
- data/History.md +5 -0
- data/Rakefile +62 -16
- data/VERSION +1 -1
- data/cauldron.gemspec +463 -0
- data/cauldron/lib/cauldron.rb +1 -1
- data/features/cauldron_generates_runtime_method.feature +7 -4
- data/features/cauldron_generates_single_paramter_methods.feature +25 -0
- data/features/cauldron_interactive_start_terminal.feature +17 -0
- data/features/cauldron_quit_terminal.feature +9 -0
- data/features/cauldron_start_terminal.feature +0 -1
- data/features/step_definitions/cauldron_steps.rb +10 -5
- data/features/step_definitions/terminal_steps.rb +27 -0
- data/features/support/env.rb +2 -0
- data/features/support/hooks.rb +15 -0
- data/lib/Chain.rb +3 -3
- data/lib/Mapping.rb +1 -0
- data/lib/PartialChain.rb +253 -0
- data/lib/Theory.rb +28 -4
- data/lib/UnifiedChain.rb +94 -125
- data/lib/cauldron.rb +3 -0
- data/lib/cauldron/demos.rb +4 -4
- data/lib/cauldron/env.rb +1 -0
- data/lib/cauldron/pot.rb +42 -38
- data/lib/cauldron/terminal.rb +19 -3
- data/lib/cauldron/util/home.rb +21 -0
- data/lib/cauldron/util/saver.rb +45 -0
- data/lib/core/Container.rb +1 -1
- data/lib/core/runtime_method/ActsAsRuntimeMethod.rb +28 -28
- data/lib/core/runtime_method/RuntimeMethod.rb +6 -23
- data/lib/core/statement/ActsAsStatement.rb +0 -96
- data/lib/core/statement/BlockStatement.rb +1 -1
- data/lib/core/statement/OpenStatement.rb +1 -1
- data/lib/core/statement/Statement.rb +39 -94
- data/lib/core/statement/TheoryStatement.rb +1 -1
- data/lib/core/syntax/BlockContainer.rb +0 -28
- data/lib/core/variable/MethodParameter.rb +1 -1
- data/lib/required.rb +2 -14
- data/lib/theories.rb +0 -1
- data/lib/theory/ActionImplementation.rb +1 -1
- data/lib/theory/TheoryAction.rb +2 -2
- data/lib/theory/TheoryConnector.rb +11 -14
- data/lib/theory/TheoryImplementation.rb +10 -9
- data/lib/util/MethodWriter.rb +10 -10
- data/sandbox.rb +23 -0
- data/spec/cauldron/pot_spec.rb +62 -10
- data/spec/cauldron/runtime_method_spec.rb +31 -17
- data/spec/cauldron/saver_spec.rb +45 -0
- data/spec/cauldron/terminal_spec.rb +10 -1
- data/spec/cauldron/theory_spec.rb +4 -4
- data/spec/cauldron/unified_chain_spec.rb +38 -0
- data/spec/spec_helper.rb +3 -1
- data/tasks/development_tasks.rake +4 -0
- data/tasks/theory_tasks.rake +16 -20
- data/test/fixtures/theories/0/desc +6 -6
- data/test/fixtures/theories/0/dump +0 -0
- data/test/fixtures/theories/1/desc +7 -7
- data/test/fixtures/theories/1/dump +0 -0
- data/test/fixtures/theories/10/desc +13 -13
- data/test/fixtures/theories/10/dump +0 -0
- data/test/fixtures/theories/11/desc +10 -10
- data/test/fixtures/theories/11/dump +0 -0
- data/test/fixtures/theories/12/desc +9 -9
- data/test/fixtures/theories/12/dump +0 -0
- data/test/fixtures/theories/13/desc +16 -16
- data/test/fixtures/theories/13/dump +0 -0
- data/test/fixtures/theories/14/desc +16 -16
- data/test/fixtures/theories/14/dump +0 -0
- data/test/fixtures/theories/15/desc +10 -10
- data/test/fixtures/theories/15/dump +0 -0
- data/test/fixtures/theories/16/desc +10 -10
- data/test/fixtures/theories/16/dump +0 -0
- data/test/fixtures/theories/17/desc +7 -7
- data/test/fixtures/theories/17/dump +0 -0
- data/test/fixtures/theories/18/desc +7 -7
- data/test/fixtures/theories/18/dump +0 -0
- data/test/fixtures/theories/19/desc +7 -7
- data/test/fixtures/theories/19/dump +0 -0
- data/test/fixtures/theories/2/desc +6 -6
- data/test/fixtures/theories/2/dump +0 -0
- data/test/fixtures/theories/20/desc +13 -13
- data/test/fixtures/theories/20/dump +0 -0
- data/test/fixtures/theories/3/desc +7 -7
- data/test/fixtures/theories/3/dump +0 -0
- data/test/fixtures/theories/4/desc +7 -7
- data/test/fixtures/theories/4/dump +0 -0
- data/test/fixtures/theories/5/desc +6 -6
- data/test/fixtures/theories/5/dump +0 -0
- data/test/fixtures/theories/6/desc +7 -7
- data/test/fixtures/theories/6/dump +0 -0
- data/test/fixtures/theories/7/desc +7 -7
- data/test/fixtures/theories/7/dump +0 -0
- data/test/fixtures/theories/8/desc +7 -7
- data/test/fixtures/theories/8/dump +0 -0
- data/test/fixtures/theories/9/desc +16 -16
- data/test/fixtures/theories/9/dump +0 -0
- data/test/fixtures/theory_implementations/0/dump +0 -0
- data/test/fixtures/theory_implementations/2/dump +0 -0
- data/test/ts_complete.rb +1 -10
- data/test/unit/core/runtime_method/tc_realised_runtime_method.rb +1 -0
- data/test/unit/core/runtime_method/tc_runtime_method.rb +16 -39
- data/test/unit/core/statement/tc_block_statement.rb +3 -3
- data/test/unit/core/statement/tc_open_statement.rb +4 -4
- data/test/unit/core/statement/tc_statement.rb +2 -147
- data/test/unit/core/statement/tc_theory_statement.rb +1 -1
- data/test/unit/theory/tc_theory_dependent.rb +3 -3
- data/test/unit/theory/tc_theory_result.rb +5 -5
- data/test/unit/util/tc_method_validation.rb +45 -45
- data/test/unit/util/tc_parser.rb +1 -1
- data/test/unit/util/tc_string_to_theory.rb +2 -2
- metadata +74 -48
- data/lib/ScopeDependencies.rb +0 -8
- data/lib/core/statement/StatementDependencies.rb +0 -271
- data/lib/core/structure/DeclareNewInstanceStructure.rb +0 -49
- data/lib/core/structure/DeclareRuntimeMethodStructure.rb +0 -34
- data/lib/core/structure/DeclareVariableAsLiteralStructure.rb +0 -31
- data/lib/core/structure/DeclareVariableAsVariableStructure.rb +0 -52
- data/lib/core/structure/FixnumAdditionStructure.rb +0 -56
- data/lib/core/structure/InstanceCallContainerStructure.rb +0 -50
- data/lib/core/structure/InstanceCallStructure.rb +0 -53
- data/lib/core/structure/InstanceMethodCallStructure.rb +0 -21
- data/lib/core/structure/ReturnStructure.rb +0 -20
- data/lib/core/structure/StatementStructure.rb +0 -11
- data/test/unit/core/statement/tc_statement_dependencies.rb +0 -147
- data/test/unit/core/structure/tc_declare_new_instance_structure.rb +0 -41
- data/test/unit/core/structure/tc_declare_variable_as_literal_structure.rb +0 -41
- data/test/unit/core/structure/tc_declare_variable_as_variable_structure.rb +0 -66
- data/test/unit/core/structure/tc_instance_call_container_structure.rb +0 -41
- data/test/unit/core/structure/tc_return_structure.rb +0 -32
- data/test/unit/tc_instance_call_structure.rb +0 -35
- data/test/unit/tc_statement_structure_2.rb +0 -43
data/lib/util/MethodWriter.rb
CHANGED
@@ -10,12 +10,12 @@ class MethodWriter
|
|
10
10
|
def write(params,statements,tab=0,method_id=0,additional_comments='')
|
11
11
|
|
12
12
|
line = "\n"
|
13
|
-
tab.times {|x| line += "
|
13
|
+
tab.times {|x| line += " " }
|
14
14
|
line += "#\n"
|
15
15
|
|
16
16
|
params.each_with_index do |var,i|
|
17
|
-
tab.times {|x| line += "
|
18
|
-
line += "
|
17
|
+
tab.times {|x| line += " " }
|
18
|
+
line += "# @param "
|
19
19
|
|
20
20
|
# Get a description of the requirements (this can multiple lines)
|
21
21
|
line_prefix = ''
|
@@ -25,8 +25,8 @@ class MethodWriter
|
|
25
25
|
line += line_prefix+l
|
26
26
|
|
27
27
|
# Assides the first line pre-fix a "# " to the start
|
28
|
-
(tab-1).times {|x| line += "
|
29
|
-
line_prefix = "
|
28
|
+
(tab-1).times {|x| line += " " }
|
29
|
+
line_prefix = "# "
|
30
30
|
|
31
31
|
end
|
32
32
|
|
@@ -34,16 +34,16 @@ class MethodWriter
|
|
34
34
|
|
35
35
|
# Add some some additional comment if supplied
|
36
36
|
unless additional_comments.nil?
|
37
|
-
tab.times {|x| line += "
|
37
|
+
tab.times {|x| line += " " }
|
38
38
|
line += "#"
|
39
|
-
tab.times {|x| line += "
|
39
|
+
tab.times {|x| line += " " }
|
40
40
|
line += additional_comments+"\n"
|
41
41
|
end
|
42
42
|
|
43
|
-
tab.times {|x| line += "
|
43
|
+
tab.times {|x| line += " " }
|
44
44
|
line += "#\n"
|
45
45
|
|
46
|
-
tab.times {|x| line += "
|
46
|
+
tab.times {|x| line += " "}
|
47
47
|
line += 'def method_'+method_id.to_s
|
48
48
|
|
49
49
|
#line += write_params(@parameters)
|
@@ -57,7 +57,7 @@ class MethodWriter
|
|
57
57
|
line += "\n" if statements.empty?
|
58
58
|
|
59
59
|
# Close the method
|
60
|
-
tab.times {|x| line += "
|
60
|
+
tab.times {|x| line += " " }
|
61
61
|
line += "end"+"\n"
|
62
62
|
|
63
63
|
return line
|
data/sandbox.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib',__FILE__)
|
2
|
+
|
3
|
+
require 'cauldron'
|
4
|
+
|
5
|
+
# unified_chain = Cauldron::Util::Saver.load(1)
|
6
|
+
#
|
7
|
+
# puts unified_chain.describe
|
8
|
+
# puts unified_chain.complete?
|
9
|
+
#
|
10
|
+
# puts 'Working'
|
11
|
+
|
12
|
+
|
13
|
+
unified_chain = Cauldron::Util::Saver.load(33)
|
14
|
+
runtime_method = Cauldron::Util::Saver.load(31)
|
15
|
+
test_cases = Cauldron::Util::Saver.load(32)
|
16
|
+
|
17
|
+
puts unified_chain.describe
|
18
|
+
|
19
|
+
|
20
|
+
#unified_chain.valid_mapping_permutations(runtime_method,test_cases)
|
21
|
+
|
22
|
+
|
23
|
+
|
data/spec/cauldron/pot_spec.rb
CHANGED
@@ -5,21 +5,19 @@ module Cauldron
|
|
5
5
|
describe 'Pot' do
|
6
6
|
|
7
7
|
describe '#simmer' do
|
8
|
+
before(:each) {
|
9
|
+
@pot = Cauldron::Pot.new
|
10
|
+
@pot.clear
|
11
|
+
}
|
8
12
|
it 'can simmer with demo one' do
|
9
|
-
pot
|
10
|
-
pot.clear
|
11
|
-
lambda {pot.simmer(demo_one)}.should_not raise_error
|
13
|
+
lambda {@pot.simmer(demo_one)}.should_not raise_error
|
12
14
|
end
|
13
15
|
it 'can simmer with demo two' do
|
14
|
-
pot
|
15
|
-
pot.clear
|
16
|
-
lambda {pot.simmer(demo_two)}.should_not raise_error
|
16
|
+
lambda {@pot.simmer(demo_two)}.should_not raise_error
|
17
17
|
end
|
18
18
|
it 'can simmer with both demo one and two' do
|
19
|
-
pot
|
20
|
-
pot.
|
21
|
-
lambda {pot.simmer(demo_one)}.should_not raise_error
|
22
|
-
lambda {pot.simmer(demo_two)}.should_not raise_error
|
19
|
+
lambda {@pot.simmer(demo_one)}.should_not raise_error
|
20
|
+
lambda {@pot.simmer(demo_two)}.should_not raise_error
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
@@ -86,6 +84,24 @@ module Cauldron
|
|
86
84
|
sexp2cauldron = Sexp2Cauldron.new
|
87
85
|
@pot.brew(cases).reset_ids!.basic_write.should == sexp2cauldron.process(sexp).basic_write
|
88
86
|
end
|
87
|
+
it 'can repeatedly generate a demo 1 solution' do
|
88
|
+
case_set_one = []
|
89
|
+
case_set_one << convert_to_example(separate_values("'pip','pip'"))
|
90
|
+
case_set_one << convert_to_example(separate_values("'rowiage','rowiage'"))
|
91
|
+
|
92
|
+
case_set_two = []
|
93
|
+
case_set_two << convert_to_example(separate_values("'andy','andy'"))
|
94
|
+
case_set_two << convert_to_example(separate_values("'kel','kel'"))
|
95
|
+
|
96
|
+
ruby = "
|
97
|
+
def method_0(var_0)
|
98
|
+
\treturn var_0
|
99
|
+
end
|
100
|
+
"
|
101
|
+
sexp2cauldron = Sexp2Cauldron.new
|
102
|
+
@pot.brew(case_set_one).reset_ids!.basic_write.should == sexp2cauldron.process(RubyParser.new.process(ruby)).basic_write
|
103
|
+
@pot.brew(case_set_two).reset_ids!.basic_write.should == sexp2cauldron.process(RubyParser.new.process(ruby)).basic_write
|
104
|
+
end
|
89
105
|
it 'can generate a solution like demo 2(it needs to discount the demo 1 solution)' do
|
90
106
|
cases = []
|
91
107
|
cases << convert_to_example(separate_values("'sparky','bro'"))
|
@@ -103,6 +119,42 @@ module Cauldron
|
|
103
119
|
sexp2cauldron = Sexp2Cauldron.new
|
104
120
|
@pot.brew(cases).reset_ids!.basic_write.should == sexp2cauldron.process(sexp).basic_write
|
105
121
|
end
|
122
|
+
it 'can repeatedly generate a demo 2 solution' do
|
123
|
+
case_set_one = []
|
124
|
+
case_set_one << convert_to_example(separate_values("'sparky','bro'"))
|
125
|
+
case_set_one << convert_to_example(separate_values("'kel','sis'"))
|
126
|
+
|
127
|
+
ruby = "
|
128
|
+
def method_0(var_0)
|
129
|
+
\tif(var_0 == 'sparky')
|
130
|
+
\t\treturn 'bro'
|
131
|
+
\tend
|
132
|
+
\treturn 'sis'
|
133
|
+
end
|
134
|
+
"
|
135
|
+
parser = RubyParser.new
|
136
|
+
sexp = parser.process(ruby)
|
137
|
+
sexp2cauldron = Sexp2Cauldron.new
|
138
|
+
@pot.brew(case_set_one).reset_ids!.basic_write.should == sexp2cauldron.process(sexp).basic_write
|
139
|
+
|
140
|
+
case_set_two = []
|
141
|
+
case_set_two << convert_to_example(separate_values("'carrot','vegtable'"))
|
142
|
+
case_set_two << convert_to_example(separate_values("'apple','fruit'"))
|
143
|
+
|
144
|
+
ruby = "
|
145
|
+
def method_0(var_0)
|
146
|
+
\tif(var_0 == 'carrot')
|
147
|
+
\t\treturn 'vegtable'
|
148
|
+
\tend
|
149
|
+
\treturn 'fruit'
|
150
|
+
end
|
151
|
+
"
|
152
|
+
parser = RubyParser.new
|
153
|
+
sexp = parser.process(ruby)
|
154
|
+
sexp2cauldron = Sexp2Cauldron.new
|
155
|
+
@pot.brew(case_set_two).reset_ids!.basic_write.should == sexp2cauldron.process(sexp).basic_write
|
156
|
+
|
157
|
+
end
|
106
158
|
end
|
107
159
|
|
108
160
|
end
|
@@ -23,7 +23,7 @@ module Cauldron
|
|
23
23
|
method_param = MethodParameter.new
|
24
24
|
temporary_runtime_method = RuntimeMethod.new(MethodUsage.new(method_param))
|
25
25
|
temporary_runtime_method << Statement.new(Return.new,method_param)
|
26
|
-
temporary_runtime_method.reset_ids!.basic_write.should == "def method_0(var_0)\n
|
26
|
+
temporary_runtime_method.reset_ids!.basic_write.should == "def method_0(var_0)\n return var_0\nend\n"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -43,16 +43,16 @@ module Cauldron
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
context 'using runtime method with if statement' do
|
46
|
-
it '
|
46
|
+
it 'should reset all the ids to 0 and count up' do
|
47
47
|
parser = RubyParser.new
|
48
|
-
ruby =
|
48
|
+
ruby = %q{
|
49
49
|
def method_3(var_8)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
if(var_8 == 'apple')
|
51
|
+
return 'fruit'
|
52
|
+
end
|
53
|
+
return 'vegetable'
|
54
54
|
end
|
55
|
-
|
55
|
+
}
|
56
56
|
sexp = parser.process(ruby)
|
57
57
|
sexp2cauldron = Sexp2Cauldron.new
|
58
58
|
unprocessed_runtime_method = sexp2cauldron.process(sexp)
|
@@ -60,18 +60,32 @@ module Cauldron
|
|
60
60
|
reset_runtime_method.method_id.should == '0'
|
61
61
|
reset_runtime_method.variables.length.should == 1
|
62
62
|
|
63
|
-
ruby_reset =
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
"
|
71
|
-
reset_runtime_method.basic_write.should == strip_whitespace(ruby_reset)+"\n"
|
63
|
+
ruby_reset =
|
64
|
+
%q{def method_0(var_0)
|
65
|
+
if(var_0 == 'apple')
|
66
|
+
return 'fruit'
|
67
|
+
end
|
68
|
+
return 'vegetable'
|
69
|
+
end}
|
70
|
+
reset_runtime_method.basic_write.should == ruby_reset+"\n"
|
72
71
|
end
|
73
72
|
end
|
74
73
|
end
|
74
|
+
|
75
|
+
describe '#realise2' do
|
76
|
+
it 'should be able to realise a very simple runtime method' do
|
77
|
+
parser = RubyParser.new
|
78
|
+
ruby = "
|
79
|
+
def method_3
|
80
|
+
var_13 = 8
|
81
|
+
end
|
82
|
+
"
|
83
|
+
sexp = parser.process(ruby)
|
84
|
+
sexp2cauldron = Sexp2Cauldron.new
|
85
|
+
runtime_method = sexp2cauldron.process(sexp)
|
86
|
+
runtime_method.realise2(ParametersContainer.new).class.should == RealisedRuntimeMethod
|
87
|
+
end
|
88
|
+
end
|
75
89
|
|
76
90
|
end
|
77
91
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Cauldron
|
4
|
+
|
5
|
+
module Util
|
6
|
+
|
7
|
+
describe Saver do
|
8
|
+
|
9
|
+
describe '.save' do
|
10
|
+
it 'can save a string object without raising an exception' do
|
11
|
+
lambda {Cauldron::Util::Saver.save('geth')}.should_not raise_error
|
12
|
+
end
|
13
|
+
it 'will return the path to saved string object after saving it' do
|
14
|
+
Cauldron::Util::Saver.save('Normandy').should match(/cauldron\/debug/)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.debug_directory' do
|
19
|
+
it 'should return the path to the debug directory' do
|
20
|
+
Cauldron::Util::Saver.debug_directory.should include("/cauldron/debug")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.next_directory' do
|
25
|
+
it "should return the path to a directory that doesn't exist" do
|
26
|
+
Cauldron::Util::Saver.next_directory.should match(/cauldron\/debug\/\d+/)
|
27
|
+
end
|
28
|
+
it 'should not return the path to an existing directory' do
|
29
|
+
File.exists?(Cauldron::Util::Saver.next_directory).should_not == true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.load' do
|
34
|
+
it 'can load a saved obj' do
|
35
|
+
path = Cauldron::Util::Saver.save('Adele & Kirk')
|
36
|
+
path_id = path.match(/(\d+)/)[0].to_i
|
37
|
+
Cauldron::Util::Saver.load(path_id).should == 'Adele & Kirk'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -30,7 +30,16 @@ module Cauldron
|
|
30
30
|
end
|
31
31
|
its([0]) { should eq({:output=>"sparky", :params=>["sparky"]}) }
|
32
32
|
its([1]) { should eq({:output=>"kel", :params=>["kel"]}) }
|
33
|
-
end
|
33
|
+
end
|
34
|
+
context 'with example case "sparky", "sparky"' do
|
35
|
+
subject do
|
36
|
+
terminal.submit '"sparky","sparky"'
|
37
|
+
terminal.submit '"kel","kel"'
|
38
|
+
terminal.cases
|
39
|
+
end
|
40
|
+
its([0]) { should eq({:output=>"sparky", :params=>["sparky"]}) }
|
41
|
+
its([1]) { should eq({:output=>"kel", :params=>["kel"]}) }
|
42
|
+
end
|
34
43
|
end
|
35
44
|
|
36
45
|
end
|
@@ -24,11 +24,11 @@ module Cauldron
|
|
24
24
|
if:
|
25
25
|
|
26
26
|
action:
|
27
|
-
|
27
|
+
runtime_method.add_statement_at(Statement.new(Return.new, test_cases.params[0]),runtime_method.statement_id)
|
28
28
|
result:
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
if(runtime_method.all_pass?(test_cases))
|
30
|
+
return true
|
31
|
+
end
|
32
32
|
"
|
33
33
|
theory.map_to(mapping).write.strip.should == result.strip
|
34
34
|
|
@@ -95,6 +95,44 @@ module Cauldron
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
describe '#partial_chain' do
|
99
|
+
before(:each) {
|
100
|
+
temp = Object.new
|
101
|
+
temp.extend(Cauldron::Demos)
|
102
|
+
demo = temp.demo_one
|
103
|
+
@unified_chain = demo[:chain].unify_chain
|
104
|
+
}
|
105
|
+
it 'should return a chain of length 1 when passed the range 0..0' do
|
106
|
+
@unified_chain.partial_chain(0..0).length.should == 1
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#complete?' do
|
112
|
+
context 'when using demo 1' do
|
113
|
+
before(:each) {
|
114
|
+
temp = Object.new
|
115
|
+
temp.extend(Cauldron::Demos)
|
116
|
+
demo = temp.demo_one
|
117
|
+
@unified_chain = demo[:chain].unify_chain
|
118
|
+
}
|
119
|
+
it 'should be a complete chain' do
|
120
|
+
@unified_chain.complete?.should == true
|
121
|
+
end
|
122
|
+
end
|
123
|
+
context 'when using demo 2' do
|
124
|
+
before(:each){
|
125
|
+
temp = Object.new
|
126
|
+
temp.extend(Cauldron::Demos)
|
127
|
+
demo = temp.demo_two
|
128
|
+
@unified_chain = demo[:chain].unify_chain
|
129
|
+
}
|
130
|
+
it 'should be a complete chain' do
|
131
|
+
@unified_chain.complete?.should == true
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
98
136
|
end
|
99
137
|
|
100
138
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,7 +6,9 @@ require 'required'
|
|
6
6
|
def strip_whitespace(ruby_code)
|
7
7
|
#res = ruby_code.strip.gsub(/\t{1,}/,'\t').gsub(/\s{2,}/,'\n')
|
8
8
|
res = ruby_code.strip.gsub(/\t/,'\t').gsub(/\s{2,}/,'\n')
|
9
|
-
|
9
|
+
#res = ruby_code.strip.gsub(/\s{2,}/,'\n')
|
10
|
+
#return res.gsub('\t',"\t").gsub('\n',"\n")
|
11
|
+
return res.gsub('\t'," ").gsub('\n',"\n")
|
10
12
|
end
|
11
13
|
|
12
14
|
include Cauldron::Demos
|
data/tasks/theory_tasks.rake
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
# http://rake.rubyforge.org/
|
2
2
|
# http://rake.rubyforge.org/files/doc/rakefile_rdoc.html
|
3
3
|
|
4
|
-
# TODO Need a test for the rake tasks as well
|
5
|
-
|
6
4
|
namespace :cauldren do
|
7
5
|
|
8
6
|
namespace :implementations do
|
9
7
|
|
10
|
-
desc
|
11
|
-
task :rebuild do
|
12
|
-
|
8
|
+
desc 'Rebuild the implementations'
|
9
|
+
task :rebuild do
|
10
|
+
Rake::Task["cauldren:theories:rebuild"].execute
|
11
|
+
|
13
12
|
file_list = FileList.new('test/fixtures/theory_implementations/*')
|
14
|
-
file_list.each do |
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
file_list.each do |folder_path|
|
14
|
+
|
15
|
+
implementation_id = folder_path.match(/\d+$/)[0].to_i
|
16
|
+
declaration = File.open(File.join(folder_path,'declaration.txt'),'r').read
|
17
|
+
theory_implementation = eval declaration
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
dump_file = File.open(File.join(folder_path,'dump'),'w')
|
20
|
+
data = Marshal.dump(theory_implementation)
|
21
|
+
dump_file << data
|
22
|
+
dump_file.close
|
23
|
+
|
24
|
+
end
|
25
25
|
|
26
26
|
end
|
27
27
|
|
@@ -242,10 +242,7 @@ namespace :cauldren do
|
|
242
242
|
file_list = FileList.new('test/fixtures/theories/*')
|
243
243
|
file_list.each do |x|
|
244
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
245
|
directory_path = File.join('test','fixtures','theories',theory_id.to_s)
|
248
|
-
puts directory_path
|
249
246
|
declaration = File.open(File.join(directory_path,'declaration.txt'),'r').read
|
250
247
|
|
251
248
|
# Save the declaration (incase the theory needs modified
|
@@ -256,9 +253,8 @@ namespace :cauldren do
|
|
256
253
|
theory = eval declaration
|
257
254
|
data = Marshal.dump(theory)
|
258
255
|
|
259
|
-
# TODO Shouldn't include colours for this description
|
260
256
|
desc_file = File.open(File.join(directory_path,'desc'),'w+')
|
261
|
-
desc_file << theory.
|
257
|
+
desc_file << theory.write
|
262
258
|
desc_file.close
|
263
259
|
|
264
260
|
dump_file = File.open(File.join(directory_path,'dump'),'w+')
|