- Timestamp:
- 01/25/08 00:24:31 (12 months ago)
- Files:
-
- 1 modified
-
ext/Test/lib/Test.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ext/Test/lib/Test.pm
r19582 r19676 3 3 use v6-alpha; 4 4 5 module Test-0.0. 7;5 module Test-0.0.8; 6 6 7 7 #if substr($*PROGRAM_NAME, -2) eq '.t' { … … 53 53 ### FUNCTIONS 54 54 55 # Compare numeric values with approximation 56 57 sub approx (Num $a, Num $b) returns Bool is export { 58 my $EPSILON = 0.00001; 59 (abs($a - $b) < $EPSILON); 60 } 61 55 62 ## plan 56 63 … … 87 94 } 88 95 96 ## is_approx Approximately compare two Nums 97 98 sub is_approx(Num $got, Num $expected, Str $desc?, :$todo, $:depends) returns Bool is export { 99 my $test := Test::approx($got, $expected); 100 Test::proclaim($test, $desc, $todo, $got, $expected, $depends); 101 } 89 102 90 103 ## isnt … … 389 402 ok(2 + 2 == 5, '2 and 2 make 5', :todo(1)); 390 403 is(2 + 2, 5, desc => '2 and 2 make 5', todo => 1); 404 is_approx(pi(), 3.141562, 'approximate compare'); 391 405 isa_ok({'one' => 1}, 'Hash', :todo(1)); 392 406 … … 509 523 510 524 The code must at least be parsable. If the code might not parse, wrap it in C<eval>. 525 526 =head3 is_approx 527 528 is_approx (Num $got, Num $expected, Str $desc?, Bool :$todo, Str :$depends) returns Bool 529 530 Similar to is(), but compares approximately, to account for floating point 531 precision errors. 511 532 512 533 =head3 is_deeply … … 680 701 Simon Sun <dolmens@gmail.com> 681 702 703 Cosimo Streppone <cosimo@cpan.org> 704 682 705 =head1 COPYRIGHT 683 706
