forked from Raku/roast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-misc.t
70 lines (65 loc) · 2.36 KB
/
01-misc.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use v6.c;
use lib $?FILE.IO.parent(3).add: 'packages';
use Test;
use Test::Util;
plan 3;
# RT #131503
#?rakudo.jvm skip "Unsupported VM encoding 'utf8-c8'"
#?DOES 1
{
subtest '.open with "-" as path uses $*IN/$*OUT' => {
plan 2;
subtest 'STDOUT' => { plan 3;
temp $*OUT = make-temp-file.open: :w;
is-deeply '-'.IO.open(:bin, :w), $*OUT, 'returned handle is STDOUT';
is-deeply $*OUT.encoding, Nil, 'set binary mode';
'-'.IO.open: :enc<utf8-c8>, :w;
is-deeply $*OUT.encoding, 'utf8-c8', 'changed encoding';
}
subtest 'STDIN' => { plan 3;
temp $*IN = make-temp-file(:content<meows>).open;
is-deeply '-'.IO.open(:bin), $*IN, 'returned handle is STDIN';
is-deeply $*IN.encoding, Nil, 'set binary mode';
'-'.IO.open: :enc<utf8-c8>;
is-deeply $*IN.encoding, 'utf8-c8', 'changed encoding';
}
}
}
#?rakudo.jvm skip "Unsupported VM encoding 'utf8-c8'"
#?DOES 1
{
subtest '.open with "-" as path can open closed $*IN/$*OUT' => {
plan 3;
subtest 'STDOUT' => { plan 4;
temp $*OUT = IO::Handle.new: :path(make-temp-file);
is-deeply '-'.IO.open(:bin, :w), $*OUT, 'returned handle is STDOUT';
is-deeply $*OUT.opened, True, '$*OUT is now opened';
is-deeply $*OUT.encoding, Nil, 'set binary mode';
'-'.IO.open: :enc<utf8-c8>, :w;
is-deeply $*OUT.encoding, 'utf8-c8', 'changed encoding';
}
subtest 'STDIN' => { plan 4;
temp $*IN = IO::Handle.new: :path(make-temp-file :content<meows>);
is-deeply '-'.IO.open(:bin), $*IN, 'returned handle is STDIN';
is-deeply $*IN.opened, True, '$*IN is now opened';
is-deeply $*IN.encoding, Nil, 'set binary mode';
'-'.IO.open: :enc<utf8-c8>;
is-deeply $*IN.encoding, 'utf8-c8', 'changed encoding';
}
is_run 「
$*IN = IO::Handle.new: :path('-'.IO);
$*OUT = IO::Handle.new: :path('-'.IO);
my $w = '-'.IO.open: :w;
my $r = '-'.IO.open;
$r.get.say;
$*IN.slurp(:close).say;
$w.put: 'meow $w';
$*OUT.put: 'meow $*OUT';
」, "foo\nbar\nber", {
:out("foo\nbar\nber\nmeow \$w\nmeow \$*OUT\n"), :err(''), :0status
}, 「can use unopened handle with path '-'.IO」;
}
}
# RT #131503
is_run 「'-'.IO.slurp.print」, 'meows', {:out<meows>, :err(''), :0status},
'can .slurp from "-".IO path';