Boost logo

Boost-Commit :

From: jurko.gospodnetic_at_[hidden]
Date: 2008-05-03 19:27:01


Author: jurko
Date: 2008-05-03 19:27:00 EDT (Sat, 03 May 2008)
New Revision: 45095
URL: http://svn.boost.org/trac/boost/changeset/45095

Log:
Upgraded some internal Boost Build tests. Minor stylistic changes.
Text files modified:
   trunk/tools/build/v2/util/assert.jam | 54 ++++++++++++++++---------
   trunk/tools/build/v2/util/numbers.jam | 81 ++++++++++++++++++++++-----------------
   trunk/tools/build/v2/util/sequence.jam | 75 ++++++++++++++++++++++--------------
   3 files changed, 124 insertions(+), 86 deletions(-)

Modified: trunk/tools/build/v2/util/assert.jam
==============================================================================
--- trunk/tools/build/v2/util/assert.jam (original)
+++ trunk/tools/build/v2/util/assert.jam 2008-05-03 19:27:00 EDT (Sat, 03 May 2008)
@@ -7,7 +7,9 @@
 import errors : error-skip-frames lol->list ;
 import modules ;
 
-# assert the equality of A and B
+
+# Assert the equality of A and B
+#
 rule equal ( a * : b * )
 {
     if $(a) != $(b)
@@ -16,8 +18,10 @@
     }
 }
 
-# assert that EXPECTED is the result of calling RULE-NAME with the
-# given arguments
+
+# Assert that EXPECTED is the result of calling RULE-NAME with the given
+# arguments.
+#
 rule result ( expected * : rule-name args * : * )
 {
     local result ;
@@ -37,6 +41,7 @@
     }
 }
 
+
 rule .set.equal ( set1 * : set2 * )
 {
     if ( $(set1) in $(set2) ) && ( $(set2) in $(set1) )
@@ -45,8 +50,10 @@
     }
 }
 
-# assert that EXPECTED is equal to the result of calling RULE-NAME with the
-# given arguments
+
+# Assert that EXPECTED is equal to the result of calling RULE-NAME with the
+# given arguments.
+#
 rule result-equal ( expected * : rule-name args * : * )
 {
     local result ;
@@ -66,7 +73,9 @@
     }
 }
 
-# assert that the given variable is nonempty.
+
+# Assert that the given variable is nonempty.
+#
 rule nonempty-variable ( name )
 {
     local value = [ modules.peek [ CALLER_MODULE ] : $(name) ] ;
@@ -77,9 +86,10 @@
     }
 }
 
-# assert that the result of calling RULE-NAME on the given arguments
-# has a true logical value (is neither an empty list nor all empty
-# strings).
+
+# Assert that the result of calling RULE-NAME on the given arguments has a true
+# logical value (is neither an empty list nor all empty strings).
+#
 rule true ( rule-name args * : * )
 {
     local result ;
@@ -99,29 +109,31 @@
     }
 }
 
-# assert that the result of calling RULE-NAME on the given arguments
-# has a false logical value (is either an empty list or all empty
-# strings).
+
+# Assert that the result of calling RULE-NAME on the given arguments has a false
+# logical value (is either an empty list or all empty strings).
+#
 rule false ( rule-name args * : * )
 {
     local result ;
     module [ CALLER_MODULE ]
     {
- modules.poke assert : result
- : [ $(1) : $(2) : $(3) : $(4)
- : $(5) : $(6) : $(7) : $(8) : $(9) ] ;
+ modules.poke assert : result : [ $(1) : $(2) : $(3) : $(4) : $(5) : $(6)
+ : $(7) : $(8) : $(9) ] ;
     }
 
     if $(result)
     {
         error-skip-frames 3 assertion failure: expecting false result from
- "[" $(rule-name)
- [ lol->list $(args) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ]
- "]" : got [ lol->list $(result) ] instead ;
+ "[" $(rule-name) [ lol->list $(args) : $(2) : $(3) : $(4) : $(5) :
+ $(6) : $(7) : $(8) : $(9) ] "]" : got [ lol->list $(result) ]
+ instead ;
     }
 }
 
