Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:/perl6/roast
  • Loading branch information
jnthn committed Jul 15, 2015
2 parents e4eb44a + ed09f71 commit c3f0861
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
10 changes: 9 additions & 1 deletion S02-types/bag.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 193;
plan 195;

sub showkv($x) {
$x.keys.sort.map({ $^k ~ ':' ~ $x{$k} }).join(' ')
Expand Down Expand Up @@ -474,4 +474,12 @@ sub showkv($x) {
'can use cross operator X with bag keys';
}

# RT #125611
{
my class MyBag is Bag { }
my $b = MyBag.new(|<a foo a a a a b foo>);
isa-ok $b, MyBag, 'MyBag.new produces a MyBag';
is showkv($b), 'a:5 b:1 foo:2', '...with the right elements';
}

# vim: ft=perl6
9 changes: 8 additions & 1 deletion S02-types/set.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 170;
plan 171;

sub showset($s) { $s.keys.sort.join(' ') }

Expand Down Expand Up @@ -384,4 +384,11 @@ dies-ok { set(1, 2) «+» set(3, 4) }, 'Set «+» Set is illegal';
nok $s.keys[0] eqv $s.keys[1], 'arrays not flattened out by Set.new (4)';
}

# RT #125611
{
class MySet is Set { };
my $s = MySet.new([1, 2], 3);
is $s.elems, 2, 'Can subclass Set';
}

# vim: ft=perl6
4 changes: 2 additions & 2 deletions S09-typed-arrays/native-int.t
Expand Up @@ -124,11 +124,11 @@ for @int,@uint -> $T {

@arr = ();
throws-like { @arr.pop }, X::Cannot::Empty,
action => '.pop',
action => 'pop',
what => "array[$t]",
"Trying to pop an empty $t array dies";
throws-like { @arr.shift }, X::Cannot::Empty,
action => '.shift',
action => 'shift',
what => "array[$t]",
"Trying to shift an empty $t array dies";

Expand Down
4 changes: 2 additions & 2 deletions S09-typed-arrays/native-num.t
Expand Up @@ -128,11 +128,11 @@ for @num -> $T {

@arr = ();
throws-like { @arr.pop }, X::Cannot::Empty,
action => '.pop',
action => 'pop',
what => "array[$t]",
"Trying to pop an empty $t array dies";
throws-like { @arr.shift }, X::Cannot::Empty,
action => '.shift',
action => 'shift',
what => "array[$t]",
"Trying to shift an empty $t array dies";
throws-like { @arr[0] := my $a }, X::AdHoc,
Expand Down
7 changes: 3 additions & 4 deletions S32-io/slurp.t
Expand Up @@ -39,15 +39,14 @@ is slurp($empty-path), '', "empty files yield empty string";
is $fh.slurp-rest, $test-contents, "method form .slurp-rest works";
$fh.close;
}
#?niecza skip "slurp(filehandle) doesn't work"

{
my $fh = open $test-path, :r;
is slurp($fh), $test-contents, "function passed a filehandle works";
$fh.close;
is slurp($test-path), $test-contents, "function passed a path works";
}

# RT #112276
# 0-argument slurp set to $*ARGFILES
# XXX This will break due to deprecation
{
my $*ARGFILES = open $test-path, :r;
is slurp(), $test-contents, "slurp with no parameters loads \$*ARGFILES";
Expand Down
20 changes: 7 additions & 13 deletions S32-io/spurt.t
Expand Up @@ -59,29 +59,23 @@ sub all-basic(Callable $handle) {
# Corner cases
#?niecza skip "Unable to resolve method open in type IO"
{
# Spurt on open handle
# Spurt on open file
{
my $io = $path.IO.open(:w);
spurt $io, "42";
close $io;
is slurp($path), "42", 'can spurt into an open handle';
spurt $path, "42";
is slurp($path), "42", 'can spurt into an open file';
}

# Buf into an open non binary handle
# Buf into an open non binary file
{
my $io = $path.IO.open(:w);
my Buf $buf = Buf.new(0xC0, 0x01, 0xF0, 0x0D);
spurt $io, $buf;
close $io;
spurt $path, $buf;
is slurp($path, :bin), $buf, 'can spurt a Buf into an open handle';
}

# Text into a open binary handle
# Text into a open binary file
{
my $io = $path.IO.open(:bin, :w);
my Str $txt = "Bli itj nå trønder-rock uten tennis-sokk";
spurt $io, $txt;
close $io;
spurt $path, $txt;
is slurp($path), $txt, 'can spurt text into a binary handle';
}

Expand Down

0 comments on commit c3f0861

Please sign in to comment.