~ntgg/zosh

270f2b81da17530c5ca4f84ab25ba2d3f44bb5a0 — Noah Graff 4 years ago f6053f6
add basic tests
M .gitignore => .gitignore +4 -1
@@ 4,5 4,8 @@
!LICENSE
!*/
!*.zig
!src/*
!src/
!tests/
!tests/*.sh
!tests/*.out


A tests/basic.out => tests/basic.out +6 -0
@@ 0,0 1,6 @@
a b c
d
a b  c
a b  c
a*bc"
a"b\ 'c    d   e' "f g h" # ' i

A tests/basic.sh => tests/basic.sh +11 -0
@@ 0,0 1,11 @@

# comment

echo a  b 	c   
echo d # e f

# another comment
echo 'a b  c'
echo "a b  c" # third comment
echo a"*"b'c"'
echo "a\"b\\" "'c    d   e'" '"f g h"' '#' \' 'i'

A tests/early-exit.out => tests/early-exit.out +1 -0
@@ 0,0 1,1 @@
a

A tests/early-exit.sh => tests/early-exit.sh +2 -0
@@ 0,0 1,2 @@
false && exit; echo a
true && exit; echo b

A tests/pipeline.out => tests/pipeline.out +8 -0
@@ 0,0 1,8 @@
Pipeline 1 command
a b c
Pipeline 2 commands
A b c
Pipeline 3 commands
A B c
Pipeline 4 commands
A B C

A tests/pipeline.sh => tests/pipeline.sh +12 -0
@@ 0,0 1,12 @@

echo "Pipeline 1 command"
echo "a b c"

echo "Pipeline 2 commands"
echo "a b c" | sed s/a/A/

echo "Pipeline 3 commands"
echo "a b c" | sed s/a/A/ | sed s/b/B/

echo "Pipeline 4 commands"
echo "a b c" | sed s/a/A/ | sed s/b/B/ | sed s/c/C/

A tests/subshell.out => tests/subshell.out +17 -0
@@ 0,0 1,17 @@
Subshell basic
a
b
Subshell nested
nested
Subshell pipe from
a
B
c
Subshell pipe to nested
b
Subshell weird format
a
;b)
c
Subshell variables
a

A tests/subshell.sh => tests/subshell.sh +20 -0
@@ 0,0 1,20 @@

echo "Subshell basic"
(echo a; echo b;)

echo "Subshell nested"
(((((((((((echo nested););););););););););)

echo "Subshell pipe from"
(echo a; echo b; echo c) | sed s/b/B/

echo "Subshell pipe to nested"
echo a | (false || (echo b | tac))

echo "Subshell weird format"
( ( (((echo a && echo 	';b)'); );) 	); ); echo c

echo "Subshell variables"
a=a
(a=b)
echo $a