2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-15 00:52:16 +00:00
Files
build/new/assert.jam
Dave Abrahams cb9dee8347 initial commit
[SVN r11695]
2001-11-14 21:24:42 +00:00

73 lines
1.8 KiB
Plaintext

# (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 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) ;
}
rule equal ( a * : b * )
{
if $(a) != $(b)
{
report-module ;
EXIT assertion failure: \"$(a)\" "!=" \"$(b)\" ;
}
}
rule Rule ( rule-name args * : expected * )
{
module [ CALLER_MODULE ]
{
result = [ $(rule-name) $(args) ] ;
}
if $(result) != $(expected)
{
report-module ;
ECHO assertion failure: "[" $(rule-name) \"$(args)\" "]" ;
ECHO expected: \"$(expected)\" ;
EXIT got: \"$(result)\" ;
}
}
rule nonempty-variable ( name )
{
local empty ;
if $($(variable)) = $(empty)
{
report-module ;
EXIT assertion failure, expecting non-empty variable $(variable) ;
}
}
rule true ( rule-name args * )
{
local result caller-module = [ CALLER_MODULE ] ;
module $(caller-module)
{
result = [ $(rule-name) $(args) ] ;
}
if ! $(result)
{
report-module ;
EXIT 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
}