cauldron 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -1
  3. data/.rspec +1 -0
  4. data/Gemfile +16 -9
  5. data/Gemfile.lock +134 -64
  6. data/README.md +26 -0
  7. data/Rakefile +24 -99
  8. data/build_sandbox.rb +41 -0
  9. data/cucumber.yml +8 -0
  10. data/features/chop.feature +23 -0
  11. data/features/create_dynamic_statements.feature +14 -0
  12. data/features/generate_known_solution.feature +42 -0
  13. data/features/generate_new_statement.feature +20 -0
  14. data/features/step_definitions/cauldron_steps.rb +47 -0
  15. data/features/support/env.rb +1 -1
  16. data/features/use_existing_statements.feature +23 -0
  17. data/lib/cauldron.rb +41 -5
  18. data/lib/cauldron/actualized_composite.rb +35 -0
  19. data/lib/cauldron/array_collect_template/default.rb +95 -0
  20. data/lib/cauldron/array_collect_template/template.rb +57 -0
  21. data/lib/cauldron/builder.rb +60 -0
  22. data/lib/cauldron/caret.rb +50 -0
  23. data/lib/cauldron/dynamic_operator.rb +90 -0
  24. data/lib/cauldron/dynamic_operator_module.rb +140 -0
  25. data/lib/cauldron/example.rb +18 -0
  26. data/lib/cauldron/example_set.rb +36 -0
  27. data/lib/cauldron/histories.rb +53 -0
  28. data/lib/cauldron/history.rb +34 -0
  29. data/lib/cauldron/if_relationship.rb +4 -6
  30. data/lib/cauldron/number_addition_template/add_five.rb +71 -0
  31. data/lib/cauldron/number_addition_template/template.rb +56 -0
  32. data/lib/cauldron/operator.rb +62 -0
  33. data/lib/cauldron/operator/array_reverse_operator.rb +160 -0
  34. data/lib/cauldron/operator/concat_operator.rb +72 -0
  35. data/lib/cauldron/operator/hash_key_value_operator.rb +74 -0
  36. data/lib/cauldron/operator/numeric_operator.rb +115 -0
  37. data/lib/cauldron/operator/string_asterisk_operator.rb +131 -0
  38. data/lib/cauldron/operator/to_s_operator.rb +18 -0
  39. data/lib/cauldron/operator/var_collect_operator.rb +29 -0
  40. data/lib/cauldron/pot.rb +136 -26
  41. data/lib/cauldron/scope.rb +24 -0
  42. data/lib/cauldron/solution/composite.rb +236 -0
  43. data/lib/cauldron/solution/one.rb +49 -0
  44. data/lib/cauldron/statement_generator.rb +298 -0
  45. data/lib/cauldron/template_base.rb +14 -0
  46. data/lib/cauldron/tracer.rb +55 -0
  47. data/lib/cauldron/version.rb +1 -1
  48. data/lib/pry_tester.rb +76 -0
  49. data/ruby_to_sexp.rb +74 -0
  50. data/sandbox.rb +7 -0
  51. data/sexp_to_ruby.rb +150 -0
  52. data/spec/cauldron/actualized_composite_spec.rb +140 -0
  53. data/spec/cauldron/array_collect_template/default_spec.rb +41 -0
  54. data/spec/cauldron/builder_spec.rb +186 -0
  55. data/spec/cauldron/dynamic/add_number_template_spec.rb +30 -0
  56. data/spec/cauldron/dynamic_operator_spec.rb +416 -0
  57. data/spec/cauldron/example_set_spec.rb +49 -0
  58. data/spec/cauldron/example_spec.rb +33 -0
  59. data/spec/cauldron/histories_spec.rb +135 -0
  60. data/spec/cauldron/history_spec.rb +118 -0
  61. data/spec/cauldron/if_relationship_spec.rb +1 -1
  62. data/spec/cauldron/operator/array_reverse_operator_spec.rb +73 -0
  63. data/spec/cauldron/{concat_operator_spec.rb → operator/concat_operator_spec.rb} +30 -12
  64. data/spec/cauldron/operator/hash_key_value_operator_spec.rb +98 -0
  65. data/spec/cauldron/operator/numeric_operator_spec.rb +110 -0
  66. data/spec/cauldron/operator/string_asterisk_operator_spec.rb +196 -0
  67. data/spec/cauldron/operator/var_collect_operator_spec.rb +38 -0
  68. data/spec/cauldron/pot_spec.rb +176 -14
  69. data/spec/cauldron/solution/composite_spec.rb +421 -0
  70. data/spec/cauldron/solution/one_spec.rb +24 -0
  71. data/spec/cauldron/statement_generator_spec.rb +211 -0
  72. data/spec/cauldron/terminal_spec.rb +2 -2
  73. data/spec/spec_helper.rb +5 -1
  74. data/spec/support/code_matcher.rb +55 -0
  75. data/spec/support/include_instance_of_matcher.rb +9 -0
  76. data/spec/support/shared_examples_for_leaf_operators.rb +22 -0
  77. data/spec/support/shared_examples_for_operators.rb +23 -0
  78. data/syntax_spec.txt +2 -0
  79. metadata +104 -41
  80. data/README +0 -1
  81. data/README.rdoc +0 -19
  82. data/VERSION +0 -1
  83. data/features/cauldron_new_approach.feature +0 -46
  84. data/lib/cauldron/array_reverse_operator.rb +0 -39
  85. data/lib/cauldron/concat_operator.rb +0 -34
  86. data/lib/cauldron/numeric_operator.rb +0 -45
  87. data/lib/cauldron/relationship.rb +0 -5
  88. data/spec/cauldron/array_reverse_operator_spec.rb +0 -59
  89. data/spec/cauldron/numeric_operator_spec.rb +0 -70
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+
3
+ module Cauldron
4
+
5
+ describe HashKeyValueOperator do
6
+
7
+ it_behaves_like "operator" do
8
+ let(:operator) { HashKeyValueOperator.new([0]) }
9
+ let(:initial_scope) { Cauldron::Scope.new(['var0']) }
10
+ let(:initial_operators) { [] }
11
+ end
12
+
13
+ describe '.viable?' do
14
+
15
+ context 'the argument is not a hash' do
16
+
17
+ it 'is false' do
18
+ expect(HashKeyValueOperator.viable?(['string'], 'foobar')).to eql(false)
19
+ end
20
+
21
+ end
22
+
23
+ context 'the argument is a hash' do
24
+
25
+ it 'is true' do
26
+ expect(HashKeyValueOperator.viable?([{:foo => 'bar'}], 'foobar')).to eql(true)
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ describe '.uses_constants?' do
34
+
35
+ it 'is true' do
36
+ expect(HashKeyValueOperator.uses_constants?).to eql(true)
37
+ end
38
+
39
+ end
40
+
41
+ describe '.find_constants' do
42
+
43
+ context 'hash uses key :foo' do
44
+
45
+ let(:problems) do
46
+ Cauldron::ExampleSet.new(
47
+ [Cauldron::Example.new({ arguments: [{:foo => 'bar'}], response: 'bar'})]
48
+ )
49
+ end
50
+
51
+ it 'return ":foo"' do
52
+ HashKeyValueOperator.find_constants(problems).should == [:foo]
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+
59
+ describe '#successful?' do
60
+
61
+ context 'both problems return reponse when using the key' do
62
+
63
+ let(:problems) do
64
+ Cauldron::ExampleSet.new(
65
+ [
66
+ Cauldron::Example.new({ arguments: [{:foo => 'bar'}], response: 'bar'}),
67
+ Cauldron::Example.new({ arguments: [{:foo => 'mass', :bar => 'effect'}], response: 'mass'}),
68
+ ]
69
+ )
70
+ end
71
+
72
+ it 'is true' do
73
+ operator = HashKeyValueOperator.new([0])
74
+ problems.all? {|x| operator.successful?(x) }.should == true
75
+ end
76
+
77
+ end
78
+
79
+ end
80
+
81
+ describe '#to_ruby' do
82
+
83
+ let(:scope) { Cauldron::Scope.new(['var0']) }
84
+
85
+ context 'using the constant ":foo"' do
86
+
87
+ it 'returns "var0[:foo]"' do
88
+ operator = HashKeyValueOperator.new([0])
89
+ operator.to_ruby(scope,[]).should == 'var0[:foo]'
90
+ end
91
+
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+
98
+ end
@@ -0,0 +1,110 @@
1
+ require 'spec_helper'
2
+
3
+ module Cauldron
4
+
5
+ describe 'NumericOperator' do
6
+
7
+ it_behaves_like "operator" do
8
+ let(:operator) { NumericOperator.new([0]) }
9
+ let(:initial_scope) { Cauldron::Scope.new(['var0']) }
10
+ let(:initial_operators) { [] }
11
+ end
12
+
13
+ describe '#realizable?' do
14
+
15
+ let(:subject) { NumericOperator.new([0]) }
16
+
17
+ context 'histories is [[{:var0 => 8}]]' do
18
+
19
+ let(:histories) do
20
+ Histories.new([Cauldron::History.new([{:var0 => 8}])])
21
+ end
22
+
23
+ before(:each) { histories.stub(:variable_permutations).and_return [{:var0 => 8}] }
24
+
25
+ it 'returns true' do
26
+ subject.realizable?(histories).should == true
27
+ end
28
+
29
+ end
30
+
31
+ context %q{histories is [[{:var0 => 'string'}]]} do
32
+
33
+ let(:histories) do
34
+ Histories.new([Cauldron::History.new([{:var0 => 'string'}])])
35
+ end
36
+
37
+ before(:each) { histories.stub(:variable_permutations).and_return [{:var0 => 'string'}] }
38
+
39
+ it 'returns false' do
40
+ subject.realizable?(histories).should == false
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+
47
+ describe '.viable?' do
48
+
49
+ context 'consistent difference between argument and response' do
50
+
51
+ it 'is true' do
52
+ problem = [
53
+ {arguments: [7], response: 8},
54
+ {arguments: [10], response: 11}
55
+ ]
56
+ expect(problem.all? {|x| NumericOperator.viable?(x[:arguments], x[:response]) }).to eql(true)
57
+ end
58
+
59
+ end
60
+
61
+ context 'arguments are not numeric' do
62
+
63
+ it 'is false' do
64
+ problem = [
65
+ {arguments: ["ted"], response: 8},
66
+ {arguments: ["ben"], response: 11}
67
+ ]
68
+ expect(problem.all? {|x| NumericOperator.viable?(x[:arguments], x[:response]) }).to eql(false)
69
+ end
70
+
71
+ end
72
+
73
+ context 'responses are not numeric' do
74
+
75
+ it 'is false' do
76
+ problem = [
77
+ {arguments: [7], response: 'ben'},
78
+ {arguments: [10], response: 'ted'}
79
+ ]
80
+ expect(problem.all? {|x| NumericOperator.viable?(x[:arguments], x[:response]) }).to eql(false)
81
+ end
82
+
83
+ end
84
+
85
+ end
86
+
87
+ describe '#successful?' do
88
+
89
+ context 'no consistent difference between values' do
90
+
91
+ let(:problem) do
92
+ [
93
+ {arguments: [7], response: 24},
94
+ {arguments: [10], response: 11}
95
+ ]
96
+ end
97
+
98
+ let(:operator) { NumericOperator.new([0]) }
99
+
100
+ it 'is false' do
101
+ expect(problem.all? { |x| operator.successful?(x) }).to eql(false)
102
+ end
103
+
104
+ end
105
+
106
+ end
107
+
108
+ end
109
+
110
+ end
@@ -0,0 +1,196 @@
1
+ require 'spec_helper'
2
+
3
+ module Cauldron
4
+
5
+ describe StringAsteriskOperator do
6
+
7
+ it_behaves_like "leaf_operator" do
8
+ let(:leaf_operator) { StringAsteriskOperator.new([0]) }
9
+ end
10
+
11
+ # it_behaves_like "operator" do
12
+ # let(:operator) { StringAsteriskOperator.new([0], 2) }
13
+ # let(:initial_scope) { Cauldron::Scope.new(['var0']) }
14
+ # let(:initial_operators) { [] }
15
+ # end
16
+
17
+ describe '.history_goals' do
18
+
19
+ context 'with the history [{:x => "lima"},{:x => "bear"}]' do
20
+
21
+ let(:history) { [{:x => "lima"},{:x => "bear"}] }
22
+
23
+ context "and target ['limalima','bearbear']" do
24
+
25
+ it 'returns "x * 2"' do
26
+ StringAsteriskOperator.history_goals(
27
+ history, ['limalima','bearbear']
28
+ ).should == [
29
+ [{:x => 'lima'}, 'limalima'],
30
+ [{:x => 'bear'}, 'bearbear']
31
+ ]
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ describe '.instances' do
41
+
42
+ context 'with the history [{:x => "lima"},{:x => "bear"}]' do
43
+
44
+ let(:history) { [{:x => "lima"},{:x => "bear"}] }
45
+
46
+ let(:scope) { Cauldron::Scope.new(['var0','x']) }
47
+
48
+ context "and target ['limalima','bearbear']" do
49
+
50
+ it 'returns "x * 2"' do
51
+ pending
52
+ StringAsteriskOperator.instances(
53
+ history, ['limalima','bearbear']
54
+ ).first.to_ruby(scope).should == "x * 2"
55
+ end
56
+
57
+ end
58
+
59
+ end
60
+
61
+ end
62
+
63
+ describe '.find_constants' do
64
+
65
+ context 'argument string is "hello"' do
66
+
67
+ context 'response string is hellohello' do
68
+
69
+ let(:problems) do
70
+ Cauldron::ExampleSet.new(
71
+ [Cauldron::Example.new({ arguments: ['hello'], response: 'hellohello' })]
72
+ )
73
+ end
74
+
75
+ it 'returns [2]' do
76
+ StringAsteriskOperator.find_constants(problems).should == [2]
77
+ end
78
+
79
+ end
80
+
81
+ context 'response string is "foo"' do
82
+
83
+ let(:problems) do
84
+ Cauldron::ExampleSet.new(
85
+ [Cauldron::Example.new({ arguments: ['hello'], response: 'foo' })]
86
+ )
87
+ end
88
+
89
+ it 'returns []' do
90
+ StringAsteriskOperator.find_constants(problems).should == []
91
+ end
92
+
93
+ end
94
+
95
+ end
96
+
97
+ context 'argument is ["foo", "lima"]' do
98
+
99
+ context 'response is ["foofoo", "limalima"]' do
100
+
101
+ let(:problems) do
102
+ Cauldron::ExampleSet.new(
103
+ [Cauldron::Example.new({ arguments: [["foo", "lima"]], response: ["foofoo", "limalima"] })]
104
+ )
105
+ end
106
+
107
+ it 'returns []' do
108
+ StringAsteriskOperator.find_constants(problems).should == []
109
+ end
110
+
111
+ end
112
+
113
+ end
114
+
115
+ end
116
+
117
+ describe '.viable?' do
118
+
119
+ context 'argument is a string' do
120
+
121
+ context 'response is string' do
122
+
123
+ it 'is true' do
124
+ expect(StringAsteriskOperator.viable?(['hello'],'hellohello') ).to eql(true)
125
+ end
126
+
127
+ end
128
+
129
+ context 'response is an array' do
130
+
131
+ it 'is false' do
132
+ expect(StringAsteriskOperator.viable?(['hello'],['hellohello']) ).to eql(false)
133
+ end
134
+
135
+ end
136
+
137
+ end
138
+
139
+ context 'argument is not a string' do
140
+
141
+ it 'is false' do
142
+ expect(StringAsteriskOperator.viable?([8],'hellohello')).to eql(false)
143
+ end
144
+
145
+ end
146
+
147
+ end
148
+
149
+ describe '.uses_constants?' do
150
+
151
+ it 'is true' do
152
+ expect(StringAsteriskOperator.uses_constants?).to eql(true)
153
+ end
154
+
155
+ end
156
+
157
+ describe '#successful?' do
158
+
159
+ context 'argument string is "hello"' do
160
+
161
+ context 'response string is hellohello' do
162
+
163
+ context 'constant is 2' do
164
+
165
+ it 'is true' do
166
+ problem = { arguments: ['hello'], response: 'hellohello' }
167
+ operator = StringAsteriskOperator.new([0])
168
+ expect(operator.successful?(problem) ).to eql(true)
169
+ end
170
+
171
+ end
172
+
173
+ end
174
+
175
+ end
176
+
177
+ end
178
+
179
+ describe '#to_ruby' do
180
+
181
+ context 'constant is 2' do
182
+
183
+ let(:scope) { Cauldron::Scope.new(['var0']) }
184
+
185
+ it 'returns "var0 * 2"' do
186
+ operator = StringAsteriskOperator.new([0])
187
+ operator.to_ruby(scope,[]).should == "var0 * 2"
188
+ end
189
+
190
+ end
191
+
192
+ end
193
+
194
+ end
195
+
196
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ module Cauldron
4
+
5
+ describe VarCollectOperator do
6
+
7
+ it_behaves_like "operator" do
8
+ let(:operator) { VarCollectOperator.new([0]) }
9
+ let(:initial_scope) { Cauldron::Scope.new(['var0']) }
10
+ let(:initial_operators) { [] }
11
+ end
12
+
13
+ let(:operator) do
14
+ VarCollectOperator.new([0])
15
+ end
16
+
17
+ let(:scope) do
18
+ Cauldron::Scope.new(['var0'])
19
+ end
20
+
21
+ describe '#to_ruby' do
22
+
23
+ it %q{is
24
+ var1 = var0.collect do |var2|
25
+ var2
26
+ end
27
+ } do
28
+ operator.to_ruby(scope,[]).should == %{
29
+ var1 = var0.collect do |var2| var2 end
30
+ }.strip
31
+ end
32
+
33
+
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -4,6 +4,13 @@ module Cauldron
4
4
 
