Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/tools/build/v2/test/unit-tests.jam @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

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