"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "unit-tests/cond-short.mk" between
bmake-20201101.tar.gz and bmake-20201117.tar.gz

About: bmake a BSD make tool (derived from NetBSD’s make).

cond-short.mk  (bmake-20201101):cond-short.mk  (bmake-20201117)
# $NetBSD: cond-short.mk,v 1.11 2020/10/24 08:50:17 rillig Exp $ # $NetBSD: cond-short.mk,v 1.12 2020/11/15 14:58:14 rillig Exp $
# #
# Demonstrates that in conditions, the right-hand side of an && or || # Demonstrates that in conditions, the right-hand side of an && or ||
# is only evaluated if it can actually influence the result. # is only evaluated if it can actually influence the result.
# This is called 'short-circuit evaluation' and is the usual evaluation
# mode in most programming languages. A notable exception is Ada, which
# distinguishes between the operators 'And', 'And Then', 'Or', 'Or Else'.
# #
# Between 2015-10-11 and 2020-06-28, the right-hand side of an && or || # Between 2015-10-11 and 2020-06-28, the right-hand side of an && or ||
# operator was always evaluated, which was wrong. # operator was always evaluated, which was wrong.
# # TODO: Had the evaluation been correct at some time before 2015-11-12?
# The && operator. # The && operator.
.if 0 && ${echo "unexpected and" 1>&2 :L:sh} .if 0 && ${echo "unexpected and" 1>&2 :L:sh}
.endif .endif
.if 1 && ${echo "expected and" 1>&2 :L:sh} .if 1 && ${echo "expected and" 1>&2 :L:sh}
.endif .endif
.if 0 && exists(nonexistent${echo "unexpected and exists" 1>&2 :L:sh}) .if 0 && exists(nonexistent${echo "unexpected and exists" 1>&2 :L:sh})
skipping to change at line 116 skipping to change at line 119
. endif . endif
.endif .endif
.if 1 .if 1
.elif ${echo "unexpected nested or" 1>&2 :L:sh} .elif ${echo "unexpected nested or" 1>&2 :L:sh}
.endif .endif
# make sure these do not cause complaint # make sure these do not cause complaint
#.MAKEFLAGS: -dc #.MAKEFLAGS: -dc
# TODO: Rewrite this whole section and check all the conditions and variables.
# Several of the assumptions are probably wrong here.
# TODO: replace 'x=' with '.info' or '.error'.
V42= 42 V42= 42
iV1= ${V42} iV1= ${V42}
iV2= ${V66} iV2= ${V66}
.if defined(V42) && ${V42} > 0 .if defined(V42) && ${V42} > 0
x= Ok x= Ok
.else .else
x= Fail x= Fail
.endif .endif
x!= echo 'defined(V42) && ${V42} > 0: $x' >&2; echo x!= echo 'defined(V42) && ${V42} > 0: $x' >&2; echo
skipping to change at line 170 skipping to change at line 176
x!= echo '0 || ${iV1} <= ${V42}: $x' >&2; echo x!= echo '0 || ${iV1} <= ${V42}: $x' >&2; echo
# ${iV2:U2} expands to 2 # ${iV2:U2} expands to 2
.if 0 || ${iV2:U2} < ${V42} .if 0 || ${iV2:U2} < ${V42}
x= Ok x= Ok
.else .else
x= Fail x= Fail
.endif .endif
x!= echo '0 || ${iV2:U2} < ${V42}: $x' >&2; echo x!= echo '0 || ${iV2:U2} < ${V42}: $x' >&2; echo
# TODO: Has this always worked? There may have been a time, maybe around
# 2000, when make would complain about the "Malformed conditional" because
# UNDEF is not defined.
.if defined(UNDEF) && ${UNDEF} != "undefined"
. error
.endif
# TODO: Test each modifier to make sure it is skipped when it is irrelevant
# for the result. Since this test is already quite long, do that in another
# test.
all: all:
@:;: @:;:
 End of changes. 5 change blocks. 
2 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)