5
5
  describe 'Pot' do
6
6
 
7
+ let(:collect_and_multiple) do
8
+ [
9
+ { arguments: [['foo','lima']], response: ['foofoo','limalima'] },
10
+ { arguments: [['bar','delta']], response: ['barbar','deltadelta'] }
11
+ ]
12
+ end
13
+
7
14
  describe '#solve' do
8
15
 
9
16
  context 'passed simple if statement problem' do
@@ -19,13 +26,13 @@ module Cauldron
19
26
  %q{
20
27
  def function(var0)
21
28
  if var0 == 7
22
- return 'seven'
29
+ return "seven"
23
30
  end
24
31
  if var0 == 8
25
- return 'eight'
32
+ return "eight"
26
33
  end
27
- end
28
- }.strip
34
+ end
35
+ }.lstrip
29
36
  end
30
37
 
31
38
  end
@@ -33,6 +40,7 @@ end
33
40
  context 'passed +1 problem' do
34
41
 
35
42
  it 'returns a function that adds 1 to total' do
43
+ pending
36
44
  pot = Pot.new
37
45
  pot.solve(
38
46
  [
@@ -43,8 +51,36 @@ end
43
51
  %q{
44
52
  def function(var0)
45
53
  var0 + 1
46
- end
47
- }.strip
54
+ end
55
+ }.lstrip
56
+ end
57
+
58
+ end
59
+
60
+ context %{passed ['Pip','Rowe'] and returns ['Pi','Row']} do
61
+
62
+ let(:pot) { pot = Pot.new }
63
+ let(:examples) do
64
+ [{arguments: [['Pip','Rowe']], response: ['Pi','Row']}]
65
+ end
66
+
67
+ it %q{
68
+ returns
69
+ def function(var0)
70
+ var2 = var0.collect do |var1|
71
+ var1.chop
72
+ end
73
+ end
74
+ } do
75
+ pending
76
+ expect(pot.solve(examples) ).to eql(
77
+ %q{
78
+ def function(var0)
79
+ var1 = var0.collect do |var2|
80
+ var2.chop
81
+ end
82
+ end
83
+ }).lstrip
48
84
  end
49
85
 
50
86
  end
@@ -52,41 +88,167 @@ end
52
88
  context 'passed "foo" and return "foobar"' do
53
89
 
54
90
  it 'returns a concat function' do
91
+ pending
55
92
  pot = Pot.new
56
- pot.solve(
93
+ expect(pot.solve(
57
94
  [
58
95
  {arguments: ['foo'], response: 'foobar'},
59
96
  {arguments: ['bar'], response: 'barbar'}
60
97
  ]
61
- ).should ==
98
+ )).to eql(
62
99
  %q{
63
100
  def function(var0)
64
- var0.concat('bar')
101
+ var0.concat("bar")
65
102
  end
66
- }.strip
103
+ }).lstrip
67
104
  end
