Permalink
Browse files

add test file for hash() method (includes test for RT #76826)

  • Loading branch information...
1 parent d87f4af commit c298bbd02acf27d85a6ca76dac193e1a7693cbba @felliott felliott committed Jan 19, 2011
Showing with 46 additions and 0 deletions.
  1. +46 −0 S29-conversions/hash.t
View
@@ -0,0 +1,46 @@
+use v6;
+
+use Test;
+
+plan 8;
+
+=begin pod
+
+Basic tests for the hash() built-in
+
+=end pod
+
+# L<S29/Conversions/hash>
+
+{
+ ok hash() ~~ Hash, 'hash() makes a hash';
+}
+
+{
+ "foo" ~~ /foo/;
+ is hash().elems, 0, "hash() doesn't auto-hash $/";
+}
+
+{
+ is ('a'..'c' Z 1..3).hash.<a>, 1, "hash() builds a sensible hash";
+ is ('a'..'c' Z 1..3).hash.<b>, 2, "hash() builds a sensible hash";
+ is ('a'..'c' Z 1..3).hash.<c>, 3, "hash() builds a sensible hash";
+}
+
+{
+ lives_ok {(a => 1, b => 2).hash.perl}, 'hash() on list of pairs lives (RT #76826)';
+}
+
+{
+ dies_ok {hash(<1 2 3>)}, "hash() won't create invalid hash";
+}
+
+
+{
+ is ?hash(), Bool::False, "hash() is false";
+}
+
+
+done;
+
+# vim: ft=perl6

0 comments on commit c298bbd

Please sign in to comment.