Skip to content

Commit c298bbd

Browse files
author
Fitz Elliott
committed
add test file for hash() method (includes test for RT #76826)
1 parent d87f4af commit c298bbd

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

S29-conversions/hash.t

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
use v6;
2+
3+
use Test;
4+
5+
plan 8;
6+
7+
=begin pod
8+
9+
Basic tests for the hash() built-in
10+
11+
=end pod
12+
13+
# L<S29/Conversions/hash>
14+
15+
{
16+
ok hash() ~~ Hash, 'hash() makes a hash';
17+
}
18+
19+
{
20+
"foo" ~~ /foo/;
21+
is hash().elems, 0, "hash() doesn't auto-hash $/";
22+
}
23+
24+
{
25+
is ('a'..'c' Z 1..3).hash.<a>, 1, "hash() builds a sensible hash";
26+
is ('a'..'c' Z 1..3).hash.<b>, 2, "hash() builds a sensible hash";
27+
is ('a'..'c' Z 1..3).hash.<c>, 3, "hash() builds a sensible hash";
28+
}
29+
30+
{
31+
lives_ok {(a => 1, b => 2).hash.perl}, 'hash() on list of pairs lives (RT #76826)';
32+
}
33+
34+
{
35+
dies_ok {hash(<1 2 3>)}, "hash() won't create invalid hash";
36+
}
37+
38+
39+
{
40+
is ?hash(), Bool::False, "hash() is false";
41+
}
42+
43+
44+
done;
45+
46+
# vim: ft=perl6

0 commit comments

Comments
 (0)