From 03cdf89bfd64e8c93e0dfd491715eb2cf35b6566 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 13 Jan 2019 18:57:38 -0600 Subject: [PATCH] Add tests for `$status` after `while` in various scenarios Includes a regression test for #5513 and asserts the behavior defined in \#4982. --- tests/while.err | 0 tests/while.in | 27 +++++++++++++++++++++++++++ tests/while.out | 3 +++ 3 files changed, 30 insertions(+) create mode 100644 tests/while.err create mode 100644 tests/while.in create mode 100644 tests/while.out diff --git a/tests/while.err b/tests/while.err new file mode 100644 index 000000000..e69de29bb diff --git a/tests/while.in b/tests/while.in new file mode 100644 index 000000000..95cb2584c --- /dev/null +++ b/tests/while.in @@ -0,0 +1,27 @@ +# vim: set ft=fish: + +function never_runs + while false + end +end + +function early_return + while true + return 2 + end +end + +function runs_once + set -l i 1 + while test $i -ne 0 && set i (math $i - 1) + end +end + +# this should return 1 +never_runs; echo $status + +# this should return 0 +runs_once; echo $status + +# this should return 2 +early_return; echo $status diff --git a/tests/while.out b/tests/while.out new file mode 100644 index 000000000..56f24a18d --- /dev/null +++ b/tests/while.out @@ -0,0 +1,3 @@ +1 +0 +2