From 2dfc85245f240d2ed32fa0c9694c185b8b8b4646 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sat, 13 Apr 2019 17:17:57 -0500 Subject: [PATCH] Add regression tests for `eval` --- tests/eval.err | 13 +++++++++++++ tests/eval.in | 33 +++++++++++++++++++++++++++++++++ tests/eval.out | 15 +++++++++++++++ tests/eval_scope.err | 0 tests/eval_scope.in | 3 --- tests/eval_scope.out | 1 - 6 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 tests/eval.err create mode 100644 tests/eval.in create mode 100644 tests/eval.out delete mode 100644 tests/eval_scope.err delete mode 100644 tests/eval_scope.in delete mode 100644 tests/eval_scope.out diff --git a/tests/eval.err b/tests/eval.err new file mode 100644 index 000000000..3e02f001c --- /dev/null +++ b/tests/eval.err @@ -0,0 +1,13 @@ + +#################### +# Testing eval builtin +fish: Unexpected end of string, expecting ')' +( +^ + +fish: The expanded command was empty. +"" +^ + +#################### +# Testing eval with empty functions, blocks, and arguments diff --git a/tests/eval.in b/tests/eval.in new file mode 100644 index 000000000..3008803d4 --- /dev/null +++ b/tests/eval.in @@ -0,0 +1,33 @@ +logmsg "Testing eval builtin" + +# Regression test for issue #4443 +eval set -l previously_undefined foo +echo $previously_undefined + +# Test redirection +eval "echo you can\\'t see this 1>&2" 2>/dev/null + +# Test return statuses +false; eval true; echo $status # 0 +false; eval false; echo $status # 1 + +# Test return status in case of parsing error +false; eval "("; echo $status # 1 +false; eval '""'; echo $status # 1 + +function empty +end + +# Regression tests for issue #5692 +logmsg "Testing eval with empty functions, blocks, and arguments" +false; eval; +echo blank eval: $status # 0 + +false; eval ""; +echo empty arg eval: $status # 0 + +false; eval empty; +echo empty function eval $status # 0 + +false; eval "begin; end;"; +echo empty block eval: $status # 0 diff --git a/tests/eval.out b/tests/eval.out new file mode 100644 index 000000000..6cba274e2 --- /dev/null +++ b/tests/eval.out @@ -0,0 +1,15 @@ + +#################### +# Testing eval builtin +foo +0 +1 +1 +1 + +#################### +# Testing eval with empty functions, blocks, and arguments +blank eval: 0 +empty arg eval: 0 +empty function eval 0 +empty block eval: 0 diff --git a/tests/eval_scope.err b/tests/eval_scope.err deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/eval_scope.in b/tests/eval_scope.in deleted file mode 100644 index b5b89b7c0..000000000 --- a/tests/eval_scope.in +++ /dev/null @@ -1,3 +0,0 @@ -# Regression test for issue #4443 -eval set -l previously_undefined foo -echo $previously_undefined diff --git a/tests/eval_scope.out b/tests/eval_scope.out deleted file mode 100644 index 257cc5642..000000000 --- a/tests/eval_scope.out +++ /dev/null @@ -1 +0,0 @@ -foo