Skip to content

Commit

Permalink
[io grant] Add tests to check nul byte is rejected
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Apr 10, 2017
1 parent 8f73ad8 commit b16fbd3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions S32-io/null-char.t
@@ -0,0 +1,23 @@
use v6;
use lib <t/spec/packages/>;
use Test;
use Test::Util;

# Tests for ensuring NUL byte is rejected from paths
constant @nuls = ("\0foobar", "foo\0bar", "foobar\0", "\0foo\0bar\0");

plan 5*@nuls;

{
temp $*CWD = make-temp-dir;
for @nuls -> $nul {
my $d = "with {$nul.perl}";
throws-like { spurt $nul, "foo" }, X::IO::Null, "&spurt $d";
throws-like { slurp $nul }, X::IO::Null, "&slurp $d";
throws-like { chdir $nul }, X::IO::Null, "&chdir $d";
throws-like { $nul.IO }, X::IO::Null, ".IO $d";
throws-like { IO::Path.new: $nul }, X::IO::Null, "IO::Path.new $d";
}
}

# vim: ft=perl6

0 comments on commit b16fbd3

Please sign in to comment.