-# assert that 'element' is present in 'list'.
+
+# Assert that 'element' is present in 'list'.
+#
 rule "in" ( element : list * )
 {
     if ! $(element) in $(list)
@@ -131,7 +143,9 @@
     }
 }
 
-# assert that 'element' is not present in 'list'.
+
+# Assert that 'element' is not present in 'list'.
+#
 rule not-in ( element : list * )
 {
     if $(element) in $(list)

Modified: trunk/tools/build/v2/util/numbers.jam
==============================================================================
--- trunk/tools/build/v2/util/numbers.jam (original)
+++ trunk/tools/build/v2/util/numbers.jam 2008-05-03 19:27:00 EDT (Sat, 03 May 2008)
@@ -1,7 +1,10 @@
-# Copyright 2001, 2002 Dave Abrahams
-# Copyright 2002, 2003 Vladimir Prus
-# 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)
+# Copyright 2001, 2002 Dave Abrahams
+# Copyright 2002, 2003 Vladimir Prus
+# 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)
+
+import errors ;
+
 
 digits = 0 1 2 3 4 5 6 7 8 9 ;
 powers = 1 ;
@@ -10,9 +13,8 @@
 positive = $(digits[2-]) ;
 incr = $(positive[2-]) ;
 znatural = $(digits) ;
-zero-test = is zero ; # if $(zero-test[$(n)]) == "is" "zero", n == 0
+zero-test = is zero ; # if $(zero-test[$(n)]) == "is" "zero", n == 0
 
-import errors : * ;
 
 local rule extend ( )
 {
@@ -23,6 +25,7 @@
     znatural = $(digits)$(znatural) ;
 }
 
+
 rule check ( numbers * )
 {
     for local n in $(numbers)
@@ -30,23 +33,24 @@
         switch $(n)
         {
             case *[^0-9]* :
- error $(n) "in" $(numbers) : is not a number ;
+ errors.error $(n) "in" $(numbers) : is not a number ;
         }
     }
 }
 
+
 rule increment ( number )
 {
     return [ CALC $(number) + 1 ] ;
 }
 
+
 rule decrement ( number )
 {
- # Previous rule did not allow decrementing zero.
- # Is that what we want?
     return [ CALC $(number) - 1 ] ;
 }
 
+
 rule range ( start finish ? : step ? )
 {
     if ! $(finish)
@@ -55,7 +59,7 @@
         start = 1 ;
     }
     step ?= 1 ;
-
+
     check $(start) $(finish) $(step) ;
 
     if $(finish) != 0
@@ -64,7 +68,7 @@
         {
             extend ;
         }
-
+
         if $(step) = 1
         {
             return $(positive[$(start)-$(finish)]) ;
@@ -84,26 +88,28 @@
     }
 }
 
+
 rule less ( n1 n2 )
 {
     check $(n1) $(n2) ;
- # avoid messy 0 case by appending 1
+ # Avoid messy 0 case by appending 1.
     local l1 = [ range 2 [ log10 $(n1)1 ] ] ;
     local l2 = [ range 2 [ log10 $(n2)1 ] ] ;
-
- # number of digits mismatch?
+
+ # Number of digits mismatch?
     if ( $(l1) < $(l2) ) || ( ( $(l1) = $(l2) ) && $(n1) < $(n2) )
     {
         return true ;
     }
 }
 
