feat: full while/until loops support, important bug fixes and more tests

This commit is contained in:
Gu://em_ 2026-01-30 23:43:49 +01:00
parent 9e522b2a68
commit f31fca4204
6 changed files with 85 additions and 37 deletions

View file

@ -377,9 +377,14 @@ test_str "If with negation" "if ! false; then echo Yes; fi"
test_str "If faut aller niquer sa mere" "if false; ! false; then echo Embrasse moi; fi"
echo -e "\n$BBlue=== For/While ===$Color_Off"
test_str "While loop" "i=0; while [ \$i -lt 3 ]; do echo \$i; i=\$((i+1)); done"
test_str "Until loop" "i=0; until [ \$i -ge 3 ]; do echo \$i; i=\$((i+1)); done"
echo -e "\n$BBlue=== Loops ===$Color_Off"
test_str "While false" "while false; do false; done"
test_str "While(false) true" "while false; do true; done"
test_str "Until(true) false" "until true; do false; done"
test_str "Until true" "until true; do true; done"
# test_str "While var" "a=2; while [ \$a -eq 2 ]; do \$a=3; done"
test_str "While arithmetic" "i=0; while [ \$i -lt 3 ]; do echo \$i; i=\$((i+1)); done"
test_str "Until arithmetic" "i=0; until [ \$i -ge 3 ]; do echo \$i; i=\$((i+1)); done"
test_str "While break" "while true; do echo break; break; done"
test_str "While continue" "i=0; while [ \$i -lt 3 ]; do i=\$((i+1)); if [ \$i -eq 2 ]; then continue; fi; echo \$i; done"
test_str "For loop basic" "for i in a b c; do echo \$i; done"