xref: /freebsd/contrib/bmake/unit-tests/directive-else.mk (revision 148ee84570001f46b7b667c86573d378101c3801)
1# $NetBSD: directive-else.mk,v 1.8 2023/06/01 20:56:35 rillig Exp $
2#
3# Tests for the .else directive.
4#
5# Since 2020-11-13, an '.else' followed by extraneous text generates a parse
6# error in -dL (lint) mode.
7#
8# Since 2020-12-15, an '.else' followed by extraneous text always generates
9# a parse error.
10
11.if 0
12.  warning must not be reached
13# expect+1: The .else directive does not take arguments
14.else 123
15# expect+1: ok
16.  info ok
17.endif
18
19.if 1
20# expect+1: ok
21.  info ok
22# expect+1: The .else directive does not take arguments
23.else 123
24.  warning must not be reached
25.endif
26
27# An .else without a corresponding .if is an error.
28# expect+1: if-less else
29.else
30
31# Accidental extra .else directives are detected too.
32.if 0
33.  warning must not be reached
34.else
35# expect+1: ok
36.  info ok
37# expect+1: warning: extra else
38.else
39.  info After an extra .else, everything is skipped.
40.endif
41
42# An .else may have a comment.  This comment does not count as an argument,
43# therefore no parse error.
44.if 0
45.else # comment
46.endif
47
48# A variable expression does count as an argument, even if it is empty.
49.if 0
50# expect+1: The .else directive does not take arguments
51.else ${:U}
52.endif
53
54all:
55	@:;
56