Skip to content

Commit 1871724

Browse files
committed
Spec Blob.gist's trimming to 100 els
Rakudo impl: rakudo/rakudo@ac8e5f430b
1 parent 60f4bd7 commit 1871724

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

S32-container/buf.t

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ is Blob.new(<1 2 3>).Int, 3, '.Int gives number of elements';
3838
throws-like { Blob.new.chars }, X::Buf::AsStr, :method<chars>,
3939
'attempting to call .chars throws';
4040

41-
is Blob.new(<1 2 3>).gist, 'Blob:0x<01 02 03>', 'gist gives useful value';
4241
is-deeply Blob.new(<1 2 3>).reverse, Blob.new(<3 2 1>),
4342
'.reverse gives reversed Blob';
4443

@@ -173,4 +172,21 @@ subtest 'arity-1 infix:<~> works on Blobs' => {
173172
is-deeply ([~] [$b]), $b, '[~] works with array with 1 blob';
174173
}
175174

175+
subtest '.gist shows only first 100 els' => {
176+
plan 5;
177+
sub make-gist ($blob, $extras = []) {
178+
'Blob:0x<' ~ (|$blob».fmt('%02x'), |$extras) ~ '>'
179+
}
180+
181+
is Blob.new(<1 2 3>).gist, 'Blob:0x<01 02 03>', 'gist gives useful value';
182+
is-deeply Blob.new(|$_).gist, make-gist([1..100]), '100 els'
183+
with (1..100).list;
184+
is-deeply Blob.new(|$_).gist, make-gist([1..100], '...'), '101 els'
185+
with (1..101).list;
186+
is-deeply Blob.new(|$_).gist, make-gist([1..100], '...'), '102 els'
187+
with (1..102).list;
188+
is-deeply Blob.new(|$_).gist, make-gist([1..100], '...'), '1000 els'
189+
with (1..1000).list;
190+
}
191+
176192
# vim: ft=perl6

0 commit comments

Comments
 (0)