summaryrefslogtreecommitdiff
path: root/ext/XS-Typemap
diff options
context:
space:
mode:
authorSteffen Mueller <smueller@cpan.org>2012-02-03 07:53:15 +0100
committerSteffen Mueller <smueller@cpan.org>2012-02-03 08:16:22 +0100
commit864fd8d30af274c82a36ddaf90ed55c91f64ebc7 (patch)
treea709c7536740e362067785f653fd15e92b4ebfbc /ext/XS-Typemap
parentbd3355a0d9e78c45f86019cf966f493394b2dbff (diff)
downloadperl-864fd8d30af274c82a36ddaf90ed55c91f64ebc7.tar.gz
XS::Typemap: Fix tests with -Dusemorebits
Thanks, Karl, for spotting this sillyness!
Diffstat (limited to 'ext/XS-Typemap')
-rw-r--r--ext/XS-Typemap/t/Typemap.t39
1 files changed, 31 insertions, 8 deletions
diff --git a/ext/XS-Typemap/t/Typemap.t b/ext/XS-Typemap/t/Typemap.t
index 2baa1cbbec..2a3f25e95f 100644
--- a/ext/XS-Typemap/t/Typemap.t
+++ b/ext/XS-Typemap/t/Typemap.t
@@ -6,7 +6,7 @@ BEGIN {
}
}
-use Test::More tests => 114;
+use Test::More tests => 140;
use strict;
use warnings;
@@ -283,9 +283,14 @@ for (0..$#opq) {
note("T_PACKED");
my $struct = T_PACKED_out(-4, 3, 2.1);
ok(ref($struct) eq 'HASH');
-is_deeply($struct, {a => -4, b => 3, c => 2.1});
+is_approx($struct->{a}, -4);
+is_approx($struct->{b}, 3);
+is_approx($struct->{c}, 2.1);
my @rv = T_PACKED_in($struct);
-is_deeply(\@rv, [-4, 3, 2.1]);
+is(scalar(@rv), 3);
+is_approx($rv[0], -4);
+is_approx($rv[1], 3);
+is_approx($rv[2], 2.1);
# T_PACKEDARRAY
SCOPE: {
@@ -299,12 +304,19 @@ SCOPE: {
push @out, {a => $d[$_*3], b => $d[$_*3+1], c => $d[$_*3+2]} for (0..2);
my $structs = T_PACKEDARRAY_out(@d);
ok(ref($structs) eq 'ARRAY');
- is_deeply(
- $structs,
- \@out
- );
+ is(scalar(@$structs), 3);
+ foreach my $i (0..2) {
+ my $s = $structs->[$i];
+ is(ref($s), 'HASH');
+ is_approx($s->{a}, $d[$i*3+0]);
+ is_approx($s->{b}, $d[$i*3+1]);
+ is_approx($s->{c}, $d[$i*3+2]);
+ }
my @rv = T_PACKEDARRAY_in($structs);
- is_deeply(\@rv, \@d);
+ is(scalar(@rv), scalar(@d));
+ foreach my $i (0..$#d) {
+ is_approx($rv[$i], $d[$i]);
+ }
}
# Skip T_DATAUNIT
@@ -394,3 +406,14 @@ SCOPE: {
is(readline($fh2), $str);
ok(eval {print $fh2 "foo\n"; 1});
}
+
+sub is_approx {
+ my ($l, $r, $n) = @_;
+ if (not defined $l or not defined $r) {
+ fail(defined($n) ? $n : ());
+ }
+ else {
+ ok($l < $r+1e-6 && $r < $l+1e-6, defined($n) ? $n : ())
+ or note("$l and $r seem to be different given a fuzz of 1e-6");
+ }
+}