File: is_equal_to.t

package info (click to toggle)
libdata-validate-perl 0.09-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 172 kB
  • sloc: perl: 397; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl

# -------------------------------------------------------------------------------
# test harness for Data::Validate::is_equal_to
#
# Author: Richard Sonnen (http://www.richardsonnen.com/)
# -------------------------------------------------------------------------------

use lib './t';
use ExtUtils::TBone;

use lib './blib';
use Data::Validate qw(is_equal_to);

my $t = ExtUtils::TBone->typical();

$t->begin(8);
$t->msg("testing is_equal_to...");

# integer
$t->ok(defined(is_equal_to(5, 5)), "5 == 5");
$t->ok(!defined(is_equal_to(5, 10)), "5 != 10");

# float
$t->ok(defined(is_equal_to(5.5, 5.5)), "5.5 == 5.5");
$t->ok(!defined(is_equal_to(5.5, 5.6)), "5.5 != 5.6");

# string
$t->ok(defined(is_equal_to('foo', 'foo')), "foo eq foo");
$t->ok(!defined(is_equal_to('foo', 'bar')), "foo ne bar");

# as an object
my $v = Data::Validate->new();
$t->ok(defined($v->is_equal_to(5, 5)), "5 == 5 (object)");
$t->ok(!defined($v->is_equal_to(5, 10)), "5 != 10 (object)");

# we're done
$t->end();