Browse Source

Number and string accept an environment as well

master
Dylan Baker 5 years ago
parent
commit
2910625b1a
4 changed files with 8 additions and 8 deletions
  1. 1
    1
      lib/chervil/ast/number.rb
  2. 1
    1
      lib/chervil/ast/string.rb
  3. 3
    3
      spec/ast/number_spec.rb
  4. 3
    3
      spec/ast/string_spec.rb

+ 1
- 1
lib/chervil/ast/number.rb View File

@@ -6,7 +6,7 @@ module Chervil::AST
6 6
       @value = value
7 7
     end
8 8
 
9
-    def evaluate
9
+    def evaluate(env)
10 10
       @value
11 11
     end
12 12
 

+ 1
- 1
lib/chervil/ast/string.rb View File

@@ -10,7 +10,7 @@ module Chervil::AST
10 10
       @value == other.value
11 11
     end
12 12
 
13
-    def evaluate
13
+    def evaluate(env)
14 14
       @value
15 15
     end
16 16
   end

+ 3
- 3
spec/ast/number_spec.rb View File

@@ -1,7 +1,7 @@
1
-module Chervil::AST
2
-  RSpec.describe Number do
1
+module Chervil
2
+  RSpec.describe AST::Number do
3 3
     it 'evaluates' do
4
-      expect(Number.new(5.0).evaluate).to eq(5.0)
4
+      expect(AST::Number.new(5.0).evaluate(Env.new)).to eq(5.0)
5 5
     end
6 6
   end
7 7
 end

+ 3
- 3
spec/ast/string_spec.rb View File

@@ -1,7 +1,7 @@
1
-module Chervil::AST
2
-  RSpec.describe String do
1
+module Chervil
2
+  RSpec.describe AST::String do
3 3
     it 'evaluates' do
4
-      expect(String.new("hello world").evaluate).to eq("hello world")
4
+      expect(AST::String.new("hello world").evaluate(Env.new)).to eq("hello world")
5 5
     end
6 6
   end
7 7
 end

Loading…
Cancel
Save