mirror of
https://github.com/boostorg/build.git
synced 2026-02-15 00:52:16 +00:00
some small progress made
[SVN r11760]
This commit is contained in:
@@ -3,22 +3,17 @@
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
rule report-module ( prefix ? : suffix ? )
|
||||
{
|
||||
# We report some large line number so that emacs, etc., will at least locate the file.
|
||||
ECHO $(prefix) [ modules.binding [ CALLER_MODULE 1 ] ] ":" line 99999 $(suffix) ;
|
||||
}
|
||||
import errors : error ;
|
||||
|
||||
rule equal ( a * : b * )
|
||||
{
|
||||
if $(a) != $(b)
|
||||
{
|
||||
report-module ;
|
||||
EXIT assertion failure: \"$(a)\" "!=" \"$(b)\" ;
|
||||
error assertion failure: \"$(a)\" "!=" \"$(b)\" ;
|
||||
}
|
||||
}
|
||||
|
||||
rule Rule ( rule-name args * : expected * )
|
||||
rule result ( expected * : rule-name args * )
|
||||
{
|
||||
|
||||
module [ CALLER_MODULE ]
|
||||
@@ -28,20 +23,18 @@ rule Rule ( rule-name args * : expected * )
|
||||
|
||||
if $(result) != $(expected)
|
||||
{
|
||||
report-module ;
|
||||
ECHO assertion failure: "[" $(rule-name) \"$(args)\" "]" ;
|
||||
ECHO expected: \"$(expected)\" ;
|
||||
EXIT got: \"$(result)\" ;
|
||||
error assertion failure: "[" $(rule-name) \"$(args)\" "]"
|
||||
: expected: \"$(expected)\"
|
||||
: got: \"$(result)\" ;
|
||||
}
|
||||
}
|
||||
|
||||
rule nonempty-variable ( name )
|
||||
{
|
||||
local empty ;
|
||||
if $($(variable)) = $(empty)
|
||||
if $($(variable)) = $(empty)
|
||||
{
|
||||
report-module ;
|
||||
EXIT assertion failure, expecting non-empty variable $(variable) ;
|
||||
error assertion failure: expecting non-empty variable $(variable) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,17 +49,8 @@ rule true ( rule-name args * )
|
||||
|
||||
if ! $(result)
|
||||
{
|
||||
report-module ;
|
||||
EXIT assertion failure, expecting true result from
|
||||
error assertion failure: expecting true result from
|
||||
"[" $(rule-name) \"$(args)\" "]" ;
|
||||
}
|
||||
}
|
||||
|
||||
# Get around the capitalized naming (required to avoid a clash with the rule
|
||||
# keyword) by importing Rule into the global namespace as assert.rule
|
||||
IMPORT : assert : Rule : assert.rule ;
|
||||
|
||||
rule __test__ ( )
|
||||
{
|
||||
# no tests yet for assertions
|
||||
}
|
||||
|
||||
46
new/errors.jam
Normal file
46
new/errors.jam
Normal file
@@ -0,0 +1,46 @@
|
||||
# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears in
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
# A utility rule used to report the including module when there is an error, so
|
||||
# that editors may find it.
|
||||
rule report-module ( prefix ? : suffix ? : frames ? )
|
||||
{
|
||||
frames ?= 1 ;
|
||||
# We report some large line number so that emacs, etc., will at least locate the file.
|
||||
ECHO $(prefix) [ modules.binding [ CALLER_MODULE $(frames) ] ] ":" line 99999 $(suffix) ;
|
||||
}
|
||||
|
||||
rule backtrace
|
||||
{
|
||||
local digits = 1 2 3 4 5 6 7 8 9 ;
|
||||
local bt = [ BACKTRACE ] ;
|
||||
bt = $(bt[5-]) ;
|
||||
while $(bt)
|
||||
{
|
||||
ECHO $(bt[1]):$(bt[2]): "in" $(bt[4]) ;
|
||||
|
||||
for local n in $(digits)
|
||||
{
|
||||
if $($(n))-is-not-empty
|
||||
{
|
||||
ECHO $($(n)) ;
|
||||
}
|
||||
}
|
||||
digits = ;
|
||||
|
||||
bt = $(bt[5-]) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule error
|
||||
{
|
||||
backtrace error: $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
|
||||
EXIT ;
|
||||
}
|
||||
|
||||
rule warning
|
||||
{
|
||||
backtrace warning: $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
|
||||
}
|
||||
@@ -4,10 +4,11 @@
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
# Keep a record so that no module is included multiple times
|
||||
module local imported-modules ;
|
||||
module local loaded-modules ;
|
||||
|
||||
# meant to be invoked from
|
||||
rule no_test_defined
|
||||
# meant to be invoked from import when no __test__ rule is defined in a given
|
||||
# module
|
||||
local rule no_test_defined
|
||||
{
|
||||
ECHO warning: no __test__ rule defined in module [ CALLER_MODULE ] ;
|
||||
}
|
||||
@@ -25,15 +26,19 @@ rule binding ( module )
|
||||
# module are imported into the caller's module.
|
||||
rule import ( module-name : rules-opt * : rename-opt * )
|
||||
{
|
||||
|
||||
if ! ( $(module-name) in $(imported-modules) )
|
||||
# First see if the module needs to be loaded
|
||||
if ! ( $(module-name) in $(loaded-modules) )
|
||||
{
|
||||
imported-modules += $(module-name) ;
|
||||
loaded-modules += $(module-name) ;
|
||||
|
||||
module $(module-name)
|
||||
{
|
||||
module local __name__ = $(module-name) ;
|
||||
|
||||
# Prepare a default behavior, in case no __test__ is defined.
|
||||
IMPORT $(module-name) : modules : no_test_defined : __test__ ;
|
||||
|
||||
# Add some grist so that the module will have a unique target name
|
||||
local module-target = $(module-name:G=module@:S=.jam) ;
|
||||
|
||||
SEARCH on $(module-target) = $(BOOST_BUILD_PATH) ;
|
||||
@@ -41,13 +46,15 @@ rule import ( module-name : rules-opt * : rename-opt * )
|
||||
include $(module-name:G=module@:S=.jam) ;
|
||||
|
||||
# run the module's test, if any.
|
||||
if $(BOOST_BUILD_TEST)
|
||||
if nonempty$(BOOST_BUILD_TEST)
|
||||
{
|
||||
ECHO testing module $(module-name)... ;
|
||||
local ignored = [ __test__ ] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# If any rules are to be imported, do so now.
|
||||
if $(rules-opt)
|
||||
{
|
||||
if $(rules-opt) = *
|
||||
@@ -59,8 +66,28 @@ rule import ( module-name : rules-opt * : rename-opt * )
|
||||
}
|
||||
}
|
||||
|
||||
# This helper is used by import (above) to record the binding (path) of
|
||||
# each loaded module.
|
||||
rule record-binding ( module-target : binding )
|
||||
{
|
||||
module local $(module-target:G=:S=).__binding__ = $(binding) ;
|
||||
}
|
||||
|
||||
# Returns the module-local value of a variable.
|
||||
rule peek ( module-name variable )
|
||||
{
|
||||
module $(module-name)
|
||||
{
|
||||
return $($(variable)) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule __test__ ( )
|
||||
{
|
||||
import assert ;
|
||||
module modules.__test__
|
||||
{
|
||||
module local foo = bar ;
|
||||
}
|
||||
assert.result bar : peek modules.__test__ foo ;
|
||||
}
|
||||
59
new/numbers.jam
Normal file
59
new/numbers.jam
Normal file
@@ -0,0 +1,59 @@
|
||||
# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears in
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
module local digits = 0 1 2 3 4 5 6 7 8 9 ;
|
||||
module local powers = 1 ;
|
||||
module local zeros = "" ;
|
||||
module local natural = $(digits) ;
|
||||
module local znatural = $(digits) ;
|
||||
|
||||
local rule extend ( )
|
||||
{
|
||||
natural += $(digits[2-])$(znatural) ;
|
||||
znatural = $(digits)$(znatural) ;
|
||||
}
|
||||
|
||||
rule increment ( number )
|
||||
{
|
||||
local r = $(natural[$(number)-]) ;
|
||||
local x = $(r[3]) ;
|
||||
if ( $(x) )
|
||||
{
|
||||
return $(x) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
extend ;
|
||||
return [ increment $(number) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
rule decrement ( number )
|
||||
{
|
||||
local x = $(natural[$(number)]) ;
|
||||
if ( $(x) )
|
||||
{
|
||||
return $(x) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
extend ;
|
||||
return [ decrement $(number) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
rule __test__ ( )
|
||||
{
|
||||
import assert ;
|
||||
assert.result 2 : increment 1 ;
|
||||
assert.result 1 : decrement 2 ;
|
||||
assert.result 50 : increment 49 ;
|
||||
assert.result 49 : decrement 50 ;
|
||||
assert.result 99 : increment 98 ;
|
||||
assert.result 99 : decrement 100 ;
|
||||
assert.result 100 : increment 99 ;
|
||||
assert.result 1000 : increment 999 ;
|
||||
assert.result 999 : decrement 1000 ;
|
||||
}
|
||||
@@ -25,10 +25,10 @@ rule __test__ ( )
|
||||
{
|
||||
import assert ;
|
||||
|
||||
assert.rule split "a/b/c" / : a b c ;
|
||||
assert.rule split "/a/b/c" / : a b c ;
|
||||
assert.rule split "//a/b/c" / : "" a b c ;
|
||||
assert.rule split "/a//b/c" / : a "" b c ;
|
||||
assert.rule split "/a//b/c/" / : a "" b c "" ;
|
||||
assert.rule split "/a//b/c//" / : a "" b c "" "" ;
|
||||
assert.result a b c : split "a/b/c" / ;
|
||||
assert.result a b c : split "/a/b/c" / ;
|
||||
assert.result "" a b c : split "//a/b/c" / ;
|
||||
assert.result a "" b c : split "/a//b/c" / ;
|
||||
assert.result a "" b c "" : split "/a//b/c/" / ;
|
||||
assert.result a "" b c "" "" : split "/a//b/c//" / ;
|
||||
}
|
||||
31
new/set.jam
Normal file
31
new/set.jam
Normal file
@@ -0,0 +1,31 @@
|
||||
# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears in
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
# difference
|
||||
# returns the elements of B that are not in A
|
||||
rule difference ( B * : A * )
|
||||
{
|
||||
local result = ;
|
||||
local element ;
|
||||
for element in $(B)
|
||||
{
|
||||
if ! ( $(element) in $(A) )
|
||||
{
|
||||
result += $(element) ;
|
||||
}
|
||||
}
|
||||
return $(result) ;
|
||||
}
|
||||
|
||||
rule __test__ ( )
|
||||
{
|
||||
import assert ;
|
||||
|
||||
assert.result 0 1 4 6 8 9
|
||||
: difference 0 1 2 3 4 5 6 7 8 9 : 2 3 5 7 ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
27
new/ultility.jam
Normal file
27
new/ultility.jam
Normal file
@@ -0,0 +1,27 @@
|
||||
# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears in
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
rule ungrist ( names * )
|
||||
{
|
||||
local result ;
|
||||
for local name in $(names)
|
||||
{
|
||||
local stripped = [ SUBST $(name) ^<(.*)>$ $1 ] ;
|
||||
if ! $(stripped)
|
||||
{
|
||||
ECHO *** error: in ungrist $(names) ;
|
||||
EXIT *** $(name) is not of the form <.*> ;
|
||||
}
|
||||
result += $(stripped) ;
|
||||
}
|
||||
return $(result) ;
|
||||
}
|
||||
|
||||
rule __test__
|
||||
{
|
||||
import assert ;
|
||||
assert.result foo bar : ungrist <foo> <bar> ;
|
||||
}
|
||||
|
||||
46
v2/errors.jam
Normal file
46
v2/errors.jam
Normal file
@@ -0,0 +1,46 @@
|
||||
# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears in
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
# A utility rule used to report the including module when there is an error, so
|
||||
# that editors may find it.
|
||||
rule report-module ( prefix ? : suffix ? : frames ? )
|
||||
{
|
||||
frames ?= 1 ;
|
||||
# We report some large line number so that emacs, etc., will at least locate the file.
|
||||
ECHO $(prefix) [ modules.binding [ CALLER_MODULE $(frames) ] ] ":" line 99999 $(suffix) ;
|
||||
}
|
||||
|
||||
rule backtrace
|
||||
{
|
||||
local digits = 1 2 3 4 5 6 7 8 9 ;
|
||||
local bt = [ BACKTRACE ] ;
|
||||
bt = $(bt[5-]) ;
|
||||
while $(bt)
|
||||
{
|
||||
ECHO $(bt[1]):$(bt[2]): "in" $(bt[4]) ;
|
||||
|
||||
for local n in $(digits)
|
||||
{
|
||||
if $($(n))-is-not-empty
|
||||
{
|
||||
ECHO $($(n)) ;
|
||||
}
|
||||
}
|
||||
digits = ;
|
||||
|
||||
bt = $(bt[5-]) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule error
|
||||
{
|
||||
backtrace error: $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
|
||||
EXIT ;
|
||||
}
|
||||
|
||||
rule warning
|
||||
{
|
||||
backtrace warning: $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
|
||||
}
|
||||
@@ -4,10 +4,11 @@
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
# Keep a record so that no module is included multiple times
|
||||
module local imported-modules ;
|
||||
module local loaded-modules ;
|
||||
|
||||
# meant to be invoked from
|
||||
rule no_test_defined
|
||||
# meant to be invoked from import when no __test__ rule is defined in a given
|
||||
# module
|
||||
local rule no_test_defined
|
||||
{
|
||||
ECHO warning: no __test__ rule defined in module [ CALLER_MODULE ] ;
|
||||
}
|
||||
@@ -25,15 +26,19 @@ rule binding ( module )
|
||||
# module are imported into the caller's module.
|
||||
rule import ( module-name : rules-opt * : rename-opt * )
|
||||
{
|
||||
|
||||
if ! ( $(module-name) in $(imported-modules) )
|
||||
# First see if the module needs to be loaded
|
||||
if ! ( $(module-name) in $(loaded-modules) )
|
||||
{
|
||||
imported-modules += $(module-name) ;
|
||||
loaded-modules += $(module-name) ;
|
||||
|
||||
module $(module-name)
|
||||
{
|
||||
module local __name__ = $(module-name) ;
|
||||
|
||||
# Prepare a default behavior, in case no __test__ is defined.
|
||||
IMPORT $(module-name) : modules : no_test_defined : __test__ ;
|
||||
|
||||
# Add some grist so that the module will have a unique target name
|
||||
local module-target = $(module-name:G=module@:S=.jam) ;
|
||||
|
||||
SEARCH on $(module-target) = $(BOOST_BUILD_PATH) ;
|
||||
@@ -41,13 +46,15 @@ rule import ( module-name : rules-opt * : rename-opt * )
|
||||
include $(module-name:G=module@:S=.jam) ;
|
||||
|
||||
# run the module's test, if any.
|
||||
if $(BOOST_BUILD_TEST)
|
||||
if nonempty$(BOOST_BUILD_TEST)
|
||||
{
|
||||
ECHO testing module $(module-name)... ;
|
||||
local ignored = [ __test__ ] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# If any rules are to be imported, do so now.
|
||||
if $(rules-opt)
|
||||
{
|
||||
if $(rules-opt) = *
|
||||
@@ -59,8 +66,28 @@ rule import ( module-name : rules-opt * : rename-opt * )
|
||||
}
|
||||
}
|
||||
|
||||
# This helper is used by import (above) to record the binding (path) of
|
||||
# each loaded module.
|
||||
rule record-binding ( module-target : binding )
|
||||
{
|
||||
module local $(module-target:G=:S=).__binding__ = $(binding) ;
|
||||
}
|
||||
|
||||
# Returns the module-local value of a variable.
|
||||
rule peek ( module-name variable )
|
||||
{
|
||||
module $(module-name)
|
||||
{
|
||||
return $($(variable)) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule __test__ ( )
|
||||
{
|
||||
import assert ;
|
||||
module modules.__test__
|
||||
{
|
||||
module local foo = bar ;
|
||||
}
|
||||
assert.result bar : peek modules.__test__ foo ;
|
||||
}
|
||||
27
v2/ultility.jam
Normal file
27
v2/ultility.jam
Normal file
@@ -0,0 +1,27 @@
|
||||
# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears in
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
rule ungrist ( names * )
|
||||
{
|
||||
local result ;
|
||||
for local name in $(names)
|
||||
{
|
||||
local stripped = [ SUBST $(name) ^<(.*)>$ $1 ] ;
|
||||
if ! $(stripped)
|
||||
{
|
||||
ECHO *** error: in ungrist $(names) ;
|
||||
EXIT *** $(name) is not of the form <.*> ;
|
||||
}
|
||||
result += $(stripped) ;
|
||||
}
|
||||
return $(result) ;
|
||||
}
|
||||
|
||||
rule __test__
|
||||
{
|
||||
import assert ;
|
||||
assert.result foo bar : ungrist <foo> <bar> ;
|
||||
}
|
||||
|
||||
@@ -3,22 +3,17 @@
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
rule report-module ( prefix ? : suffix ? )
|
||||
{
|
||||
# We report some large line number so that emacs, etc., will at least locate the file.
|
||||
ECHO $(prefix) [ modules.binding [ CALLER_MODULE 1 ] ] ":" line 99999 $(suffix) ;
|
||||
}
|
||||
import errors : error ;
|
||||
|
||||
rule equal ( a * : b * )
|
||||
{
|
||||
if $(a) != $(b)
|
||||
{
|
||||
report-module ;
|
||||
EXIT assertion failure: \"$(a)\" "!=" \"$(b)\" ;
|
||||
error assertion failure: \"$(a)\" "!=" \"$(b)\" ;
|
||||
}
|
||||
}
|
||||
|
||||
rule Rule ( rule-name args * : expected * )
|
||||
rule result ( expected * : rule-name args * )
|
||||
{
|
||||
|
||||
module [ CALLER_MODULE ]
|
||||
@@ -28,20 +23,18 @@ rule Rule ( rule-name args * : expected * )
|
||||
|
||||
if $(result) != $(expected)
|
||||
{
|
||||
report-module ;
|
||||
ECHO assertion failure: "[" $(rule-name) \"$(args)\" "]" ;
|
||||
ECHO expected: \"$(expected)\" ;
|
||||
EXIT got: \"$(result)\" ;
|
||||
error assertion failure: "[" $(rule-name) \"$(args)\" "]"
|
||||
: expected: \"$(expected)\"
|
||||
: got: \"$(result)\" ;
|
||||
}
|
||||
}
|
||||
|
||||
rule nonempty-variable ( name )
|
||||
{
|
||||
local empty ;
|
||||
if $($(variable)) = $(empty)
|
||||
if $($(variable)) = $(empty)
|
||||
{
|
||||
report-module ;
|
||||
EXIT assertion failure, expecting non-empty variable $(variable) ;
|
||||
error assertion failure: expecting non-empty variable $(variable) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,17 +49,8 @@ rule true ( rule-name args * )
|
||||
|
||||
if ! $(result)
|
||||
{
|
||||
report-module ;
|
||||
EXIT assertion failure, expecting true result from
|
||||
error assertion failure: expecting true result from
|
||||
"[" $(rule-name) \"$(args)\" "]" ;
|
||||
}
|
||||
}
|
||||
|
||||
# Get around the capitalized naming (required to avoid a clash with the rule
|
||||
# keyword) by importing Rule into the global namespace as assert.rule
|
||||
IMPORT : assert : Rule : assert.rule ;
|
||||
|
||||
rule __test__ ( )
|
||||
{
|
||||
# no tests yet for assertions
|
||||
}
|
||||
|
||||
59
v2/util/numbers.jam
Normal file
59
v2/util/numbers.jam
Normal file
@@ -0,0 +1,59 @@
|
||||
# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears in
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
module local digits = 0 1 2 3 4 5 6 7 8 9 ;
|
||||
module local powers = 1 ;
|
||||
module local zeros = "" ;
|
||||
module local natural = $(digits) ;
|
||||
module local znatural = $(digits) ;
|
||||
|
||||
local rule extend ( )
|
||||
{
|
||||
natural += $(digits[2-])$(znatural) ;
|
||||
znatural = $(digits)$(znatural) ;
|
||||
}
|
||||
|
||||
rule increment ( number )
|
||||
{
|
||||
local r = $(natural[$(number)-]) ;
|
||||
local x = $(r[3]) ;
|
||||
if ( $(x) )
|
||||
{
|
||||
return $(x) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
extend ;
|
||||
return [ increment $(number) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
rule decrement ( number )
|
||||
{
|
||||
local x = $(natural[$(number)]) ;
|
||||
if ( $(x) )
|
||||
{
|
||||
return $(x) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
extend ;
|
||||
return [ decrement $(number) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
rule __test__ ( )
|
||||
{
|
||||
import assert ;
|
||||
assert.result 2 : increment 1 ;
|
||||
assert.result 1 : decrement 2 ;
|
||||
assert.result 50 : increment 49 ;
|
||||
assert.result 49 : decrement 50 ;
|
||||
assert.result 99 : increment 98 ;
|
||||
assert.result 99 : decrement 100 ;
|
||||
assert.result 100 : increment 99 ;
|
||||
assert.result 1000 : increment 999 ;
|
||||
assert.result 999 : decrement 1000 ;
|
||||
}
|
||||
@@ -25,10 +25,10 @@ rule __test__ ( )
|
||||
{
|
||||
import assert ;
|
||||
|
||||
assert.rule split "a/b/c" / : a b c ;
|
||||
assert.rule split "/a/b/c" / : a b c ;
|
||||
assert.rule split "//a/b/c" / : "" a b c ;
|
||||
assert.rule split "/a//b/c" / : a "" b c ;
|
||||
assert.rule split "/a//b/c/" / : a "" b c "" ;
|
||||
assert.rule split "/a//b/c//" / : a "" b c "" "" ;
|
||||
assert.result a b c : split "a/b/c" / ;
|
||||
assert.result a b c : split "/a/b/c" / ;
|
||||
assert.result "" a b c : split "//a/b/c" / ;
|
||||
assert.result a "" b c : split "/a//b/c" / ;
|
||||
assert.result a "" b c "" : split "/a//b/c/" / ;
|
||||
assert.result a "" b c "" "" : split "/a//b/c//" / ;
|
||||
}
|
||||
31
v2/util/set.jam
Normal file
31
v2/util/set.jam
Normal file
@@ -0,0 +1,31 @@
|
||||
# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears in
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
# difference
|
||||
# returns the elements of B that are not in A
|
||||
rule difference ( B * : A * )
|
||||
{
|
||||
local result = ;
|
||||
local element ;
|
||||
for element in $(B)
|
||||
{
|
||||
if ! ( $(element) in $(A) )
|
||||
{
|
||||
result += $(element) ;
|
||||
}
|
||||
}
|
||||
return $(result) ;
|
||||
}
|
||||
|
||||
rule __test__ ( )
|
||||
{
|
||||
import assert ;
|
||||
|
||||
assert.result 0 1 4 6 8 9
|
||||
: difference 0 1 2 3 4 5 6 7 8 9 : 2 3 5 7 ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user