Home | History | Annotate | Line # | Download | only in unit-tests
varmod-order.mk revision 1.11
      1  1.11  rillig # $NetBSD: varmod-order.mk,v 1.11 2023/06/01 20:56:35 rillig Exp $
      2   1.1  rillig #
      3   1.6  rillig # Tests for the :O variable modifier and its variants, which either sort the
      4   1.6  rillig # words of the value or shuffle them.
      5   1.1  rillig 
      6   1.7  rillig WORDS=		one two three four five six seven eight nine ten
      7   1.7  rillig NUMBERS=	8 5 4 9 1 7 6 10 3 2	# in English alphabetical order
      8   1.3  rillig 
      9   1.7  rillig .if ${WORDS:O} != "eight five four nine one seven six ten three two"
     10   1.7  rillig .  error ${WORDS:O}
     11   1.3  rillig .endif
     12   1.1  rillig 
     13   1.4  rillig # Unknown modifier "OX"
     14  1.11  rillig # FIXME: The error message is wrong.
     15  1.11  rillig # expect+1: Undefined variable "${WORDS:OX"
     16   1.7  rillig _:=	${WORDS:OX}
     17   1.4  rillig 
     18   1.4  rillig # Unknown modifier "OxXX"
     19  1.11  rillig # FIXME: The error message is wrong.
     20  1.11  rillig # expect+1: Undefined variable "${WORDS:Ox"
     21   1.7  rillig _:=	${WORDS:OxXX}
     22   1.4  rillig 
     23   1.6  rillig # Missing closing brace, to cover the error handling code.
     24   1.7  rillig _:=	${WORDS:O
     25   1.6  rillig _:=	${NUMBERS:On
     26   1.6  rillig _:=	${NUMBERS:Onr
     27   1.6  rillig 
     28   1.6  rillig # Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be
     29   1.6  rillig # combined.
     30   1.6  rillig #
     31   1.8  rillig # expect: make: Bad modifier ":Oxn" for variable "NUMBERS"
     32   1.6  rillig # expect+1: Malformed conditional (${NUMBERS:Oxn})
     33   1.6  rillig .if ${NUMBERS:Oxn}
     34   1.6  rillig .  error
     35   1.6  rillig .else
     36   1.6  rillig .  error
     37   1.6  rillig .endif
     38   1.6  rillig 
     39   1.6  rillig # Extra characters after ':On' are detected and diagnosed.
     40   1.6  rillig # TODO: Add line number information to the "Bad modifier" diagnostic.
     41   1.6  rillig #
     42   1.8  rillig # expect: make: Bad modifier ":On_typo" for variable "NUMBERS"
     43  1.11  rillig # expect+1: Malformed conditional (${NUMBERS:On_typo})
     44   1.6  rillig .if ${NUMBERS:On_typo}
     45   1.6  rillig .  error
     46   1.6  rillig .else
     47   1.6  rillig .  error
     48   1.6  rillig .endif
     49   1.6  rillig 
     50   1.6  rillig # Extra characters after ':Onr' are detected and diagnosed.
     51   1.6  rillig #
     52   1.8  rillig # expect: make: Bad modifier ":Onr_typo" for variable "NUMBERS"
     53  1.11  rillig # expect+1: Malformed conditional (${NUMBERS:Onr_typo})
     54   1.6  rillig .if ${NUMBERS:Onr_typo}
     55   1.6  rillig .  error
     56   1.6  rillig .else
     57   1.6  rillig .  error
     58   1.6  rillig .endif
     59   1.6  rillig 
     60   1.6  rillig # Extra characters after ':Orn' are detected and diagnosed.
     61   1.6  rillig #
     62   1.8  rillig # expect: make: Bad modifier ":Orn_typo" for variable "NUMBERS"
     63  1.11  rillig # expect+1: Malformed conditional (${NUMBERS:Orn_typo})
     64   1.6  rillig .if ${NUMBERS:Orn_typo}
     65   1.6  rillig .  error
     66   1.6  rillig .else
     67   1.6  rillig .  error
     68   1.6  rillig .endif
     69   1.6  rillig 
     70   1.6  rillig # Repeating the 'n' is not supported.  In the typical use cases, the sorting
     71   1.6  rillig # criteria are fixed, not computed, therefore allowing this redundancy does
     72   1.6  rillig # not make sense.
     73   1.6  rillig #
     74   1.8  rillig # expect: make: Bad modifier ":Onn" for variable "NUMBERS"
     75  1.11  rillig # expect+1: Malformed conditional (${NUMBERS:Onn})
     76   1.6  rillig .if ${NUMBERS:Onn}
     77   1.6  rillig .  error
     78   1.6  rillig .else
     79   1.6  rillig .  error
     80   1.6  rillig .endif
     81   1.6  rillig 
     82   1.6  rillig # Repeating the 'r' is not supported as well, for the same reasons as above.
     83   1.6  rillig #
     84   1.8  rillig # expect: make: Bad modifier ":Onrr" for variable "NUMBERS"
     85  1.11  rillig # expect+1: Malformed conditional (${NUMBERS:Onrr})
     86   1.6  rillig .if ${NUMBERS:Onrr}
     87   1.6  rillig .  error
     88   1.6  rillig .else
     89   1.6  rillig .  error
     90   1.6  rillig .endif
     91   1.6  rillig 
     92   1.6  rillig # Repeating the 'r' is not supported as well, for the same reasons as above.
     93   1.6  rillig #
     94   1.8  rillig # expect: make: Bad modifier ":Orrn" for variable "NUMBERS"
     95  1.11  rillig # expect+1: Malformed conditional (${NUMBERS:Orrn})
     96   1.6  rillig .if ${NUMBERS:Orrn}
     97   1.6  rillig .  error
     98   1.6  rillig .else
     99   1.6  rillig .  error
    100   1.6  rillig .endif
    101   1.6  rillig 
    102   1.9  rillig 
    103  1.10  rillig # If a modifier that starts with ':O' is not one of the known sort or shuffle
    104  1.10  rillig # forms, it is a parse error.  Several other modifiers such as ':H' or ':u'
    105  1.10  rillig # fall back to the SysV modifier, for example, ':H=new' is not the standard
    106  1.10  rillig # ':H' modifier but instead replaces a trailing 'H' with 'new' in each word.
    107  1.10  rillig # There is no such fallback for the ':O' modifiers.
    108  1.10  rillig SWITCH=	On
    109  1.10  rillig # expect: make: Bad modifier ":On=Off" for variable "SWITCH"
    110  1.11  rillig # expect+1: Malformed conditional (${SWITCH:On=Off} != "Off")
    111  1.10  rillig .if ${SWITCH:On=Off} != "Off"
    112   1.9  rillig .  error
    113   1.9  rillig .else
    114   1.9  rillig .  error
    115   1.9  rillig .endif
    116   1.9  rillig 
    117   1.1  rillig all:
    118