Permalink
Browse files

a few more hashy tests

  • Loading branch information...
1 parent 362c757 commit 278c0b869f72fba7e2f381d5ad6eda8c21cdeaaa @rjbs rjbs committed May 15, 2009
Showing with 17 additions and 1 deletion.
  1. +14 −0 t/code.t
  2. +3 −1 t/hash.t
View
14 t/code.t
@@ -2,3 +2,17 @@ use strict;
use warnings;
use 5.010001;
use Test::More 'no_plan';
+use Tie::RefHash;
+
+{
+ tie my %refhash, 'Tie::RefHash';
+ my $obj = bless {} => 'Class';
+
+ $refhash{ $obj } = 1;
+
+ my $is_obj = sub { ref $_[0] and (ref $_[0]) =~ /[a-z]/ }; # "ha ha ha"
+
+ ok(%refhash ~~ $is_obj, "all keys are blessed");
+}
+
+
View
4 t/hash.t
@@ -21,7 +21,7 @@ use Tie::RefHash;
{
tie my %h, 'Tie::RefHash';
- $h{ $x } = 0;
+ $h{ $x } = 1;
my ($key) = keys %h;
isa_ok($key, 'Smartmatch::Thingie'); # key is still an obj
@@ -30,5 +30,7 @@ use Tie::RefHash;
my $err = $@;
ok(!$ok, q{can't %h~~%h if keys include non-OL objects});
like($err, qr{non-overloaded object}, "can't %h~~%h with non-OL obj keys");
+
+ ok([$x]~~%h, 'obj $x is a key of %h');
}
}

0 comments on commit 278c0b8

Please sign in to comment.