diff options
author | Paul Smith <psmith@gnu.org> | 2005-05-13 12:45:30 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2005-05-13 12:45:30 +0000 |
commit | e50e0fdf8856fada821393af3dbd268db09c3b47 (patch) | |
tree | fde9bf944a5192b729a8faf18d5ef0085d49e22e /tests | |
parent | 26d8d00cb77f0d71f72d4f61e7f38009dbef9715 (diff) | |
download | gunmake-e50e0fdf8856fada821393af3dbd268db09c3b47.tar.gz |
Implement new "if... else if... endif" semantics.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ChangeLog | 5 | ||||
-rw-r--r-- | tests/scripts/features/conditionals | 105 |
2 files changed, 77 insertions, 33 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 2a19918..914a67f 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2005-05-13 Paul D. Smith <psmith@gnu.org> + + * scripts/features/conditionals: Add tests for the new if... else + if... endif syntax. + 2005-05-03 Paul D. Smith <psmith@gnu.org> * scripts/variables/DEFAULT_GOAL: Rename DEFAULT_TARGET to diff --git a/tests/scripts/features/conditionals b/tests/scripts/features/conditionals index 36cba23..2ece60b 100644 --- a/tests/scripts/features/conditionals +++ b/tests/scripts/features/conditionals @@ -3,12 +3,7 @@ $description = "Check GNU make conditionals."; $details = "Attempt various different flavors of GNU make conditionals."; -open(MAKEFILE,"> $makefile"); - -# The Contents of the MAKEFILE ... - -print MAKEFILE <<'EOMAKE'; -objects = foo.obj +run_make_test(' arg1 = first arg2 = second arg3 = third @@ -22,13 +17,13 @@ else @echo arg1 NOT equal arg2 endif -ifeq '$(arg2)' "$(arg5)" +ifeq \'$(arg2)\' "$(arg5)" @echo arg2 equals arg5 else @echo arg2 NOT equal arg5 endif -ifneq '$(arg3)' '$(arg4)' +ifneq \'$(arg3)\' \'$(arg4)\' @echo arg3 NOT equal arg4 else @echo arg3 equal arg4 @@ -43,32 +38,18 @@ ifdef arg4 @echo arg4 is defined else @echo arg4 is NOT defined -endif - -EOMAKE - -close(MAKEFILE); - -&run_make_with_options($makefile,"",&get_logfile,0); - -$answer = "arg1 NOT equal arg2 +endif', + '', + 'arg1 NOT equal arg2 arg2 equals arg5 arg3 NOT equal arg4 variable is undefined -arg4 is defined -"; - -&compare_output($answer,&get_logfile(1)); +arg4 is defined'); # Test expansion of variables inside ifdef. -$makefile2 = &get_tmpfile; - -open(MAKEFILE, "> $makefile2"); - -print MAKEFILE <<'EOF'; - +run_make_test(' foo = 1 FOO = foo @@ -92,15 +73,73 @@ ifdef $(call FUNC,DEF)3 DEF3 = yes endif -all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3) +all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3)', + '', + 'DEF=yes DEF2=yes DEF3=yes'); + + +# Test all the different "else if..." constructs + +run_make_test(' +arg1 = first +arg2 = second +arg3 = third +arg4 = cc +arg5 = fifth -EOF +result = -close(MAKEFILE) +ifeq ($(arg1),$(arg2)) + result += arg1 equals arg2 +else ifeq \'$(arg2)\' "$(arg5)" + result += arg2 equals arg5 +else ifneq \'$(arg3)\' \'$(arg3)\' + result += arg3 NOT equal arg4 +else ifndef arg5 + result += variable is undefined +else ifdef undefined + result += arg4 is defined +else + result += success +endif + + +all: ; @echo $(result)', + '', + 'success'); + + +# Test some random "else if..." construct nesting + +run_make_test(' +arg1 = first +arg2 = second +arg3 = third +arg4 = cc +arg5 = second + +ifeq ($(arg1),$(arg2)) + $(info failed 1) +else ifeq \'$(arg2)\' "$(arg2)" + ifdef undefined + $(info failed 2) + else + $(info success) + endif +else ifneq \'$(arg3)\' \'$(arg3)\' + $(info failed 3) +else ifdef arg5 + $(info failed 4) +else ifdef undefined + $(info failed 5) +else + $(info failed 6) +endif -&run_make_with_options($makefile2,"",&get_logfile,0); -$answer = "DEF=yes DEF2=yes DEF3=yes\n"; -&compare_output($answer,&get_logfile(1)); +.PHONY: all +all: ; @:', + '', + 'success'); # This tells the test driver that the perl test script executed properly. |