Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make/unit-tests make(1): add test for operator prece...
details: https://anonhg.NetBSD.org/src/rev/407f3256bf7a
branches: trunk
changeset: 957064:407f3256bf7a
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 15 14:04:26 2020 +0000
description:
make(1): add test for operator precedence using truth tables
diffstat:
usr.bin/make/unit-tests/cond-op.exp | 9 +++++++++
usr.bin/make/unit-tests/cond-op.mk | 18 +++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletions(-)
diffs (50 lines):
diff -r 00ecaae65997 -r 407f3256bf7a usr.bin/make/unit-tests/cond-op.exp
--- a/usr.bin/make/unit-tests/cond-op.exp Sun Nov 15 14:01:06 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-op.exp Sun Nov 15 14:04:26 2020 +0000
@@ -2,6 +2,15 @@
make: "cond-op.mk" line 70: Malformed conditional (0 ${ERR::=evaluated})
make: "cond-op.mk" line 74: warning: After detecting a parse error, the rest is evaluated.
make: "cond-op.mk" line 78: Parsing continues until here.
+make: "cond-op.mk" line 81: A B C => (A || B) && C A || B && C A || (B && C)
+make: "cond-op.mk" line 88: 0 0 0 => 0 0 0
+make: "cond-op.mk" line 88: 0 0 1 => 0 0 0
+make: "cond-op.mk" line 88: 0 1 0 => 0 0 0
+make: "cond-op.mk" line 88: 0 1 1 => 1 1 1
+make: "cond-op.mk" line 88: 1 0 0 => 0 1 1
+make: "cond-op.mk" line 88: 1 0 1 => 1 1 1
+make: "cond-op.mk" line 88: 1 1 0 => 0 1 1
+make: "cond-op.mk" line 88: 1 1 1 => 1 1 1
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
diff -r 00ecaae65997 -r 407f3256bf7a usr.bin/make/unit-tests/cond-op.mk
--- a/usr.bin/make/unit-tests/cond-op.mk Sun Nov 15 14:01:06 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-op.mk Sun Nov 15 14:04:26 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.8 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.9 2020/11/15 14:04:26 rillig Exp $
#
# Tests for operators like &&, ||, ! in .if conditions.
#
@@ -77,5 +77,21 @@
# Just in case that parsing should ever stop on the first error.
.info Parsing continues until here.
+# Demonstration that '&&' has higher precedence than '||'.
+.info A B C => (A || B) && C A || B && C A || (B && C)
+.for a in 0 1
+. for b in 0 1
+. for c in 0 1
+. for r1 in ${ ($a || $b) && $c :?1:0}
+. for r2 in ${ $a || $b && $c :?1:0}
+. for r3 in ${ $a || ($b && $c) :?1:0}
+. info $a $b $c => ${r1} ${r2} ${r3}
+. endfor
+. endfor
+. endfor
+. endfor
+. endfor
+.endfor
+
all:
@:;
Home |
Main Index |
Thread Index |
Old Index