Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

added boost

File size: 9.3 KB
Line 
1# (C) Copyright David Abrahams 2001.
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
8ECHO running unit tests... ;
9rule assert_equal
10{
11    if $(<) != $(>)
12    {
13        EXIT "assertion failure: [" $(<) "] != [" $(>) "]" ;
14    }
15}
16
17rule assert_equal_sets
18{
19    if ! [ equal-sets $(<) : $(>) ]
20    {
21        EXIT "assertion failure: [" $(<) "] !=(set) [" $(>) "]" ;
22    }
23}
24
25# FAppendSuffix
26assert_equal [ FAppendSuffix yacc lex foo.bat : ] : yacc lex foo.bat ;
27assert_equal [ FAppendSuffix yacc lex foo.bat : .exe ] : yacc.exe lex.exe foo.bat ;
28assert_equal [ FAppendSuffix yacc lex foo.bat : .dll .lib ] : yacc.dll yacc.lib lex.dll lex.lib foo.bat foo.lib ;
29
30# sort
31assert_equal [ sort 7 3 5 6 2 4 ] : 2 3 4 5 6 7 ;
32
33# min
34assert_equal [ min 7 3 5 6 2 4 ] : 2 ;
35
36# difference
37assert_equal [ difference 0 1 2 3 4 5 6 7 8 9 : 2 3 5 7 ] : 0 1 4 6 8 9 ;
38
39# replace
40assert_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 ;
41
42# select-ungristed
43assert_equal [ select-ungristed <a>b c <d>e f ] : c f ;
44
45# split-qualified-property
46assert_equal [ split-qualified-property <feature>value ]
47    : <*> <*> <feature>value ;
48   
49assert_equal [ split-qualified-property <variant><feature>value ]
50    : <*> <variant> <feature>value ;
51   
52assert_equal [ split-qualified-property <toolset><variant><feature>value ]
53    : <toolset> <variant> <feature>value ;
54
55# unique
56assert_equal [ unique 0 1 2 3 1 7 6 6 4 5 ] : 0 1 2 3 7 6 4 5 ;
57
58# get-properties
59assert_equal [ get-properties <foo> <bar> : <foo>bar <foo>baz <bar>fight <baz>niss ]
60    : <foo>bar <foo>baz <bar>fight ;
61
62# get-values
63assert_equal [ get-values <foo> : <foo>bar <foo>baz <bar>fight <baz>niss ] : bar baz ;
64
65# normalize-properties
66assert_equal [ normalize-properties <a>b <c><d>e <f><g><h>i ] :
67     <*><*><a>b <*><c><d>e <f><g><h>i ;
68
69# intersection
70assert_equal [ intersection 1 2 2 3 3 4 5 6 7 : 5 1 3 7 3 9 11 ] : 1 3 3 5 7 ;
71
72# is-subset
73assert_equal [ is-subset a b c : c a b d ] : true ;
74assert_equal [ is-subset a b z : c a b d ] : ;
75
76# split-path
77assert_equal [ split-path /a/b/c ] : / a b c ;
78assert_equal [ split-path b/c.d/.f/g./h.i ] : b c.d .f g. h.i ;
79assert_equal [ split-path <a>b/c/<d>e ] : <a>b c <d>e ;
80assert_equal [ split-path <a>/<d>/<e> ] : <a> <d> <e> ;
81assert_equal [ split-path <a> ] : <a> ;
82assert_equal [ split-path x ] : x ;
83assert_equal [ split-path $(DOT) ] : $(DOT) ;
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# simplify-path-tokens
176{
177    local $(gTOP)_TOKENS = .. .. .. ;
178    local gINVOCATION_SUBDIR_TOKENS = d e ;
179    assert_equal [ simplify-path-tokens a b . c .. .. d e ] : a d e ;
180    assert_equal [ simplify-path-tokens a b .. .. .. d e ] : .. d e ;
181    assert_equal [ simplify-path-tokens .. .. d e : xxx ] : .. .. d e ;
182    assert_equal [ simplify-path-tokens a b .. .. : xxx ] : xxx ;
183    $(gTOP)_TOKENS = .. .. ;
184    assert_equal [ simplify-path-tokens .. .. d e : xxx ] : xxx ;
185    assert_equal [ simplify-path-tokens .. .. d e f g : xxx ] : f g ;
186}
187
188# fixup-path-properties
189{
190    local RELATIVE_SUBDIR = foobar ;
191    local gPATH_FEATURES = <include> ;
192    assert_equal [ fixup-path-properties <a>b <include>.. <c>d ]
193                : <include>. <a>b <c>d ;
194               
195    RELATIVE_SUBDIR = foobar/baz ;
196    assert_equal [ fixup-path-properties <a>b <include>.. <c>d ]
197                : <include>foobar <a>b <c>d ;
198}
199# multiply-property-sets
200assert_equal [ multiply-property-sets <b>1 <a>2/3 <c>4/5 ]
201    : <a>2/<b>1/<c>4 <a>2/<b>1/<c>5 <a>3/<b>1/<c>4 <a>3/<b>1/<c>5 ;
202
203# make-path-property-sets
204{
205    local gUNGRISTED(<a>) = a ;
206    local gUNGRISTED(<c>) = c ;
207    local gUNGRISTED(<e>) = e ;
208    local gUNGRISTED(<g>) = g ;
209    local gUNGRISTED(<i>) = i ;
210    assert_equal [ make-path-property-sets foo$(SLASH)bar : <a>b <c>d : <e>f$(SLASH)<g>h <i>j ]
211    : 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 ;
212    assert_equal [ make-path-property-sets foo$(SLASH)bar : <a>b <c>d : ]
213    : foo$(SLASH)bar$(SLASH)<a>b$(SLASH)<c>d ;
214}
215
216
217# split-path-at-grist
218assert_equal
219 [ split-path-at-grist <a>b$(SLASH)c$(SLASH)<d>e$(SLASH)<f>g$(SLASH)h$(SLASH)i ]
220 : <a>b$(SLASH)c <d>e <f>g$(SLASH)h$(SLASH)i ;
221assert_equal
222 [ split-path-at-grist b$(SLASH)c$(SLASH)<d>e$(SLASH)<f>g$(SLASH)h$(SLASH)i ]
223 : b$(SLASH)c <d>e <f>g$(SLASH)h$(SLASH)i ;
224if $(NT)
225{
226    assert_equal
227        [ split-path-at-grist b\\c\\<include>e:\\f\\g\\<h>i ]
228        : b\\c <include>e:\\f\\g <h>i ;
229}
230# directory-of
231assert_equal [ directory-of a$(SLASH)b c d$(SLASH)e$(SLASH)f ] : a . d$(SLASH)e ;
232
233# top-relative-tokens
234{
235    local SUBDIR_TOKENS = a b c ;
236    assert_equal [ top-relative-tokens ..$(SLASH)d$(SLASH)e ] : a b d e ;
237}
238
239# flags
240{
241    local gBUILD_PROPERTIES = <a>b <c>d <e>f ;
242    local FLAGS1 FLAGS2 FLAGS3 ;
243    flags toolset FLAGS1 <a>b/<c>d <a>b/<e>f <x>y <a>/<c> <e> : foobar ;
244    assert_equal $(FLAGS1) : foobar b d f ;
245    flags toolset FLAGS2 <a> : foobar ;
246    assert_equal $(FLAGS2) : b ;
247    flags toolset FLAGS1 <a>b/<c>d <a>b/<e>f : foobar ;
248    assert_equal $(FLAGS1) : foobar b d f foobar ;
249}
250
251# get-BUILD
252{
253    local DEFAULT_BUILD = a ;
254    local BUILD = b ;
255    assert_equal [ get-BUILD c <d>e ] : b ;
256    BUILD = ;
257    assert_equal [ get-BUILD c <d>e ] : c <d>e ;
258    assert_equal [ get-BUILD ] : a ;
259    assert_equal [ get-BUILD <d>e ] : <d>e a ;
260    BUILD = <f>g ;
261    assert_equal [ get-BUILD c <d>e ] : <f>g a ;
262}
263
264# strip-initial
265assert_equal [ strip-initial a b c : a b c d e f g ] : d e f g ;
266assert_equal [ strip-initial a b c : a b d e f g ] : a b d e f g ;
267assert_equal [ strip-initial a b c : b d e f g ] : b d e f g ;
268assert_equal [ strip-initial a b c : ] :  ;
269
270ECHO unit tests complete. ;
Note: See TracBrowser for help on using the repository browser.