From bcbdf3f2c90897769394d6d0d23e7714ec471d4f Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 20 Jul 2017 23:42:06 -0400 Subject: eval: Add some sanity checks --- eval.c | 6 ++++++ tests.sh | 10 ++++++++++ tests/test_false.out | 0 tests/test_true.out | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 tests/test_false.out create mode 100644 tests/test_true.out diff --git a/eval.c b/eval.c index b095279..34ccba8 100644 --- a/eval.c +++ b/eval.c @@ -858,6 +858,8 @@ static bool eval_expr(struct expr *expr, struct eval_state *state) { } } + assert(!*state->quit); + bool ret = expr->eval(expr, state); if (time) { @@ -871,6 +873,10 @@ static bool eval_expr(struct expr *expr, struct eval_state *state) { ++expr->successes; } + assert(!expr->always_true || ret); + assert(!expr->always_false || !ret); + assert(!expr->never_returns || *state->quit); + return ret; } diff --git a/tests.sh b/tests.sh index 0e337bd..f0ada64 100755 --- a/tests.sh +++ b/tests.sh @@ -259,6 +259,8 @@ bsd_tests=( ) gnu_tests=( + test_true + test_false test_executable test_readable test_writable @@ -528,6 +530,14 @@ function test_path() { bfs_diff basic -path 'basic/*f*' } +function test_true() { + bfs_diff basic -true +} + +function test_false() { + bfs_diff basic -false +} + function test_executable() { bfs_diff perms -executable } diff --git a/tests/test_false.out b/tests/test_false.out new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_true.out b/tests/test_true.out new file mode 100644 index 0000000..bb3cd8d --- /dev/null +++ b/tests/test_true.out @@ -0,0 +1,19 @@ +basic +basic/a +basic/b +basic/c +basic/e +basic/g +basic/i +basic/j +basic/k +basic/l +basic/c/d +basic/e/f +basic/g/h +basic/j/foo +basic/k/foo +basic/l/foo +basic/k/foo/bar +basic/l/foo/bar +basic/l/foo/bar/baz -- cgit v1.2.3