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

12345678910111213141516171819202122
  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::FunctionCall.new(
  14. AST::Identifier.new('print'),
  15. [
  16. AST::Identifier.new('x')
  17. ]
  18. )
  19. ).execute(Environment.new)
  20. }.to output("1.0\n2.0\n3.0\n").to_stdout
  21. end
  22. end