Chervil is a toy Lisp interpreter written in Ruby
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

function_spec.rb 601B

1234567891011121314151617181920212223242526
  1. module Chervil
  2. RSpec.describe AST::Definition do
  3. it 'evaluates its body with its arguments when called' do
  4. expect(
  5. AST::Function.new(
  6. AST::Identifier.new("square"),
  7. [
  8. AST::Identifier.new("x")
  9. ],
  10. [
  11. AST::Application.new(
  12. AST::Identifier.new("*"),
  13. [
  14. AST::Identifier.new("x"),
  15. AST::Identifier.new("x")
  16. ]
  17. )
  18. ],
  19. ).call(
  20. [AST::Number.new(5.0)],
  21. Env.new
  22. )
  23. ).to eq(25.0)
  24. end
  25. end
  26. end