Skip to content

Commit d557444

Browse files
committed
Add some basic List.sum tests
1 parent 614d76a commit d557444

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

S02-types/list.t

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use v6;
22
use Test;
33

4-
plan 61;
4+
plan 65;
55

66
isa-ok (5, 7, 8), List, '(5, 7, 8) is List';
77
is +(5, 7, 8), 3, 'prefix:<+> on a List';
@@ -121,4 +121,13 @@ is $(;).elems, 0, '$(;) parses, and is empty';
121121
}
122122
}
123123

124+
{
125+
is (1,2,3,4).sum, 10, 'can we do .sum on a List';
126+
is (.1,.2,.3,.4).sum, 1, 'even if they are not ints';
127+
is <1 2 3 4>.sum, 10, 'even if they are numified strings';
128+
throws-like { <a b c d>.sum }, X::Str::Numeric,
129+
reason => "base-10 number must begin with valid digits or '.'",
130+
'fail if they are non-numeric strings';
131+
}
132+
124133
# vim: ft=perl6

0 commit comments

Comments
 (0)