From 9d711f14a22d93e73a6d965816ad894e5ef14e89 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Tue, 13 May 2014 00:56:32 -0400 Subject: [PATCH] Added `aok' silent tests --- src/util | 4 ++-- test/test-util | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/util b/src/util index 333eb38..a357190 100644 --- a/src/util +++ b/src/util @@ -42,7 +42,7 @@ aok() local -i i="${#arr[@]}" while ((i--)); do - test "${arr[i]}" -eq 0 || return 1 - done + test "${arr[i]}" -eq 0 || return + done &>/dev/null } diff --git a/test/test-util b/test/test-util index 0862915..60783ef 100644 --- a/test/test-util +++ b/test/test-util @@ -23,38 +23,48 @@ describe aok it succeeds for all zero values expect aok 0 to succeed + and to be silent expect aok 0 0 0 to succeed + and to be silent end it fails for any zero values expect aok 1 to fail + and to be silent expect aok 1 0 0 to fail + and to be silent expect aok 0 1 0 to fail + and to be silent expect aok 0 0 1 to fail + and to be silent expect aok 1 1 1 to fail + and to be silent end # this surely implies a bug in the user's code it fails for any non-numeric values expect aok foo to fail + and to be silent expect aok 0 foo to fail + and to be silent expect aok foo 0 to fail + and to be silent end end