A toy dynamic programming language written in Ruby
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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