Browse Source

Evaluate identifier referents

master
Dylan Baker 5 years ago
parent
commit
0b46e6cb5a

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

@@ -11,7 +11,7 @@ module Chervil::AST
11 11
     end
12 12
 
13 13
     def evaluate(env)
14
-      env.get(@name)
14
+      env.get(@name).evaluate(env)
15 15
     end
16 16
   end
17 17
 end

+ 1
- 1
spec/ast/function_spec.rb View File

@@ -17,7 +17,7 @@ module Chervil
17 17
             )
18 18
           ],
19 19
         ).call(
20
-          [5.0]
20
+          [AST::Number.new(5.0)]
21 21
         )
22 22
       ).to eq(25.0)
23 23
     end

+ 1
- 1
spec/ast/identifier_spec.rb View File

@@ -6,7 +6,7 @@ module Chervil
6 6
       value = AST::Number.new(5.0)
7 7
       definition = AST::Definition.new(identifier, value)
8 8
       definition.evaluate(env)
9
-      expect(identifier.evaluate(env)).to eq(value)
9
+      expect(identifier.evaluate(env)).to eq(5.0)
10 10
     end
11 11
   end
12 12
 end

+ 1
- 1
spec/interpreter_spec.rb View File

@@ -10,7 +10,7 @@ module Chervil
10 10
       env = Env.new
11 11
       interpret('(define x 5)', env)
12 12
       expect(env.get("x")).to eq(AST::Number.new(5.0))
13
-      expect(interpret('x', env).first).to eq(AST::Number.new(5.0))
13
+      expect(interpret('x', env).first).to eq(5.0)
14 14
     end
15 15
   end
16 16
 end

Loading…
Cancel
Save