Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/build/v2/test/unit-tests.jam @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 9.0 KB
Line 
1# Copyright 2001 Dave Abrahams
2# Distributed under the Boost Software License, Version 1.0.
3# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
4
5# assert_equal a : b
6#
7# exits with an assertion failure if a != b
8rule assert_equal
9{
10    if $(<) != $(>)
11    {
12        EXIT "assertion failure: [" $(<) "] != [" $(>) "]" ;
13    }
14}
15
16rule assert_equal_sets
17{
18    if ! [ equal-sets $(<) : $(>) ]
19    {
20        EXIT "assertion failure: [" $(<) "] !=(set) [" $(>) "]" ;
21    }
22}
23
24# FAppendSuffix
25assert_equal [ FAppendSuffix yacc lex foo.bat : ] : yacc lex foo.bat ;
26assert_equal [ FAppendSuffix yacc lex foo.bat : .exe ] : yacc.exe lex.exe foo.bat ;
27assert_equal [ FAppendSuffix yacc lex foo.bat : .dll .lib ] : yacc.dll yacc.lib lex.dll lex.lib foo.bat foo.lib ;
28
29# sort
30assert_equal [ sort 7 3 5 6 2 4 ] : 2 3 4 5 6 7 ;
31
32# min
33assert_equal [ min 7 3 5 6 2 4 ] : 2 ;
34
35# difference
36assert_equal [ difference 0 1 2 3 4 5 6 7 8 9 : 2 3 5 7 ] : 0 1 4 6 8 9 ;
37
38# replace
39assert_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 ;
40
41# select-ungristed
42assert_equal [ select-ungristed <a>b c <d>e f ] : c f ;
43
44# split-qualified-property
45assert_equal [ split-qualified-property <feature>value ]
46    : <*> <*> <feature>value ;
47   
48assert_equal [ split-qualified-property <variant><feature>value ]
49    : <*> <variant> <feature>value ;
50   
51assert_equal [ split-qualified-property <toolset><variant><feature>value ]
52    : <toolset> <variant> <feature>value ;
53
54# unique
55assert_equal [ unique 0 1 2 3 1 7 6 6 4 5 ] : 0 1 2 3 7 6 4 5 ;
56
57# get-properties
58assert_equal [ get-properties <foo> <bar> : <foo>bar <foo>baz <bar>fight <baz>niss ]
59    : <foo>bar <foo>baz <bar>fight ;
60
61# get-values
62assert_equal [ get-values <foo> : <foo>bar <foo>baz <bar>fight <baz>niss ] : bar baz ;
63
64# normalize-properties
65assert_equal [ normalize-properties <a>b <c><d>e <f><g><h>i ] :
66     <*><*><a>b <*><c><d>e <f><g><h>i ;
67
68# intersection
69assert_equal [ intersection 1 2 2 3 3 4 5 6 7 : 5 1 3 7 3 9 11 ] : 1 3 3 5 7 ;
70
71# is-subset
72assert_equal [ is-subset a b c : c a b d ] : true ;
73assert_equal [ is-subset a b z : c a b d ] : ;
74
75# split-path
76assert_equal [ split-path <a>b/c/<d>e ] : <a>b c <d>e ;
77assert_equal [ split-path <a>/<d>/<e> ] : <a> <d> <e> ;
78assert_equal [ split-path <a> ] : <a> ;
79assert_equal [ split-path x ] : x ;
80assert_equal [ split-path $(DOT) ] : $(DOT) ;
81assert_equal [ split-path a/b.c/d.e/f ] : a b.c d.e f ;
82if $(NT)
83{
84    assert_equal [ split-path x:\\y\\z\\w ] : x: y z w ;
85    assert_equal [ split-path x:\\y\\z ] : x: y z ;
86    assert_equal [ split-path x:\\y ] : x: y ;
87    assert_equal [ split-path x:\\ ] : x: ;
88    assert_equal [ split-path x: ] : x: ;
89}
90
91# distribute-feature
92assert_equal [ distribute-feature <feature>value1 ] : <feature>value1 ;
93assert_equal [ distribute-feature <feature>value1/value2 ] : <feature>value1 <feature>value2 ;
94assert_equal [ distribute-feature <feature>value1/value2/value3 ] : <feature>value1 <feature>value2 <feature>value3 ;
95
96# segregate-free-properties
97{
98    local gFREE_FEATURES = <a> <c> <e> ;
99    local x = <a>b <b>c <d>e ;
100    local y = <a>b <a>c <b>c <e>f ;
101    local free = [ segregate-free-properties x y ] ;
102    assert_equal $(free) : <a>b <a>c <e>f ;
103    assert_equal $(x) : <b>c <d>e ;
104    assert_equal $(y) : <b>c ;
105}
106
107# set-insert
108{
109    local gTEST_SET = 1 2 3 ;
110    set-insert gTEST_SET : 2 ;
111    assert_equal $(gTEST_SET) : 1 2 3 ;
112    set-insert gTEST_SET : 0 ;
113    assert_equal $(gTEST_SET) : 1 2 3 0 ;
114}
115
116# equal-sets
117assert_equal [ equal-sets 1 2 3 : 3 2 2 1 ] : true ;
118assert_equal [ equal-sets 1 2 3 3 : 3 2 2 1 ] : true ;
119assert_equal [ equal-sets 1 2 3 3 4 : 3 2 2 1 ] : ;
120
121# segregate-overrides
122{
123    local base = <a>b <c>d <e>f ;
124    local overrides = <a>b <c>c <d>e <f>g ;
125    segregate-overrides overrides : base ;
126    assert_equal $(overrides) : <c>c <d>e <f>g ;
127    assert_equal $(base) : <a>b <e>f ;
128}
129
130# select-properties
131{
132    local TOOLS = gcc msvc ;
133   
134    local gRELEVANT_FEATURES(msvc)  = <debug-symbols> <optimization> <inlining> <inline> <runtime-build> <runtime-link> <threading> <define> <undef> <include> <target-type> ;
135    local gRELEVANT_FEATURES(gcc)  = <runtime-link> <debug-symbols> <optimization> <inlining> <profiling> <define> <undef> <include> <shared-linkable> <target-type> ;
136    local gFREE_FEATURES =  <define> <undef> <include> ;
137   
138    local gBASE_PROPERTIES(msvc,debug)  = <debug-symbols>on <inlining>off <optimization>off <runtime-build>debug <threading>single ;
139    local gBASE_PROPERTIES(gcc,debug)  = <debug-symbols>on <inlining>off <optimization>off <profiling>off <shared-linkable>false ;
140    local gBASE_PROPERTIES(msvc,release)  = <debug-symbols>off <define>NDEBUG <inlining>full <optimization>speed <runtime-build>release <threading>single ;
141    local gBASE_PROPERTIES(gcc,release)  = <debug-symbols>off <define>NDEBUG <inlining>full <optimization>speed <profiling>off <shared-linkable>false ;
142   
143    local TEST_PROPERTIES = <inlining>off <define>FOO <*><release><inlining>on
144                  <debug><define>DEBUG <msvc><release><foo>bar
145                  <gcc><*><inlining>on
146                  <msvc><*><foo>baz
147                  <msvc><release><optimization>speed
148                  <msvc><*><optimization>off
149                  <*><debug><optimization>off
150                  ;
151                 
152    assert_equal_sets [ select-properties gcc debug my-target : $(TEST_PROPERTIES) ]
153        : <define>FOO <define>DEBUG <inlining>on <optimization>off ;
154
155    assert_equal_sets [ select-properties gcc release my-target : $(TEST_PROPERTIES) ]
156        : <define>FOO <inlining>on ;
157
158    assert_equal_sets [ select-properties msvc debug my-target : $(TEST_PROPERTIES) ]
159        : <define>FOO <define>DEBUG <inlining>off <optimization>off ;
160
161    assert_equal_sets [ select-properties msvc release my-target : $(TEST_PROPERTIES) ]
162        : <define>FOO <inlining>on <optimization>speed ;
163}
164
165
166# ungrist-properties
167feature TEST_FEATURE1 : a b ;
168feature TEST_FEATURE2 : c d ;
169assert_equal [ ungrist-properties <TEST_FEATURE1>a <TEST_FEATURE2>c ]
170    : TEST_FEATURE1-a TEST_FEATURE2-c ;
171
172
173# fixup-path-properties
174{
175    local RELATIVE_SUBDIR = foobar ;
176    local gPATH_FEATURES = <include> ;
177    assert_equal [ fixup-path-properties <a>b <include>.. <c>d ]
178                : <include>foobar$(SLASH).. <a>b <c>d ;
179}
180# multiply-property-sets
181assert_equal [ multiply-property-sets <b>1 <a>2/3 <c>4/5 ]
182    : <a>2/<b>1/<c>4 <a>2/<b>1/<c>5 <a>3/<b>1/<c>4 <a>3/<b>1/<c>5 ;
183
184# make-path-property-sets
185{
186    local gUNGRISTED(<a>) = a ;
187    local gUNGRISTED(<c>) = c ;
188    local gUNGRISTED(<e>) = e ;
189    local gUNGRISTED(<g>) = g ;
190    local gUNGRISTED(<i>) = i ;
191    assert_equal [ make-path-property-sets foo$(SLASH)bar : <a>b <c>d : <e>f$(SLASH)<g>h <i>j ]
192    : foo$(SLASH)bar$(SLASH)e-f$(SLASH)g-h$(SLASH)<a>b$(SLASH)<c>d$(SLASH)<e>f$(SLASH)<g>h foo$(SLASH)bar$(SLASH)i-j$(SLASH)<a>b$(SLASH)<c>d$(SLASH)<i>j ;
193    assert_equal [ make-path-property-sets foo$(SLASH)bar : <a>b <c>d : ]
194    : foo$(SLASH)bar$(SLASH)<a>b$(SLASH)<c>d ;
195}
196
197
198# split-path-at-grist
199assert_equal
200 [ split-path-at-grist <a>b$(SLASH)c$(SLASH)<d>e$(SLASH)<f>g$(SLASH)h$(SLASH)i ]
201 : <a>b$(SLASH)c <d>e <f>g$(SLASH)h$(SLASH)i ;
202assert_equal
203 [ split-path-at-grist b$(SLASH)c$(SLASH)<d>e$(SLASH)<f>g$(SLASH)h$(SLASH)i ]
204 : b$(SLASH)c <d>e <f>g$(SLASH)h$(SLASH)i ;
205if $(NT)
206{
207    assert_equal
208        [ split-path-at-grist b\\c\\<include>e:\\f\\g\\<h>i ]
209        : b\\c <include>e:\\f\\g <h>i ;
210}
211# directory-of
212assert_equal [ directory-of a$(SLASH)b c d$(SLASH)e$(SLASH)f ] : a . d$(SLASH)e ;
213
214# top-relative-tokens
215{
216    local SUBDIR_TOKENS = a b c ;
217    assert_equal [ top-relative-tokens ..$(SLASH)d$(SLASH)e ] : a b d e ;
218}
219
220# flags
221{
222    local gBUILD_PROPERTIES = <a>b <c>d <e>f ;
223    local FLAGS1 FLAGS2 FLAGS3 ;
224    flags toolset FLAGS1 <a>b/<c>d <a>b/<e>f <x>y <a>/<c> <e> : foobar ;
225    assert_equal $(FLAGS1) : foobar b d f ;
226    flags toolset FLAGS2 <a> : foobar ;
227    assert_equal $(FLAGS2) : b ;
228    flags toolset FLAGS1 <a>b/<c>d <a>b/<e>f : foobar ;
229    assert_equal $(FLAGS1) : foobar b d f foobar ;
230}
231
232# get-BUILD
233{
234    local DEFAULT_BUILD = a ;
235    local BUILD = b ;
236    assert_equal [ get-BUILD c <d>e ] : b ;
237    BUILD = ;
238    assert_equal [ get-BUILD c <d>e ] : c <d>e ;
239    assert_equal [ get-BUILD ] : a ;
240    assert_equal [ get-BUILD <d>e ] : <d>e a ;
241    BUILD = <f>g ;
242    assert_equal [ get-BUILD c <d>e ] : <f>g a ;
243}
244
245# strip-initial
246assert_equal [ strip-initial a b c : a b c d e f g ] : d e f g ;
247assert_equal [ strip-initial a b c : a b d e f g ] : a b d e f g ;
248assert_equal [ strip-initial a b c : b d e f g ] : b d e f g ;
249assert_equal [ strip-initial a b c : ] :  ;
250
251# simplify-path-tokens
252{
253    local $(gTOP)_TOKENS = .. .. .. ;
254    local gINVOCATION_SUBDIR_TOKENS = d e ;
255    assert_equal [ simplify-path-tokens a b . c .. .. d e ] : a d e ;
256    assert_equal [ simplify-path-tokens a b .. .. .. d e ] : .. d e ;
257    assert_equal [ simplify-path-tokens .. .. d e : xxx ] : .. .. d e ;
258    assert_equal [ simplify-path-tokens a b .. .. : xxx ] : xxx ;
259    $(gTOP)_TOKENS = .. .. ;
260    assert_equal [ simplify-path-tokens .. .. d e : xxx ] : xxx ;
261    assert_equal [ simplify-path-tokens .. .. d e f g : xxx ] : f g ;
262}
Note: See TracBrowser for help on using the repository browser.