+
 rule log10 ( number )
 {
     switch $(number)
     {
- case *[^0-9]* : error $(number) is not a number ;
- case 0 : error can't take log of zero ;
+ case *[^0-9]* : errors.error $(number) is not a number ;
+ case 0 : errors.error can't take log of zero ;
         case [1-9] : return 0 ;
         case [1-9]? : return 1 ;
         case [1-9]?? : return 2 ;
@@ -123,10 +129,10 @@
             {
                 chars = $(chars[2-]) ;
             }
-
+
             if ! $(chars)
             {
- error can't take log of zero ;
+ errors.error can't take log of zero ;
             }
             else
             {
@@ -136,10 +142,11 @@
     }
 }
 
+
 rule __test__ ( )
 {
     import assert ;
-
+
     assert.result 1 : increment 0 ;
     assert.result 2 : increment 1 ;
     assert.result 1 : decrement 2 ;
@@ -149,10 +156,9 @@
     assert.result 99 : increment 98 ;
     assert.result 99 : decrement 100 ;
     assert.result 100 : increment 99 ;
- # This just makes debugging output too large
- # assert.result 1000 : increment 999 ;
- # assert.result 999 : decrement 1000 ;
-
+ assert.result 999 : decrement 1000 ;
+ assert.result 1000 : increment 999 ;
+
     assert.result 1 2 3 : range 3 ;
     assert.result 1 2 3 4 5 6 7 8 9 10 11 12 : range 12 ;
     assert.result 3 4 5 6 7 8 9 10 11 : range 3 11 ;
@@ -160,40 +166,43 @@
     assert.result 1 4 7 10 : range 10 : 3 ;
     assert.result 2 4 6 8 10 : range 2 10 : 2 ;
     assert.result 25 50 75 100 : range 25 100 : 25 ;
-
+
     assert.true less 1 2 ;
     assert.true less 1 12 ;
+ assert.true less 005 217 ;
+ assert.true less 0005 217 ;
+ assert.true less 5 00217 ;
     assert.true less 1 21 ;
     assert.false less 0 0 ;
-
- # TEMPORARY disabled, because nested "try"/"catch" do not work, I don't the
- # time to fix that right now.
- if $(0)
- {
+
+ # TEMPORARY disabled, because nested "try"/"catch" do not work and I do no
+ # have the time to fix that right now.
+ if $(0)
+ {
     try ;
     {
         decrement 0 ;
     }
     catch can't decrement zero! ;
-
+
     try ;
     {
         check foo ;
     }
     catch : not a number ;
-
+
     try ;
     {
         increment foo ;
     }
     catch : not a number ;
-
+
     try ;
     {
         log10 0 ;
     }
     catch can't take log of zero ;
-
+
     try ;
     {
         log10 000 ;
@@ -201,14 +210,14 @@
     catch can't take log of zero ;
 
     }
-
+
     assert.result 0 : log10 1 ;
     assert.result 0 : log10 9 ;
     assert.result 1 : log10 10 ;
     assert.result 1 : log10 99 ;
     assert.result 2 : log10 125 ;
     assert.result 11 : log10 12345678901 ;
-
+
     for local x in [ range 75 110 : 5 ]
     {
         for local y in [ range $(x) 111 : 3 ]
@@ -219,7 +228,7 @@
             }
         }
     }
-
+
     for local x in [ range 90 110 : 2 ]
     {
         for local y in [ range 80 $(x) : 4 ]

Modified: trunk/tools/build/v2/util/sequence.jam
==============================================================================
--- trunk/tools/build/v2/util/sequence.jam (original)
+++ trunk/tools/build/v2/util/sequence.jam 2008-05-03 19:27:00 EDT (Sat, 03 May 2008)
@@ -8,15 +8,17 @@
 import numbers ;
 import modules ;
 
-# Note that algorithms in this module execute largely in the caller's
-# module namespace, so that local rules can be used as function
-# objects. Also note that most predicates can be multi-element
-# lists. In that case, all but the first element are prepended to the
-# first argument which is passed to the rule named by the first
-# element.
 
-# Return the elements e of $(sequence) for which [ $(predicate) e ]
-# has a non-null value.
+# Note that algorithms in this module execute largely in the caller's module
+# namespace, so that local rules can be used as function objects. Also note that
+# most predicates can be multi-element lists. In that case, all but the first
+# element are prepended to the first argument which is passed to the rule named
+# by the first element.
+
+
+# Return the elements e of $(sequence) for which [ $(predicate) e ] has a
+# non-null value.
+#
 rule filter ( predicate + : sequence * )
 {
     local caller = [ CALLER_MODULE ] ;
@@ -32,8 +34,10 @@
     return $(result) ;
 }
 
-# return a new sequence consisting of [ $(function) $(e) ] for each
-# element e of $(sequence).
+
+# Return a new sequence consisting of [ $(function) $(e) ] for each element e of
+# $(sequence).
+#
 rule transform ( function + : sequence * )
 {
     local caller = [ CALLER_MODULE ] ;
@@ -46,6 +50,7 @@
     return $(result) ;
 }
 
+
 rule reverse ( s * )
 {
     local r ;
@@ -65,7 +70,9 @@
     }
 }
 
-# insertion-sort s using the BinaryPredicate ordered.
+
+# Insertion-sort s using the BinaryPredicate ordered.
+#
 rule insertion-sort ( s * : ordered * )
 {
     if ! $(ordered)
@@ -111,14 +118,17 @@
     }
 }
 
-# merge two ordered sequences using the BinaryPredicate ordered.
+
+# Merge two ordered sequences using the BinaryPredicate ordered.
+#
 rule merge ( s1 * : s2 * : ordered * )
 {
     ordered ?= sequence.less ;
     local result__ ;
     local caller = [ CALLER_MODULE ] ;
 
- while $(s1) && $(s2) {
+ while $(s1) && $(s2)
+ {
         if [ modules.call-in $(caller) : $(ordered) $(s1[1]) $(s2[1]) ]
         {
             result__ += $(s1[1]) ;
@@ -141,15 +151,19 @@
     return $(result__) ;
 }
 
-# join the elements of s into one long string. If joint is supplied,
-# it is used as a separator.
+
+# Join the elements of s into one long string. If joint is supplied, it is used
+# as a separator.
+#
 rule join ( s * : joint ? )
 {
     joint ?= "" ;
     return $(s:J=$(joint)) ;
 }
 
+
 # Find the length of any sequence.
+#
 rule length ( s * )
 {
     local result = 0 ;
@@ -160,6 +174,7 @@
     return $(result) ;
 }
 
+
 rule unique ( list * : stable ? )
 {
     local result ;
@@ -188,8 +203,10 @@
     return $(result) ;
 }
 
-# Returns the maximum number in 'elements'. Uses 'ordered' for comparisons,
-# or 'numbers.less' is none is provided.
+
+# Returns the maximum number in 'elements'. Uses 'ordered' for comparisons, or
+# 'numbers.less' is none is provided.
+#
 rule max-element ( elements + : ordered ? )
 {
     ordered ?= numbers.less ;
@@ -205,8 +222,10 @@
     return $(max) ;
 }
 
-# Returns all of 'elements' for which corresponding element in parallel
-# list 'rank' is equal to the maximum value in 'rank'.
+
+# Returns all of 'elements' for which corresponding element in parallel list
+# 'rank' is equal to the maximum value in 'rank'.
+#
 rule select-highest-ranked ( elements * : ranks * )
 {
     if $(elements)
@@ -230,7 +249,7 @@
 
 local rule __test__ ( )
 {
- # use a unique module so we can test the use of local rules.
+ # Use a unique module so we can test the use of local rules.
     module sequence.__test__
     {
         import assert ;
@@ -244,10 +263,9 @@
             }
         }
 
- assert.result 4 6 4 2 8
- : sequence.filter is-even : 1 4 6 3 4 7 2 3 8 ;
+ assert.result 4 6 4 2 8 : sequence.filter is-even : 1 4 6 3 4 7 2 3 8 ;
 
- # test that argument binding works
+ # Test that argument binding works.
         local rule is-equal-test ( x y )
         {
             if $(x) = $(y)
@@ -302,18 +320,15 @@
         local p2 = x ;
         for local i in 1 2 3 4 5 6 7 8
         {
- p2 = $(p2) $(p2) ;
+ p2 = $(p2) $(p2) ;
         }
         assert.result 256 : sequence.length $(p2) ;
 
- assert.result 1 2 3 4 5
- : sequence.unique 1 2 3 2 4 3 3 5 5 5 ;
+ assert.result 1 2 3 4 5 : sequence.unique 1 2 3 2 4 3 3 5 5 5 ;
                 
- assert.result 5
- : sequence.max-element 1 3 5 0 4 ;
+ assert.result 5 : sequence.max-element 1 3 5 0 4 ;
         
- assert.result e-3 h-3
- : sequence.select-highest-ranked e-1 e-3 h-3 m-2 : 1 3 3 2 ;
+ assert.result e-3 h-3 : sequence.select-highest-ranked e-1 e-3 h-3 m-2 : 1 3 3 2 ;
         
         assert.result 7 6 5 4 3 2 1 : sequence.reverse 1 2 3 4 5 6 7 ;
     }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk