diff --git a/tests/test.test b/tests/test.test index 02225662..300a72b2 100644 --- a/tests/test.test +++ b/tests/test.test @@ -122,9 +122,14 @@ testcmd "-ef link" "newfile -ef samefile && echo yes" "yes\n" "" "" testcmd "-ef2" "newfile -ef oldfile || echo no" "no\n" "" "" testcmd "-ot" "oldfile -ot newfile && echo yes" "yes\n" "" "" testcmd "-ot2" "oldfile -ot oldfile || echo no" "no\n" "" "" +testcmd "-ot3" "none -ot oldfile && echo yes" "yes\n" "" "" +testcmd "-ot4" "oldfile -ot none || echo no" "no\n" "" "" +testcmd "-ot5" "none -ot none || echo no" "no\n" "" "" testcmd "-nt" "newfile -nt oldfile && echo yes" "yes\n" "" "" testcmd "-nt2" "oldfile -nt newfile || echo no" "no\n" "" "" -testcmd "-nt2" "oldfile -nt newfile || echo no" "no\n" "" "" +testcmd "-nt3" "none -nt newfile || echo no" "no\n" "" "" +testcmd "-nt4" "oldfile -nt none && echo yes" "yes\n" "" "" +testcmd "-nt5" "none -nt none || echo no" "no\n" "" "" testing "positional" "test -a == -a && echo yes" "yes\n" "" "" testing "! stacks" 'test \! \! \! \! 2 -eq 2 && echo yes' "yes\n" "" "" diff --git a/toys/posix/test.c b/toys/posix/test.c index 2fda1718..6480e5c7 100644 --- a/toys/posix/test.c +++ b/toys/posix/test.c @@ -87,8 +87,11 @@ static int do_test(char **args, int *count) a = atolx(args[0]); b = atolx(args[2]); } else { - if ((i == 12 ? stat : lstat)(args[0], &st1) - || (i == 12 ? stat : lstat)(args[2], &st2)) return 0; + int j = (i == 12 ? stat : lstat)(args[0], &st1), + k = (i == 12 ? stat : lstat)(args[2], &st2); + + // "does not exist" is always older than existing file + if (j || k) return (i<14) ? 0 : i==16 ? j>k : j