68
105
 
69
106
  end
70
107
 
71
- context 'passed ["lion","bear"] and return ["bear","lion"]' do
108
+ context 'passed ["lion","bear"] and return ["bear","lion"]' do
72
109
 
73
110
  it 'returns a reverse function' do
74
111
  pot = Pot.new
75
112
  pot.solve(
76
113
  [
77
- { arguments: [['lion','bear']], response: ['bear','lion'] },
78
- { arguments: [['foo','bar']], response: ['bar','foo'] }
114
+ { arguments: [['lion', 'bear']], response: ['bear','lion'] },
115
+ { arguments: [['foo', 'bar']], response: ['bar','foo'] }
79
116
  ]
80
117
  ).should ==
81
118
  %q{
82
119
  def function(var0)
83
120
  var0.reverse
84
121
  end
85
- }.strip
122
+ }.lstrip
123
+ end
124
+
125
+ end
126
+
127
+ context '{:foo => 5, :bar => 7 } and return 7' do
128
+
129
+ context '{:foo => 10, :bar => 5 } and return 10' do
130
+
131
+ let(:pot) { Pot.new }
132
+
133
+ it 'returns the value of foo' do
134
+ pot.solve(
135
+ [
136
+ { arguments: [{:foo => 5, :bar => 7 }], response: 5 },
137
+ { arguments: [{:foo => 10, :bar => 5 }], response: 10 }
138
+ ]
139
+ ).should ==
140
+ %q{
141
+ def function(var0)
142
+ var0[:foo]
143
+ end
144
+ }.lstrip
145
+ end
146
+
86
147
  end
