Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Spec Blob.gist's trimming to 100 els
  • Loading branch information
zoffixznet committed Oct 5, 2017
1 parent 60f4bd7 commit 1871724
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion S32-container/buf.t
Expand Up @@ -38,7 +38,6 @@ is Blob.new(<1 2 3>).Int, 3, '.Int gives number of elements';
throws-like { Blob.new.chars }, X::Buf::AsStr, :method<chars>,
'attempting to call .chars throws';

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

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

subtest '.gist shows only first 100 els' => {
plan 5;
sub make-gist ($blob, $extras = []) {
'Blob:0x<' ~ (|$blob».fmt('%02x'), |$extras) ~ '>'
}

is Blob.new(<1 2 3>).gist, 'Blob:0x<01 02 03>', 'gist gives useful value';
is-deeply Blob.new(|$_).gist, make-gist([1..100]), '100 els'
with (1..100).list;
is-deeply Blob.new(|$_).gist, make-gist([1..100], '...'), '101 els'
with (1..101).list;
is-deeply Blob.new(|$_).gist, make-gist([1..100], '...'), '102 els'
with (1..102).list;
is-deeply Blob.new(|$_).gist, make-gist([1..100], '...'), '1000 els'
with (1..1000).list;
}

# vim: ft=perl6

0 comments on commit 1871724

Please sign in to comment.