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 595B

1234567891011121314151617181920212223242526
  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. [
  8. AST::Number.new(1.0),
  9. AST::Number.new(2.0),
  10. AST::Number.new(3.0),
  11. ]
  12. ),
  13. AST::Block.new(
  14. [
  15. AST::FunctionCall.new(
  16. AST::Identifier.new('print'),
  17. [
  18. AST::Identifier.new('x')
  19. ]
  20. )
  21. ]
  22. )
  23. ).execute(Environment.new)
  24. }.to output("1.0\n2.0\n3.0\n").to_stdout
  25. end
  26. end