From f7d0c4b065cb6a282a5e3d164bdcc5fc4a7e8b8e Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Thu, 21 Jun 2012 19:09:45 -0700 Subject: [PATCH] Add a test case for switch error code (issue #161) --- tests/test7.err | 0 tests/test7.in | 30 ++++++++++++++++++++++++++++++ tests/test7.out | 7 +++++++ tests/test7.status | 1 + tests/top.out | 2 ++ 5 files changed, 40 insertions(+) create mode 100644 tests/test7.err create mode 100644 tests/test7.in create mode 100644 tests/test7.out create mode 100644 tests/test7.status diff --git a/tests/test7.err b/tests/test7.err new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test7.in b/tests/test7.in new file mode 100644 index 000000000..1ad65648d --- /dev/null +++ b/tests/test7.in @@ -0,0 +1,30 @@ +# Test that subsequent cases do not blow away the status from previous ones +for val in one two three four + switch $val + case one + /bin/sh -c 'exit 1' + case two + /bin/sh -c 'exit 2' + case three + /bin/sh -c 'exit 3' + end + echo $status +end + +echo + +# Test that the `switch` builtin itself does not blow away status before evaluating a case +false +switch one +case one + echo $status +end + +# Test that non-case tokens inside `switch` don't blow away status +# (why are these even allowed?) +false +switch one +true +case one + echo $status +end diff --git a/tests/test7.out b/tests/test7.out new file mode 100644 index 000000000..c298309df --- /dev/null +++ b/tests/test7.out @@ -0,0 +1,7 @@ +1 +2 +3 +0 + +1 +1 diff --git a/tests/test7.status b/tests/test7.status new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/test7.status @@ -0,0 +1 @@ +0 diff --git a/tests/top.out b/tests/top.out index c3a60ba61..5614a6619 100644 --- a/tests/top.out +++ b/tests/top.out @@ -4,3 +4,5 @@ File test2.in tested ok File test3.in tested ok File test4.in tested ok File test5.in tested ok +File test6.in tested ok +File test7.in tested ok