Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' into curli
  • Loading branch information
niner committed Nov 15, 2015
2 parents d6cee0d + a1e5aff commit 5048f1b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
2 changes: 1 addition & 1 deletion S02-types/array-shapes.t
Expand Up @@ -78,7 +78,7 @@ plan 25;
my int @arr = 1, 2, 3, 4, 5;
is(@arr, <1 2 3 4 5>, 'my type @arr works');
is push(@arr, 6), [1,2,3,4,5,6], 'push on native @arr works';
#?rakudo 2 todo 'X::AdHoc "This type cannot unbox to a native integer" RT #125123'
# RT #125123'
throws-like { EVAL 'push @arr, "s"' },
X::TypeCheck,
'type constraints on my type @arr works (1)';
Expand Down
49 changes: 28 additions & 21 deletions S03-operators/buf.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 53;
plan 55;

ok (~^"foo".encode eqv utf8.new(0x99, 0x90, 0x90)), 'prefix:<~^>';

Expand Down Expand Up @@ -48,34 +48,33 @@ ok Buf.new(1, 2, 3, 4).subbuf(1, 2) eqv Buf.new(2, 3), '.subbuf(start, len)';
ok Buf.new(1, 2).subbuf(0, 3) eqv Buf.new(1,2), '.subbuf length out of bounds';
ok Buf.new.subbuf(0, 1) eqv Buf.new(), "subbuf on an empty buffer";

{ # Throw on negative range
Buf.new(1).subbuf(-1, 1);
ok 0, "throw on negative range";
CATCH { when X::OutOfRange { ok 1, "throw on negative range" } }
}
# Throw on negative range
throws-like { Buf.new(1).subbuf(-1, 1) }, X::OutOfRange,
got => -1,
range => "0..1",
"throw on negative range";

{ # Throw on out of bounds
Buf.new(0xFF).subbuf(2, 1);
ok 0, "throw on out of range (positive)";
CATCH { when X::OutOfRange { ok 1, "throw on out of range (positive)" } }
}
# Throw on out of bounds
throws-like { Buf.new(0xFF).subbuf(2, 1) }, X::OutOfRange,
got => 2,
range => "0..1",
"throw on out of range (positive)";

{ # Counted from the end
ok Buf.new(^10).subbuf(*-5, 5) eqv Buf.new(5..9), "counted from the end";
ok Buf.new(1, 2).subbuf(*-1, 10) eqv Buf.new(2), "counted from the end, length out of bounds";
}

{ # Throw on out of bounds, from the end.
Buf.new(0xFF).subbuf(*-2, 1);
ok 0, "throw on out of bounds, counted from the end";
CATCH { when X::OutOfRange { ok 1, "throw on out of bounds, counted from the end"; } }
}
# Throw on out of bounds, from the end.
throws-like { Buf.new(0xFF).subbuf(*-2, 1) }, X::OutOfRange,
got => *,
range => "0..1",
"throw on out of bounds, counted from the end";

{
Buf.new().subbuf(0, -1);
ok 0, "throw on negative len";
CATCH { when X::OutOfRange { ok 1, "throw on negative len" } }
}
throws-like { Buf.new().subbuf(0, -1) }, X::OutOfRange,
got => -1,
range => "0..0",
"throw on negative len";

# RT #122827
{
Expand Down Expand Up @@ -141,3 +140,11 @@ ok Buf.new.subbuf(0, 1) eqv Buf.new(), "subbuf on an empty buffer";
my Buf $raw-bin .= new(0x55 xx 3);
is $raw-bin.elems, 3, 'Can create Buf with .= new';
}

{
my $b = Buf.new(^100);
is-deeply $b.subbuf(^10), Buf.new(^10),
'can we use ^10 as specifier';
is-deeply $b.subbuf(10..20), Buf.new(10..20),
'can we use 10..20 as specifier';
}
2 changes: 1 addition & 1 deletion S03-operators/increment.t
Expand Up @@ -71,9 +71,9 @@ is($moo, 0, "var was not touched");

# test incrementing literals
# all of those can be detected at compile time
#?rakudo.jvm todo "RT #126531"
{
throws-like ' 4++ ', X::Multi::NoMatch, "can't postincrement a literal number";
#?rakudo.jvm 3 todo "RT #126531"
throws-like ' ++4 ', X::Multi::NoMatch, "can't preincrement a literal number";
throws-like ' 4-- ', X::Multi::NoMatch, "can't postdecrement a literal number";
throws-like ' --4 ', X::Multi::NoMatch, "can't predecrement a literal number";
Expand Down
10 changes: 6 additions & 4 deletions S09-typed-arrays/native-int.t
Expand Up @@ -133,8 +133,9 @@ for flat @int,@uint -> $T {
is @arr.push(42), (42,), "can push to $t array";
is @arr.elems, 1, "push to $t array works (1)";
is @arr[0], 42, "push to $t array works (2)";
throws-like { @arr.push('it real good') }, Exception,
message => 'This type cannot unbox to a native integer',
# RT #125123
throws-like { @arr.push('it real good') }, X::TypeCheck,
got => Str,
"Cannot push non-int/Int to $t array";
throws-like { @arr[0] := my $a }, Exception,
message => 'Cannot bind to a natively typed array',
Expand All @@ -158,8 +159,9 @@ for flat @int,@uint -> $T {
is @arr.elems, 3, "unshift to $t array works (1)";
is @arr[0], 1, "unshift to $t array works (2)";
is @arr[1], 42, "unshift to $t array works (3)";
throws-like { @arr.unshift('part of the day not working') }, Exception,
message => 'This type cannot unbox to a native integer',
# RT #125123
throws-like { @arr.unshift('part of the day not working') }, X::TypeCheck,
got => Str,
"Cannot unshift non-int/Int to $t array";

is (@arr.unshift(3,2)), (3,2,1,42,101),"can unshift multiple to $t array";
Expand Down
1 change: 0 additions & 1 deletion S16-filehandles/io.t
Expand Up @@ -308,7 +308,6 @@ nok $filename.IO ~~ :e, '... and the tempfile is gone, really';
#?rakudo.moar todo 'Too late to change filehandle encoding RT #125079'
lives-ok { $fh.encoding('ISO-8859-1') }, "reset input fh encoding";
$s = '';
#?rakudo.jvm todo 'will fail due to above failures RT #125080'
lives-ok { $s ~= $fh.getc for 1..3; }, "iso-8859-1 chars from fh";
#?rakudo.jvm todo 'will fail due to above failures RT #125081'
is $s, 'a垄每', "correct iso-8859-1 chars from fh";
Expand Down
1 change: 0 additions & 1 deletion S16-filehandles/io_in_while_loops.t
Expand Up @@ -41,7 +41,6 @@ my $filename = 'tempfile_io_in_while_loop';
ok(unlink($filename), 'file has been removed');

# RT #122971
#?rakudo.jvm todo 'Multi-line separators on JVM'
{
spurt($filename, q:to/FASTAISH/.subst(/\r\n/, "\n"));
>roa1_drome Rea guano receptor type III >> 0.1
Expand Down

0 comments on commit 5048f1b

Please sign in to comment.