Module Name:    src
Committed By:   rillig
Date:           Fri Aug 28 14:48:38 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: cond-op-and.mk cond-op-not.mk
            cond-op-or.mk

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


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-op-and.mk \
    src/usr.bin/make/unit-tests/cond-op-not.mk \
    src/usr.bin/make/unit-tests/cond-op-or.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/cond-op-and.mk
diff -u src/usr.bin/make/unit-tests/cond-op-and.mk:1.2 src/usr.bin/make/unit-tests/cond-op-and.mk:1.3
--- src/usr.bin/make/unit-tests/cond-op-and.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/cond-op-and.mk	Fri Aug 28 14:48:37 2020
@@ -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:
 	@:;
Index: src/usr.bin/make/unit-tests/cond-op-not.mk
diff -u src/usr.bin/make/unit-tests/cond-op-not.mk:1.2 src/usr.bin/make/unit-tests/cond-op-not.mk:1.3
--- src/usr.bin/make/unit-tests/cond-op-not.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/cond-op-not.mk	Fri Aug 28 14:48:37 2020
@@ -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:
 	@:;
Index: src/usr.bin/make/unit-tests/cond-op-or.mk
diff -u src/usr.bin/make/unit-tests/cond-op-or.mk:1.2 src/usr.bin/make/unit-tests/cond-op-or.mk:1.3
--- src/usr.bin/make/unit-tests/cond-op-or.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/cond-op-or.mk	Fri Aug 28 14:48:37 2020
@@ -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:
 	@:;

Reply via email to