Skip to content

Commit

Permalink
Add interpreter tests for arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
AliOsm committed Oct 12, 2024
1 parent 52c46c8 commit c5e1101
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/interpreter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,40 @@ def test_while_with_continue

assert_output("5\n4\n2\n1\n") { @interpreter.eval(code) }
end

def test_array
code = <<~CODE
مصفوفة_الأعداد = [١، ٢]
اطبع(مصفوفة_الأعداد[٠])
CODE

assert_output("1\n") { @interpreter.eval(code) }
end

def test_array_with_newlines
code = <<~CODE
مصفوفة_الأعداد = [
١،
٢
]
اطبع(مصفوفة_الأعداد[٠])
CODE

assert_output("1\n") { @interpreter.eval(code) }
end

def test_nested_arrays
code = <<~CODE
مصفوفة_الأعداد = [
١،
[٢، ٣]
]
اطبع(مصفوفة_الأعداد[١][٠])
CODE

assert_output("2\n") { @interpreter.eval(code) }
end
end
end

0 comments on commit c5e1101

Please sign in to comment.