From ca527165aae1388a483cc96c57e17600bfd8d313 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Fri, 9 May 2014 02:14:34 -0400 Subject: [PATCH] Added _bail_clause shorthand There will be a test for bailing on output's clause shortly, now that we can assert on output...testing itself. --- src/expect-core | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/expect-core b/src/expect-core index e25a29a..cf4fe10 100644 --- a/src/expect-core +++ b/src/expect-core @@ -23,6 +23,17 @@ __INC_EXPECT_CORE=1 +## +# Shorthand for bailing out on unrecognized clauses +_bail_clause() +{ + local -r type="$1" + local -r clause="$2" + + _bail "unrecognized \`$type' clause: \`$2'" +} + + _expect--succeed() { test "$1" -eq 0; } _expect--fail() { test "$1" -ne 0; } @@ -36,7 +47,7 @@ _expect--output() if [ -n "$clause" ]; then [ "$clause" == 'without newline' ] \ && nl=-n \ - || _bail "unrecognized output clause: $clause" + || _bail_clause output "$clause" fi # we will eventually be interested in this output