@@ -415,6 +415,7 @@ pub fn core_macros() -> ~str {
415
415
__log( 1u32 , fmt!( $( $arg) ,+ ) )
416
416
)
417
417
)
418
+
418
419
macro_rules! warn (
419
420
( $arg: expr) => (
420
421
__log( 2u32 , fmt!( \"%?\" , $arg ) )
@@ -423,6 +424,7 @@ pub fn core_macros() -> ~str {
423
424
__log( 2u32 , fmt!( $( $arg) ,+ ) )
424
425
)
425
426
)
427
+
426
428
macro_rules! info (
427
429
( $arg: expr) => (
428
430
__log( 3u32 , fmt!( \"%?\" , $arg ) )
@@ -431,6 +433,7 @@ pub fn core_macros() -> ~str {
431
433
__log( 3u32 , fmt!( $( $arg) ,+ ) )
432
434
)
433
435
)
436
+
434
437
macro_rules! debug (
435
438
( $arg: expr) => (
436
439
__log( 4u32 , fmt!( \"%?\" , $arg ) )
@@ -441,35 +444,48 @@ pub fn core_macros() -> ~str {
441
444
)
442
445
443
446
macro_rules! fail(
444
- ( $msg: expr) => (
445
- :: core:: sys:: begin_unwind( $msg, file!( ) . to_owned( ) , line!( ) )
446
- ) ;
447
447
( ) => (
448
- fail!( ~\" explicit failure\" )
448
+ fail!( \" explicit failure\" )
449
+ ) ;
450
+ ( $msg: expr) => (
451
+ :: core:: sys:: FailWithCause :: fail_with( $msg, file!( ) , line!( ) )
452
+ ) ;
453
+ ( $( $arg: expr ) ,+) => (
454
+ :: core:: sys:: FailWithCause :: fail_with( fmt!( $( $arg) ,+ ) , file!( ) , line!( ) )
449
455
)
450
456
)
451
457
452
458
macro_rules! assert(
453
459
( $cond: expr) => {
454
460
if !$cond {
455
- :: core:: sys:: fail_assert( stringify!( $cond) , file!( ) , line!( ) )
461
+ :: core:: sys:: FailWithCause :: fail_with(
462
+ ~\" assertion failed: \" + stringify!( $cond) , file!( ) , line!( ) )
456
463
}
457
464
} ;
458
465
( $cond: expr, $msg: expr) => {
459
466
if !$cond {
460
- :: core:: sys:: fail_assert( $msg, file!( ) , line!( ) )
467
+ :: core:: sys:: FailWithCause :: fail_with( $msg, file!( ) , line!( ) )
468
+ }
469
+ } ;
470
+ ( $cond: expr, $( $arg: expr ) ,+) => {
471
+ if !$cond {
472
+ :: core:: sys:: FailWithCause :: fail_with( fmt!( $( $arg) ,+ ) , file!( ) , line!( ) )
461
473
}
462
474
}
463
475
)
464
476
465
477
macro_rules! assert_eq (
466
- ( $given: expr , $expected: expr) =>
467
- ( { let given_val = $given;
468
- let expected_val = $expected;
469
- // check both directions of equality....
470
- if !( ( given_val == expected_val) && ( expected_val == given_val) ) {
471
- fail!( fmt!( \" expected: %?, given: %?\" , expected_val, given_val) ) ;
472
- } } ) )
478
+ ( $given: expr , $expected: expr) => (
479
+ {
480
+ let given_val = $given;
481
+ let expected_val = $expected;
482
+ // check both directions of equality....
483
+ if !( ( given_val == expected_val) && ( expected_val == given_val) ) {
484
+ fail!( fmt!( \" left: %? != right: %?\" , given_val, expected_val) ) ;
485
+ }
486
+ }
487
+ )
488
+ )
473
489
474
490
macro_rules! condition (
475
491
0 commit comments