Skip to content

Commit

Permalink
[v6.d REVIEW] Appendicise "-" magic open string cover tests
Browse files Browse the repository at this point in the history
This feature is deprecated in 6.d

Orig: 60a7a88e4
  • Loading branch information
zoffixznet committed Sep 17, 2018
1 parent 903d395 commit 1fefe0a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 64 deletions.
66 changes: 63 additions & 3 deletions APPENDICES/A03-older-specs/01-misc.t
@@ -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;
}
}
62 changes: 1 addition & 61 deletions S32-io/open.t
Expand Up @@ -3,7 +3,7 @@ use lib $?FILE.IO.parent(2).add("packages");
use Test;
use Test::Util;

plan 19;
plan 17;

###################################################################################################
#
Expand Down Expand Up @@ -228,66 +228,6 @@ subtest '.open uses attributes by default' => {
$fh.close;
}

# 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 #131755
subtest '.DESTROY does not close standard handles' => {
plan 3;
Expand Down

0 comments on commit 1fefe0a

Please sign in to comment.