87
148
 
88
149
  end
89
150
 
151
+ describe 'using string#* problem' do
152
+
153
+ it 'returns a valid statement' do
154
+ pending
155
+ sexp = Ripper::SexpBuilder.new(%Q{def function(var0)\n var0 * 3\nend}).parse
156
+ pot = Pot.new
157
+ pot.solve(
158
+ [
159
+ {arguments: ['foo'], response: 'foofoofoo'},
160
+ {arguments: ['bar'], response: 'barbarbar'}
161
+ ]
162
+ ).should ==
163
+ %q{
164
+ def function(var0)
165
+ var0 * 3
166
+ end
167
+ }.lstrip
168
+ end
169
+
170
+ end
171
+
172
+ describe 'chaining operators' do
173
+
174
+ describe 'use of Array#collect' do
175
+
176
+ describe 'use of string#*' do
177
+
178
+ it %{returns the function
179
+ def function(var0)
180
+ var0.collect { |x| x * 2 }
181
+ end
182
+ } do
183
+ pending
184
+ pot = Pot.new
185
+ expect(pot.solve(
186
+ [
187
+ { arguments: [['foo', 'lima']], response: ['foofoo', 'limalima'] },
188
+ { arguments: [['bar', 'delta']], response: ['barbar', 'deltadelta'] }
189
+ ]
190
+ )).to eql(
191
+ %q{
192
+ def function(var0)
193
+ var0.collect { |x|
194
+ x * 2
195
+ }
196
+ end
197
+ }).lstrip
198
+ end
199
+
200
+ end
201
+
202
+ end
203
+
204
+ end
205
+
206
+ end
207
+
208
+ describe '#chain_operators' do
209
+
210
+ it 'returns a solution function' do
211
+ pending
212
+ pot = Pot.new
213
+ pot.chain_operators(
214
+ collect_and_multiple,
215
+ [ArrayCollect.new([0]), StringAsteriskOperator.new([1])]
216
+ ).should == "var0.collect { |var1| var1 * 2 }"
217
+ end
218
+
219
+ end
220
+
221
+ describe '#build_chain_operator' do
222
+
223
+ #[ArrayCollect, StringAsteriskOperator]
224
+ context 'operators are Array#collect and String#*' do
225
+
226
+ let(:scope) do
227
+ Cauldron::Scope.new(['var0'])
228
+ end
229
+
230
+ let(:tree) do
231
+ root = Tree::TreeNode.new("ROOT", "Root Content")
232
+ child = Tree::TreeNode.new("CHILD1", ArrayCollect.new([0]))
233
+ grand_child = Tree::TreeNode.new("CHILD2", StringAsteriskOperator.new([1],2))
234
+ child << grand_child
235
+ root << child
236
+ root
237
+ end
238
+
239
+ it 'is "var0.collect { |x| x * 2 }"' do
240
+ pending
241
+ pot = Pot.new
242
+ pot.build_chain_operator(
243
+ [ArrayCollect, StringAsteriskOperator],
244
+ collect_and_multiple
245
+ ).to_ruby(scope).should == Cauldron::Solution::Composite.new(
246
+ tree.children #[ArrayCollect.new([0]),StringAsteriskOperator.new([1],2)]
247
+ ).to_ruby(Cauldron::Scope.new(['var0']))
248
+ end
249
+
250
+ end
251
+
90
252
  end
91
253
 
92
254
  end