Home | History | Annotate | Line # | Download | only in unit-tests
moderrs.mk revision 1.31.2.1
      1  1.31.2.1  perseant # $NetBSD: moderrs.mk,v 1.31.2.1 2024/07/01 01:01:15 perseant Exp $
      2       1.1       apb #
      3       1.1       apb # various modifier error tests
      4       1.1       apb 
      5      1.17    rillig VAR=		TheVariable
      6      1.18    rillig # in case we have to change it ;-)
      7      1.17    rillig MOD_UNKN=	Z
      8      1.17    rillig MOD_TERM=	S,V,v
      9      1.17    rillig MOD_S:=		${MOD_TERM},
     10       1.1       apb 
     11       1.7    rillig FIB=	1 1 2 3 5 8 13 21 34
     12       1.7    rillig 
     13      1.21    rillig all:	mod-unknown-direct mod-unknown-indirect
     14      1.21    rillig all:	unclosed-direct unclosed-indirect
     15      1.21    rillig all:	unfinished-indirect unfinished-loop
     16      1.21    rillig all:	loop-close
     17      1.21    rillig all:	words
     18      1.21    rillig all:	exclam
     19       1.6    rillig all:	mod-subst-delimiter
     20       1.7    rillig all:	mod-regex-delimiter
     21       1.7    rillig all:	mod-ts-parse
     22       1.7    rillig all:	mod-t-parse
     23       1.7    rillig all:	mod-ifelse-parse
     24       1.7    rillig all:	mod-remember-parse
     25       1.7    rillig all:	mod-sysv-parse
     26       1.1       apb 
     27  1.31.2.1  perseant mod-unknown-direct: print-footer
     28  1.31.2.1  perseant # expect: make: in target "mod-unknown-direct": while evaluating variable "VAR": Unknown modifier "Z"
     29      1.23    rillig 	@echo 'VAR:Z=before-${VAR:Z}-after'
     30       1.1       apb 
     31  1.31.2.1  perseant mod-unknown-indirect: print-footer
     32  1.31.2.1  perseant # expect: make: in target "mod-unknown-indirect": while evaluating variable "VAR": Unknown modifier "Z"
     33      1.23    rillig 	@echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after'
     34       1.1       apb 
     35      1.21    rillig unclosed-direct: print-header print-footer
     36  1.31.2.1  perseant # expect: make: Unclosed expression, expecting '}' for modifier "S,V,v," of variable "VAR" with value "Thevariable"
     37       1.1       apb 	@echo VAR:S,V,v,=${VAR:S,V,v,
     38       1.1       apb 
     39      1.21    rillig unclosed-indirect: print-header print-footer
     40  1.31.2.1  perseant # expect: make: Unclosed expression after indirect modifier, expecting '}' for variable "VAR"
     41       1.1       apb 	@echo VAR:${MOD_TERM},=${VAR:${MOD_S}
     42       1.1       apb 
     43  1.31.2.1  perseant unfinished-indirect: print-footer
     44  1.31.2.1  perseant # expect: make: in target "unfinished-indirect": while evaluating variable "VAR": Unfinished modifier (',' missing)
     45       1.1       apb 	-@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}"
     46       1.2    rillig 
     47  1.31.2.1  perseant unfinished-loop: print-footer
     48  1.31.2.1  perseant # expect: make: in target "unfinished-loop": while evaluating variable "UNDEF": Unfinished modifier ('@' missing)
     49       1.2    rillig 	@echo ${UNDEF:U1 2 3:@var}
     50  1.31.2.1  perseant # expect: make: in target "unfinished-loop": while evaluating variable "UNDEF": Unfinished modifier ('@' missing)
     51       1.2    rillig 	@echo ${UNDEF:U1 2 3:@var (a] ...}
     52       1.2    rillig 	@echo ${UNDEF:U1 2 3:@var@${var}@}
     53       1.3    rillig 
     54       1.5    rillig # The closing brace after the ${var} is part of the replacement string.
     55       1.5    rillig # In ParseModifierPart, braces and parentheses don't have to be balanced.
     56       1.5    rillig # This is contrary to the :M, :N modifiers, where both parentheses and
     57       1.5    rillig # braces must be balanced.
     58       1.5    rillig # This is also contrary to the SysV modifier, where only the actually
     59       1.5    rillig # used delimiter (either braces or parentheses) must be balanced.
     60      1.21    rillig loop-close: print-header print-footer
     61  1.31.2.1  perseant # expect: make: Unclosed expression, expecting '}' for modifier "@var@${var}}...@" of variable "UNDEF" with value "1}... 2}... 3}..."
     62       1.5    rillig 	@echo ${UNDEF:U1 2 3:@var@${var}}...@
     63       1.5    rillig 	@echo ${UNDEF:U1 2 3:@var@${var}}...@}
     64       1.5    rillig 
     65  1.31.2.1  perseant words: print-footer
     66  1.31.2.1  perseant # expect: make: in target "words": while evaluating variable "UNDEF": Unfinished modifier (']' missing)
     67       1.3    rillig 	@echo ${UNDEF:U1 2 3:[}
     68  1.31.2.1  perseant # expect: make: in target "words": while evaluating variable "UNDEF": Unfinished modifier (']' missing)
     69       1.3    rillig 	@echo ${UNDEF:U1 2 3:[#}
     70       1.3    rillig 
     71       1.3    rillig 	# out of bounds => empty
     72       1.3    rillig 	@echo 13=${UNDEF:U1 2 3:[13]}
     73       1.3    rillig 
     74       1.3    rillig 	# Word index out of bounds.
     75       1.3    rillig 	#
     76      1.24    rillig 	# Until 2020-11-01, the behavior in this case depended upon the size
     77      1.24    rillig 	# of unsigned long.
     78       1.3    rillig 	#
     79      1.24    rillig 	# On LP64I32, strtol returns LONG_MAX, which was then truncated to
     80      1.24    rillig 	# int (undefined behavior), typically resulting in -1.  This -1 was
     81      1.24    rillig 	# interpreted as "the last word".
     82      1.24    rillig 	#
     83      1.24    rillig 	# On ILP32, strtol returns LONG_MAX, which is a large number.  This
     84      1.24    rillig 	# resulted in a range from LONG_MAX - 1 to 3, which was empty.
     85      1.24    rillig 	#
     86      1.24    rillig 	# Since 2020-11-01, the numeric overflow is detected and generates an
     87      1.24    rillig 	# error.  In the remainder of the text, the '$,' is no longer parsed
     88      1.24    rillig 	# as part of a variable modifier, where it would have been interpreted
     89      1.24    rillig 	# as an anchor to the :S modifier, but as a normal variable named ','.
     90      1.24    rillig 	# That variable is undefined, resulting in an empty string.
     91       1.3    rillig 	@echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,}
     92       1.4    rillig 
     93  1.31.2.1  perseant exclam: print-footer
     94  1.31.2.1  perseant # expect: make: in target "exclam": while evaluating variable "VARNAME": Unfinished modifier ('!' missing)
     95       1.4    rillig 	@echo ${VARNAME:!echo}
     96       1.4    rillig 	# When the final exclamation mark is missing, there is no
     97       1.4    rillig 	# fallback to the SysV substitution modifier.
     98       1.4    rillig 	# If there were a fallback, the output would be "exclam",
     99       1.4    rillig 	# and the above would have produced an "Unknown modifier '!'".
    100  1.31.2.1  perseant # expect: make: in target "exclam": while evaluating variable "!": Unfinished modifier ('!' missing)
    101       1.4    rillig 	@echo ${!:L:!=exclam}
    102       1.6    rillig 
    103  1.31.2.1  perseant mod-subst-delimiter: print-footer
    104  1.31.2.1  perseant # expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Missing delimiter for modifier ':S'
    105       1.6    rillig 	@echo 1: ${VAR:S
    106  1.31.2.1  perseant # expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
    107       1.6    rillig 	@echo 2: ${VAR:S,
    108  1.31.2.1  perseant # expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
    109       1.6    rillig 	@echo 3: ${VAR:S,from
    110  1.31.2.1  perseant # expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
    111      1.22    rillig 	@echo 4: ${VAR:S,from,
    112  1.31.2.1  perseant # expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
    113      1.22    rillig 	@echo 5: ${VAR:S,from,to
    114  1.31.2.1  perseant # expect: make: Unclosed expression, expecting '}' for modifier "S,from,to," of variable "VAR" with value "TheVariable"
    115      1.22    rillig 	@echo 6: ${VAR:S,from,to,
    116      1.22    rillig 	@echo 7: ${VAR:S,from,to,}
    117       1.7    rillig 
    118  1.31.2.1  perseant mod-regex-delimiter: print-footer
    119  1.31.2.1  perseant # expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Missing delimiter for modifier ':C'
    120       1.7    rillig 	@echo 1: ${VAR:C
    121  1.31.2.1  perseant # expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
    122       1.7    rillig 	@echo 2: ${VAR:C,
    123  1.31.2.1  perseant # expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
    124       1.7    rillig 	@echo 3: ${VAR:C,from
    125  1.31.2.1  perseant # expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
    126      1.22    rillig 	@echo 4: ${VAR:C,from,
    127  1.31.2.1  perseant # expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
    128      1.22    rillig 	@echo 5: ${VAR:C,from,to
    129  1.31.2.1  perseant # expect: make: Unclosed expression, expecting '}' for modifier "C,from,to," of variable "VAR" with value "TheVariable"
    130      1.22    rillig 	@echo 6: ${VAR:C,from,to,
    131      1.22    rillig 	@echo 7: ${VAR:C,from,to,}
    132       1.7    rillig 
    133      1.19    rillig mod-ts-parse: print-header print-footer
    134       1.7    rillig 	@echo ${FIB:ts}
    135       1.7    rillig 	@echo ${FIB:ts\65}	# octal 065 == U+0035 == '5'
    136  1.31.2.1  perseant # expect: make: Bad modifier ":ts\65oct" for variable "FIB"
    137       1.7    rillig 	@echo ${FIB:ts\65oct}	# bad modifier
    138  1.31.2.1  perseant # expect: make: Bad modifier ":ts\65oct" for variable ""
    139      1.27    rillig 	@echo ${:U${FIB}:ts\65oct} # bad modifier, variable name is ""
    140  1.31.2.1  perseant # expect: make: Bad modifier ":tsxy" for variable "FIB"
    141       1.7    rillig 	@echo ${FIB:tsxy}	# modifier too long
    142       1.7    rillig 
    143      1.19    rillig mod-t-parse: print-header print-footer
    144  1.31.2.1  perseant # expect: make: Bad modifier ":t" for variable "FIB"
    145      1.10    rillig 	@echo ${FIB:t
    146  1.31.2.1  perseant # expect: make: Bad modifier ":txy" for variable "FIB"
    147       1.7    rillig 	@echo ${FIB:txy}
    148  1.31.2.1  perseant # expect: make: Bad modifier ":t" for variable "FIB"
    149       1.7    rillig 	@echo ${FIB:t}
    150  1.31.2.1  perseant # expect: make: Bad modifier ":t" for variable "FIB"
    151       1.7    rillig 	@echo ${FIB:t:M*}
    152       1.7    rillig 
    153  1.31.2.1  perseant mod-ifelse-parse: print-footer
    154  1.31.2.1  perseant # expect: make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing)
    155       1.7    rillig 	@echo ${FIB:?
    156  1.31.2.1  perseant # expect: make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing)
    157       1.7    rillig 	@echo ${FIB:?then
    158  1.31.2.1  perseant # expect: make: in target "mod-ifelse-parse": while evaluating else-branch of condition "FIB": Unfinished modifier ('}' missing)
    159       1.7    rillig 	@echo ${FIB:?then:
    160  1.31.2.1  perseant # expect: make: in target "mod-ifelse-parse": while evaluating else-branch of condition "FIB": Unfinished modifier ('}' missing)
    161       1.7    rillig 	@echo ${FIB:?then:else
    162       1.7    rillig 	@echo ${FIB:?then:else}
    163       1.7    rillig 
    164  1.31.2.1  perseant mod-remember-parse: print-footer
    165       1.7    rillig 	@echo ${FIB:_}		# ok
    166  1.31.2.1  perseant # expect: make: in target "mod-remember-parse": while evaluating variable "FIB": Unknown modifier "__"
    167       1.7    rillig 	@echo ${FIB:__}		# modifier name too long
    168       1.7    rillig 
    169  1.31.2.1  perseant mod-sysv-parse: print-footer
    170  1.31.2.1  perseant # expect: make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3"
    171       1.7    rillig 	@echo ${FIB:3
    172  1.31.2.1  perseant # expect: make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3="
    173       1.7    rillig 	@echo ${FIB:3=
    174  1.31.2.1  perseant # expect: make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3=x3"
    175       1.7    rillig 	@echo ${FIB:3=x3
    176       1.7    rillig 	@echo ${FIB:3=x3}	# ok
    177      1.18    rillig 
    178      1.19    rillig print-header: .USEBEFORE
    179      1.18    rillig 	@echo $@:
    180      1.19    rillig print-footer: .USE
    181      1.19    rillig 	@echo
    182