Chervil is a toy Lisp interpreter written in Ruby
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

identifier_spec.rb 535B

123456789101112131415161718
  1. module Chervil
  2. RSpec.describe AST::Identifier do
  3. it 'evaluates' do
  4. env = Env.new
  5. identifier = AST::Identifier.new("x")
  6. value = AST::Number.new(5.0)
  7. definition = AST::Definition.new(identifier, value)
  8. definition.evaluate(env)
  9. expect(identifier.evaluate(env)).to eq(5.0)
  10. end
  11. it 'returns an error for an unbound identifier' do
  12. env = Env.new
  13. identifier = AST::Identifier.new("x")
  14. expect(identifier.evaluate(env)).to eq(Error.new("unbound variable x"))
  15. end
  16. end
  17. end