1234567891011121314151617181920212223242526 |
- module Chervil
- RSpec.describe AST::Definition do
- it 'evaluates its body with its arguments when called' do
- expect(
- AST::Function.new(
- AST::Identifier.new("square"),
- [
- AST::Identifier.new("x")
- ],
- [
- AST::Application.new(
- AST::Identifier.new("*"),
- [
- AST::Identifier.new("x"),
- AST::Identifier.new("x")
- ]
- )
- ],
- ).call(
- [AST::Number.new(5.0)],
- Env.new
- )
- ).to eq(25.0)
- end
- end
- end
|