compares with anything
Example 6-4. examples/intro/cmp_ok.t
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 2;
my $start = time;
wait_for_input_with_timeout(3);
my $end = time;
cmp_ok $end - $start, ">=", 2, "process was waiting at least 2 secs";
cmp_ok $end - $start, "<=", 3, "process was waiting at most 3 secs";
sub wait_for_input_with_timeout {
sleep rand shift;
}$ perl cmp_ok.t not ok 1 - process was waiting enough # Failed test (cmp_ok.t at line 7) # '0' # >= # '2' ok 2 - process was waiting enough 1..2 # Looks like you failed 1 tests of 2.
| Prev | Home (Copyright Gabor Szabo) Perl Training Israel | Next |
| like(value, qr/expected regex/, name); | Up | is_deeply( complex_structure, expected_complex structure, name); |