diff options
author | axel <axel@liljencrantz.se> | 2005-09-20 23:31:55 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2005-09-20 23:31:55 +1000 |
commit | 7ddecde54372c25fcf526e2d24807c5dac9800aa (patch) | |
tree | 1bff6e0ccd096836adb74529d53a6debcf45375b /tests | |
parent | 149594f974350bb364a76c73b91b1d5ffddaa1fa (diff) |
Add subdirectories
darcs-hash:20050920133155-ac50b-9a14c6c664dd03afbe8e15e7c7998fcfb5c3c750.gz
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/gen_output.fish | 17 | ||||
-rwxr-xr-x | tests/test.fish | 42 | ||||
-rw-r--r-- | tests/test1.err | 0 | ||||
-rw-r--r-- | tests/test1.in | 53 | ||||
-rw-r--r-- | tests/test1.out | 7 | ||||
-rw-r--r-- | tests/test1.status | 1 | ||||
-rw-r--r-- | tests/test2.err | 0 | ||||
-rw-r--r-- | tests/test2.in | 6 | ||||
-rw-r--r-- | tests/test2.out | 1 | ||||
-rw-r--r-- | tests/test2.status | 1 | ||||
-rw-r--r-- | tests/test3.err | 0 | ||||
-rw-r--r-- | tests/test3.in | 113 | ||||
-rw-r--r-- | tests/test3.out | 9 | ||||
-rw-r--r-- | tests/test3.status | 1 | ||||
-rw-r--r-- | tests/test4.err | 0 | ||||
-rw-r--r-- | tests/test4.in | 35 | ||||
-rw-r--r-- | tests/test4.out | 4 | ||||
-rw-r--r-- | tests/test4.status | 1 | ||||
-rw-r--r-- | tests/test5.err | 0 | ||||
-rw-r--r-- | tests/test5.in | 25 | ||||
-rw-r--r-- | tests/test5.out | 3 | ||||
-rw-r--r-- | tests/test5.status | 1 |
22 files changed, 320 insertions, 0 deletions
diff --git a/tests/gen_output.fish b/tests/gen_output.fish new file mode 100755 index 00000000..91db67b0 --- /dev/null +++ b/tests/gen_output.fish @@ -0,0 +1,17 @@ +#!/usr/bin/fish + +# +# Generate output for a test script +# +# It is important that you verify that the generated +# output is correct! +# + +for i in $argv + set template_out (basename $i .in).out + set template_err (basename $i .in).err + set template_status (basename $i .in).status + + fish <$i >$template_out ^$template_err + echo $status >$template_status +end
\ No newline at end of file diff --git a/tests/test.fish b/tests/test.fish new file mode 100755 index 00000000..082db468 --- /dev/null +++ b/tests/test.fish @@ -0,0 +1,42 @@ +#!/usr/local/bin/fish +# +# Main loop of the test suite. I wrote this +# instad of using autotest to provide additional +# testing for fish. :-) + +echo Testing high level script functionality + +for i in *.in + set template_out (basename $i .in).out + set template_err (basename $i .in).err + set template_status (basename $i .in).status + + ../fish <$i >tmp.out ^tmp.err + echo $status >tmp.status + set res ok + if diff tmp.out $template_out >/dev/null + else + set res fail + echo Output differs for file $i + end + + if diff tmp.err $template_err >/dev/null + else + set res fail + echo Error output differs for file $i + end + + if test (cat tmp.status) = (cat $template_status) + else + set res fail + echo Exit status differs for file $i + end + + if test $res = ok; + echo File $i tested ok + else + echo File $i failed tests + end; + +end + diff --git a/tests/test1.err b/tests/test1.err new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/test1.err diff --git a/tests/test1.in b/tests/test1.in new file mode 100644 index 00000000..5b87fb71 --- /dev/null +++ b/tests/test1.in @@ -0,0 +1,53 @@ +# +#Test aliases loops and conditionals +# + +for i in 1 2 #Comment on same line as command +#Comment inside loop + for j in a b + #Double loop + echo $i$j + end; +end + +# Simple alias tests + +function foo + echo >foo.txt $argv +end + +foo hello + +cat foo.txt |read foo + +if test $foo = hello; + echo Test 2 pass +else + echo Test 2 fail +end + +function foo + printf 'Test %s' $1; echo ' pass' +end + +foo 3 + +for i in Test for continue break and switch builtins problems; + switch $i + case Test + printf "%s " $i + case "f??" + printf "%s " 3 + case "c*" + echo pass + case break + continue + echo fail + case and + break + echo fail + case "*" + echo fail + end +end + diff --git a/tests/test1.out b/tests/test1.out new file mode 100644 index 00000000..64b65faa --- /dev/null +++ b/tests/test1.out @@ -0,0 +1,7 @@ +1a +1b +2a +2b +Test 2 pass +Test pass +Test 3 pass diff --git a/tests/test1.status b/tests/test1.status new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/tests/test1.status @@ -0,0 +1 @@ +0 diff --git a/tests/test2.err b/tests/test2.err new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/test2.err diff --git a/tests/test2.in b/tests/test2.in new file mode 100644 index 00000000..a0c7ecbd --- /dev/null +++ b/tests/test2.in @@ -0,0 +1,6 @@ +#Tests complex parameter expantions + +set a A +set aa AA +set aaa AAA +echo {$aa}a{1,2,3}(for a in 1 2 3; echo $a; end) diff --git a/tests/test2.out b/tests/test2.out new file mode 100644 index 00000000..e1af6063 --- /dev/null +++ b/tests/test2.out @@ -0,0 +1 @@ +AAa11 AAa21 AAa31 AAa12 AAa22 AAa32 AAa13 AAa23 AAa33 diff --git a/tests/test2.status b/tests/test2.status new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/tests/test2.status @@ -0,0 +1 @@ +0 diff --git a/tests/test3.err b/tests/test3.err new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/test3.err diff --git a/tests/test3.in b/tests/test3.in new file mode 100644 index 00000000..3fccaa03 --- /dev/null +++ b/tests/test3.in @@ -0,0 +1,113 @@ +# Environment variable tests + +#Test if variables can be properly set + +set smurf blue + +if test $smurf = blue + echo Test 1 pass +else + echo Test 1 fail +end + +# Test if variables can be erased + +set -e smurf + +if test $smurf + echo Test 2 fail +else + echo Test 2 pass +end + +# Test if local variables go out of scope + +if true + set t3 bar +end + +if test $t3 + echo Test 3 fail +else + echo Test 3 pass +end + +# Test if globals can be set in block scope + +if true + set -g baz qux +end + +if test $baz = qux + echo Test 4 pass +else + echo Test 4 fail +end + + +#Test that scope is preserved when setting a new value + +set t5 a + +if true + set t5 b +end + +if test $t5 = b + echo Test 5 pass +else + echo Test 5 fail +end + +# Test that scope is preserved in double blocks + +for i in 1 + set t6 $i + for j in a + if test $t6$j = 1a + echo Test 6 pass + else + echo Test 6 fail + end + end +end + + +# Test if variables in for loop blocks do not go out of scope on new laps + +set res fail + +for i in 1 2 + set t7 + if test $i = 1 + set t7 b + else + if test $t7 = b + set res pass + end + end +end + +echo Test 7 $res + +# Test if variables are properly exported + +if true + set -x t8 foo + if test (fish -c "echo $t8") = foo + echo Test 8 pass + else + echo Test 8 fail + end +end + +# Test if exported variables go out of scope + +if test (fish -c "echo $t8") = foo + echo Test 9 fail +else + echo Test 9 pass +end + + + diff --git a/tests/test3.out b/tests/test3.out new file mode 100644 index 00000000..9ae93fd4 --- /dev/null +++ b/tests/test3.out @@ -0,0 +1,9 @@ +Test 1 pass +Test 2 pass +Test 3 pass +Test 4 pass +Test 5 pass +Test 6 pass +Test 7 pass +Test 8 pass +Test 9 pass diff --git a/tests/test3.status b/tests/test3.status new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/tests/test3.status @@ -0,0 +1 @@ +0 diff --git a/tests/test4.err b/tests/test4.err new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/test4.err diff --git a/tests/test4.in b/tests/test4.in new file mode 100644 index 00000000..75c2c7ec --- /dev/null +++ b/tests/test4.in @@ -0,0 +1,35 @@ +#Test scoping rules for functions + +set -e smurf + +function setter +set smurf green +end + +function unsetter +set -e smurf +end + +function call1 +set smurf blue; setter; if test $smurf = blue; echo Test 1 pass; else; echo Test 1 fail; end +end + +function call2 +set smurf blue; unsetter; if test $smurf = blue; echo Test 2 pass; else; echo Test 2 fail; end +end + +call1 +call2 + +function call3 +setter; if test $smurf = green; echo Test 3 pass; else; echo Test 3 fail; end +end + +function call4 +unsetter; if test !$smurf; echo Test 4 pass; else; echo Test 4 fail; end +end + +set -g smurf yellow +call3 +call4 + diff --git a/tests/test4.out b/tests/test4.out new file mode 100644 index 00000000..3c2d17b6 --- /dev/null +++ b/tests/test4.out @@ -0,0 +1,4 @@ +Test 1 pass +Test 2 pass +Test 3 pass +Test 4 fail diff --git a/tests/test4.status b/tests/test4.status new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/tests/test4.status @@ -0,0 +1 @@ +0 diff --git a/tests/test5.err b/tests/test5.err new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/test5.err diff --git a/tests/test5.in b/tests/test5.in new file mode 100644 index 00000000..a3e2256c --- /dev/null +++ b/tests/test5.in @@ -0,0 +1,25 @@ + +set smurf green + +switch $smurf; + case "*ee*" + echo Test 1 pass + case "*" + echo Test 1 fail +end; + +switch $smurf + case *ee* + echo Test 2 fail + case red green blue + echo Test 2 pass + case "*" + echo Test 2 fail +end + +switch $smurf + case cyan magenta yellow + echo Test 3 fail + case "?????" + echo Test 3 pass +end diff --git a/tests/test5.out b/tests/test5.out new file mode 100644 index 00000000..66343bb8 --- /dev/null +++ b/tests/test5.out @@ -0,0 +1,3 @@ +Test 1 pass +Test 2 pass +Test 3 pass diff --git a/tests/test5.status b/tests/test5.status new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/tests/test5.status @@ -0,0 +1 @@ +0 |