Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Test for bug with .slurp after .get
#!/usr/bin/env perl6
use Test;
plan 4;
my $temp-file = '/tmp/nulltest';
my $test-string = 'test line';
my $lines = 6;
shell "echo $test-string > $temp-file";
shell "echo $test-string >> $temp-file" for ^($lines - 1);
my $content-length = $lines * ($test-string ~ "\n").chars;
diag "Content-Length: $content-length";
given open $temp-file {
my @lines = .get xx ($lines - 1); # Leave one line
my $rest = .slurp;
is @lines[0], $test-string, 'First line read back correctly';
is @lines[*-1], $test-string, 'Penultimate line read back correctly';
is $rest.chars, ($test-string ~ "\n").chars, '.slurp on remaining content';
ok $rest !~~ /\x00+/, 'Slurped content has no null bytes';
unlink $temp-file;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.