# Copyright 2001 Dave Abrahams # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) # assert_equal a : b # # exits with an assertion failure if a != b rule assert_equal { if $(<) != $(>) { EXIT "assertion failure: [" $(<) "] != [" $(>) "]" ; } } rule assert_equal_sets { if ! [ equal-sets $(<) : $(>) ] { EXIT "assertion failure: [" $(<) "] !=(set) [" $(>) "]" ; } } # FAppendSuffix assert_equal [ FAppendSuffix yacc lex foo.bat : ] : yacc lex foo.bat ; assert_equal [ FAppendSuffix yacc lex foo.bat : .exe ] : yacc.exe lex.exe foo.bat ; assert_equal [ FAppendSuffix yacc lex foo.bat : .dll .lib ] : yacc.dll yacc.lib lex.dll lex.lib foo.bat foo.lib ; # sort assert_equal [ sort 7 3 5 6 2 4 ] : 2 3 4 5 6 7 ; # min assert_equal [ min 7 3 5 6 2 4 ] : 2 ; # difference assert_equal [ difference 0 1 2 3 4 5 6 7 8 9 : 2 3 5 7 ] : 0 1 4 6 8 9 ; # replace assert_equal [ replace 1 3 5 7 7 9 2 5 4 3 1 : 7 x ] : 1 3 5 x x 9 2 5 4 3 1 ; # select-ungristed assert_equal [ select-ungristed b c e f ] : c f ; # split-qualified-property assert_equal [ split-qualified-property value ] : <*> <*> value ; assert_equal [ split-qualified-property value ] : <*> value ; assert_equal [ split-qualified-property value ] : value ; # unique assert_equal [ unique 0 1 2 3 1 7 6 6 4 5 ] : 0 1 2 3 7 6 4 5 ; # get-properties assert_equal [ get-properties : bar baz fight niss ] : bar baz fight ; # get-values assert_equal [ get-values : bar baz fight niss ] : bar baz ; # normalize-properties assert_equal [ normalize-properties b e i ] : <*><*>b <*>e i ; # intersection assert_equal [ intersection 1 2 2 3 3 4 5 6 7 : 5 1 3 7 3 9 11 ] : 1 3 3 5 7 ; # is-subset assert_equal [ is-subset a b c : c a b d ] : true ; assert_equal [ is-subset a b z : c a b d ] : ; # split-path assert_equal [ split-path b/c/e ] : b c e ; assert_equal [ split-path // ] : ; assert_equal [ split-path ] : ; assert_equal [ split-path x ] : x ; assert_equal [ split-path $(DOT) ] : $(DOT) ; assert_equal [ split-path a/b.c/d.e/f ] : a b.c d.e f ; if $(NT) { assert_equal [ split-path x:\\y\\z\\w ] : x: y z w ; assert_equal [ split-path x:\\y\\z ] : x: y z ; assert_equal [ split-path x:\\y ] : x: y ; assert_equal [ split-path x:\\ ] : x: ; assert_equal [ split-path x: ] : x: ; } # distribute-feature assert_equal [ distribute-feature value1 ] : value1 ; assert_equal [ distribute-feature value1/value2 ] : value1 value2 ; assert_equal [ distribute-feature value1/value2/value3 ] : value1 value2 value3 ; # segregate-free-properties { local gFREE_FEATURES = ; local x = b c e ; local y = b c c f ; local free = [ segregate-free-properties x y ] ; assert_equal $(free) : b c f ; assert_equal $(x) : c e ; assert_equal $(y) : c ; } # set-insert { local gTEST_SET = 1 2 3 ; set-insert gTEST_SET : 2 ; assert_equal $(gTEST_SET) : 1 2 3 ; set-insert gTEST_SET : 0 ; assert_equal $(gTEST_SET) : 1 2 3 0 ; } # equal-sets assert_equal [ equal-sets 1 2 3 : 3 2 2 1 ] : true ; assert_equal [ equal-sets 1 2 3 3 : 3 2 2 1 ] : true ; assert_equal [ equal-sets 1 2 3 3 4 : 3 2 2 1 ] : ; # segregate-overrides { local base = b d f ; local overrides = b c e g ; segregate-overrides overrides : base ; assert_equal $(overrides) : c e g ; assert_equal $(base) : b f ; } # select-properties { local TOOLS = gcc msvc ; local gRELEVANT_FEATURES(msvc) = ; local gRELEVANT_FEATURES(gcc) = ; local gFREE_FEATURES = ; local gBASE_PROPERTIES(msvc,debug) = on off off debug single ; local gBASE_PROPERTIES(gcc,debug) = on off off off false ; local gBASE_PROPERTIES(msvc,release) = off NDEBUG full speed release single ; local gBASE_PROPERTIES(gcc,release) = off NDEBUG full speed off false ; local TEST_PROPERTIES = off FOO <*>on DEBUG bar <*>on <*>baz speed <*>off <*>off ; assert_equal_sets [ select-properties gcc debug my-target : $(TEST_PROPERTIES) ] : FOO DEBUG on off ; assert_equal_sets [ select-properties gcc release my-target : $(TEST_PROPERTIES) ] : FOO on ; assert_equal_sets [ select-properties msvc debug my-target : $(TEST_PROPERTIES) ] : FOO DEBUG off off ; assert_equal_sets [ select-properties msvc release my-target : $(TEST_PROPERTIES) ] : FOO on speed ; } # ungrist-properties feature TEST_FEATURE1 : a b ; feature TEST_FEATURE2 : c d ; assert_equal [ ungrist-properties a c ] : TEST_FEATURE1-a TEST_FEATURE2-c ; # fixup-path-properties { local RELATIVE_SUBDIR = foobar ; local gPATH_FEATURES = ; assert_equal [ fixup-path-properties b .. d ] : foobar$(SLASH).. b d ; } # multiply-property-sets assert_equal [ multiply-property-sets 1 2/3 4/5 ] : 2/1/4 2/1/5 3/1/4 3/1/5 ; # make-path-property-sets { local gUNGRISTED() = a ; local gUNGRISTED() = c ; local gUNGRISTED() = e ; local gUNGRISTED() = g ; local gUNGRISTED() = i ; assert_equal [ make-path-property-sets foo$(SLASH)bar : b d : f$(SLASH)h j ] : foo$(SLASH)bar$(SLASH)e-f$(SLASH)g-h$(SLASH)b$(SLASH)d$(SLASH)f$(SLASH)h foo$(SLASH)bar$(SLASH)i-j$(SLASH)b$(SLASH)d$(SLASH)j ; assert_equal [ make-path-property-sets foo$(SLASH)bar : b d : ] : foo$(SLASH)bar$(SLASH)b$(SLASH)d ; } # split-path-at-grist assert_equal [ split-path-at-grist b$(SLASH)c$(SLASH)e$(SLASH)g$(SLASH)h$(SLASH)i ] : b$(SLASH)c e g$(SLASH)h$(SLASH)i ; assert_equal [ split-path-at-grist b$(SLASH)c$(SLASH)e$(SLASH)g$(SLASH)h$(SLASH)i ] : b$(SLASH)c e g$(SLASH)h$(SLASH)i ; if $(NT) { assert_equal [ split-path-at-grist b\\c\\e:\\f\\g\\i ] : b\\c e:\\f\\g i ; } # directory-of assert_equal [ directory-of a$(SLASH)b c d$(SLASH)e$(SLASH)f ] : a . d$(SLASH)e ; # top-relative-tokens { local SUBDIR_TOKENS = a b c ; assert_equal [ top-relative-tokens ..$(SLASH)d$(SLASH)e ] : a b d e ; } # flags { local gBUILD_PROPERTIES = b d f ; local FLAGS1 FLAGS2 FLAGS3 ; flags toolset FLAGS1 b/d b/f y / : foobar ; assert_equal $(FLAGS1) : foobar b d f ; flags toolset FLAGS2 : foobar ; assert_equal $(FLAGS2) : b ; flags toolset FLAGS1 b/d b/f : foobar ; assert_equal $(FLAGS1) : foobar b d f foobar ; } # get-BUILD { local DEFAULT_BUILD = a ; local BUILD = b ; assert_equal [ get-BUILD c e ] : b ; BUILD = ; assert_equal [ get-BUILD c e ] : c e ; assert_equal [ get-BUILD ] : a ; assert_equal [ get-BUILD e ] : e a ; BUILD = g ; assert_equal [ get-BUILD c e ] : g a ; } # strip-initial assert_equal [ strip-initial a b c : a b c d e f g ] : d e f g ; assert_equal [ strip-initial a b c : a b d e f g ] : a b d e f g ; assert_equal [ strip-initial a b c : b d e f g ] : b d e f g ; assert_equal [ strip-initial a b c : ] : ; # simplify-path-tokens { local $(gTOP)_TOKENS = .. .. .. ; local gINVOCATION_SUBDIR_TOKENS = d e ; assert_equal [ simplify-path-tokens a b . c .. .. d e ] : a d e ; assert_equal [ simplify-path-tokens a b .. .. .. d e ] : .. d e ; assert_equal [ simplify-path-tokens .. .. d e : xxx ] : .. .. d e ; assert_equal [ simplify-path-tokens a b .. .. : xxx ] : xxx ; $(gTOP)_TOKENS = .. .. ; assert_equal [ simplify-path-tokens .. .. d e : xxx ] : xxx ; assert_equal [ simplify-path-tokens .. .. d e f g : xxx ] : f g ; }