Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v6.d REVIEW] Appendicise "-" magic open string cover tests
This feature is deprecated in 6.d Orig: 60a7a88e4
- Loading branch information
1 parent
903d395
commit 1fefe0a
Showing
2 changed files
with
64 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,66 @@ | ||
use v6.c; | ||
|
||
use lib $?FILE.IO.parent(3).add: 'packages'; | ||
use Test; | ||
plan 1; | ||
use Test::Util; | ||
|
||
plan 2; | ||
|
||
# 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'; | ||
} | ||
|
||
ok 1; | ||
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」; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters