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 tests for the &&, || an...



details:   https://anonhg.NetBSD.org/src/rev/795557465d5d
branches:  trunk
changeset: 975412:795557465d5d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 28 14:48:37 2020 +0000

description:
make(1): add tests for the &&, || and ! operators

diffstat:

 usr.bin/make/unit-tests/cond-op-and.mk |  23 +++++++++++++++++++++--
 usr.bin/make/unit-tests/cond-op-not.mk |  18 ++++++++++++++++--
 usr.bin/make/unit-tests/cond-op-or.mk  |  23 +++++++++++++++++++++--
 3 files changed, 58 insertions(+), 6 deletions(-)

diffs (94 lines):

diff -r 8591ffe09e3a -r 795557465d5d usr.bin/make/unit-tests/cond-op-and.mk
--- a/usr.bin/make/unit-tests/cond-op-and.mk    Fri Aug 28 14:18:29 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-op-and.mk    Fri Aug 28 14:48:37 2020 +0000
@@ -1,8 +1,27 @@
-# $NetBSD: cond-op-and.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: cond-op-and.mk,v 1.3 2020/08/28 14:48:37 rillig Exp $
 #
 # Tests for the && operator in .if conditions.
 
-# TODO: Implementation
+.if 0 && 0
+.error
+.endif
+
+.if 1 && 0
+.error
+.endif
+
+.if 0 && 1
+.error
+.endif
+
+.if !(1 && 1)
+.error
+.endif
+
+# The right-hand side is not evaluated since the left-hand side is already
+# false.
+.if 0 && ${UNDEF}
+.endif
 
 all:
        @:;
diff -r 8591ffe09e3a -r 795557465d5d usr.bin/make/unit-tests/cond-op-not.mk
--- a/usr.bin/make/unit-tests/cond-op-not.mk    Fri Aug 28 14:18:29 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-op-not.mk    Fri Aug 28 14:48:37 2020 +0000
@@ -1,8 +1,22 @@
-# $NetBSD: cond-op-not.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: cond-op-not.mk,v 1.3 2020/08/28 14:48:37 rillig Exp $
 #
 # Tests for the ! operator in .if conditions.
 
-# TODO: Implementation
+# The exclamation mark negates its operand.
+.if !1
+.error
+.endif
+
+# Exclamation marks can be chained.
+# This doesn't happen in practice though.
+.if !!!1
+.error
+.endif
+
+# The ! binds more tightly than the &&.
+.if !!0 && 1
+.error
+.endif
 
 all:
        @:;
diff -r 8591ffe09e3a -r 795557465d5d usr.bin/make/unit-tests/cond-op-or.mk
--- a/usr.bin/make/unit-tests/cond-op-or.mk     Fri Aug 28 14:18:29 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-op-or.mk     Fri Aug 28 14:48:37 2020 +0000
@@ -1,8 +1,27 @@
-# $NetBSD: cond-op-or.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: cond-op-or.mk,v 1.3 2020/08/28 14:48:37 rillig Exp $
 #
 # Tests for the || operator in .if conditions.
 
-# TODO: Implementation
+.if 0 || 0
+.error
+.endif
+
+.if !(1 || 0)
+.error
+.endif
+
+.if !(0 || 1)
+.error
+.endif
+
+.if !(1 || 1)
+.error
+.endif
+
+# The right-hand side is not evaluated since the left-hand side is already
+# true.
+.if 1 || ${UNDEF}
+.endif
 
 all:
        @:;



Home | Main Index | Thread Index | Old Index