A toy dynamic programming language written in Ruby
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

for_loop_spec.rb 523B

123456789101112131415161718192021
  1. RSpec.describe AST::ForLoop do
  2. it 'evaluates' do
  3. expect {
  4. AST::ForLoop.new(
  5. AST::Identifier.new('x'),
  6. AST::Array.new(
  7. [AST::Number.new(1.0), AST::Number.new(2.0), AST::Number.new(3.0)]
  8. ),
  9. AST::Block.new(
  10. [
  11. AST::FunctionCall.new(
  12. AST::Identifier.new('print'),
  13. [AST::Identifier.new('x')]
  14. )
  15. ]
  16. )
  17. )
  18. .execute(Environment.new)
  19. }.to output("1.0\n2.0\n3.0\n").to_stdout
  20. end
  21. end