diff options
| author | rillig <rillig@NetBSD.org> | 2021-01-19 17:49:13 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2021-01-19 17:49:13 +0000 |
| commit | c5cdcf83d6bd6a67cd29d4c3da03cf6eb794dde3 (patch) | |
| tree | 9d0ac8e86e2c004d7a83902961245518866844f9 /usr.bin/make/unit-tests | |
| parent | 8a82e20990b297064df0445b283a2c9103b7cb10 (diff) | |
make(1): demonstrate wrong return value in CondParser_Term
Diffstat (limited to 'usr.bin/make/unit-tests')
| -rw-r--r-- | usr.bin/make/unit-tests/cond-op-not.exp | 5 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/cond-op-not.mk | 9 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/cond-op-parentheses.exp | 6 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/cond-op-parentheses.mk | 19 |
4 files changed, 35 insertions, 4 deletions
diff --git a/usr.bin/make/unit-tests/cond-op-not.exp b/usr.bin/make/unit-tests/cond-op-not.exp index 37f57b7fdfa..440670ca724 100644 --- a/usr.bin/make/unit-tests/cond-op-not.exp +++ b/usr.bin/make/unit-tests/cond-op-not.exp @@ -3,4 +3,7 @@ make: "cond-op-not.mk" line 37: Not space evaluates to false. make: "cond-op-not.mk" line 41: Not 0 evaluates to true. make: "cond-op-not.mk" line 49: Not 1 evaluates to false. make: "cond-op-not.mk" line 55: Not word evaluates to false. -exit status 0 +make: "cond-op-not.mk" line 59: Malformed conditional (!) +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 diff --git a/usr.bin/make/unit-tests/cond-op-not.mk b/usr.bin/make/unit-tests/cond-op-not.mk index 388c62d8898..ffd5bc89e4b 100644 --- a/usr.bin/make/unit-tests/cond-op-not.mk +++ b/usr.bin/make/unit-tests/cond-op-not.mk @@ -1,4 +1,4 @@ -# $NetBSD: cond-op-not.mk,v 1.6 2020/11/15 14:58:14 rillig Exp $ +# $NetBSD: cond-op-not.mk,v 1.7 2021/01/19 17:49:13 rillig Exp $ # # Tests for the ! operator in .if conditions, which negates its argument. @@ -55,5 +55,12 @@ . info Not word evaluates to false. .endif +# A single exclamation mark is a parse error. +.if ! +. error +.else +. error +.endif + all: @:; diff --git a/usr.bin/make/unit-tests/cond-op-parentheses.exp b/usr.bin/make/unit-tests/cond-op-parentheses.exp index a0fa137af4c..b4409330410 100644 --- a/usr.bin/make/unit-tests/cond-op-parentheses.exp +++ b/usr.bin/make/unit-tests/cond-op-parentheses.exp @@ -1,2 +1,6 @@ make: "cond-op-parentheses.mk" line 13: Parentheses can be nested at least to depth 112. -exit status 0 +make: "cond-op-parentheses.mk" line 19: Malformed conditional (() +make: "cond-op-parentheses.mk" line 29: Malformed conditional ()) +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 diff --git a/usr.bin/make/unit-tests/cond-op-parentheses.mk b/usr.bin/make/unit-tests/cond-op-parentheses.mk index 39ebc160745..ca288cad582 100644 --- a/usr.bin/make/unit-tests/cond-op-parentheses.mk +++ b/usr.bin/make/unit-tests/cond-op-parentheses.mk @@ -1,4 +1,4 @@ -# $NetBSD: cond-op-parentheses.mk,v 1.3 2020/11/15 14:58:14 rillig Exp $ +# $NetBSD: cond-op-parentheses.mk,v 1.4 2021/01/19 17:49:13 rillig Exp $ # # Tests for parentheses in .if conditions. @@ -15,5 +15,22 @@ . error .endif +# An unbalanced opening parenthesis is a parse error. +.if ( +. error +.else +. error +.endif + +# An unbalanced closing parenthesis is a parse error. +# +# As of 2021-01-19, CondParser_Term returned TOK_RPAREN even though this +# function promised to only ever return TOK_TRUE, TOK_FALSE or TOK_ERROR. +.if ) +. error +.else +. error +.endif + all: @:; |
