Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Various test updates for Buf changes.
Rakudo has become more closely aligned with the spec in various ways,
and these tests were caught out in the process.
  • Loading branch information
jnthn committed Jul 21, 2013
1 parent 0a12a9c commit e2c0079
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions S02-types/declare.t
Expand Up @@ -91,7 +91,7 @@ plan 78;
#?pugs skip 'Buf'
{
my Buf $nacpoi;
isa_ok($nacpoi, Buf);
ok($nacpoi ~~ Buf);
}

{
Expand Down Expand Up @@ -260,12 +260,11 @@ plan 78;
isa_ok($papa,Capture );
}

#?rakudo skip 'Blob not implemented'
#?niecza skip 'Blob not implemented'
#?pugs skip 'Blob'
{
my Blob $pare;
isa_ok($pare,Blob );
ok($pare ~~ Blob);
}

#?pugs skip 'Instant'
Expand Down
4 changes: 2 additions & 2 deletions S03-operators/buf.t
Expand Up @@ -3,11 +3,11 @@ use Test;

plan 26;

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

ok ("foo".encode ~& "bar".encode eqv "bab".encode), 'infix:<~&>';
ok ("ber".encode ~| "baz".encode eqv "bez".encode), 'infix:<~|>';
ok ("foo".encode ~^ "bar".encode eqv Buf.new(4, 14, 29)), 'infix:<~^>';
ok ("foo".encode ~^ "bar".encode eqv utf8.new(4, 14, 29)), 'infix:<~^>';

ok ("aaaaa".encode ~& "aa".encode eqv "aa\0\0\0".encode),
'~& extends rightwards';
Expand Down
2 changes: 1 addition & 1 deletion S32-io/slurp.t
Expand Up @@ -58,7 +58,7 @@ is slurp($empty-path), '', "empty files yield empty string";
{
my $binary-slurp;
ok ($binary-slurp = slurp $test-path, :bin), ":bin option runs";
isa_ok $binary-slurp, Buf, ":bin returns a Buf";
ok $binary-slurp ~~ Buf, ":bin returns a Buf";
is $binary-slurp, $test-contents.encode, "binary slurp returns correct content";
}

Expand Down
4 changes: 2 additions & 2 deletions S32-io/spurt.t
Expand Up @@ -15,7 +15,7 @@ all-basic({ $path.IO });


sub all-basic(Callable $handle) {
my Buf $buf = "hello world".encode("utf-8");
my Blob $buf = "hello world".encode("utf-8");
my $txt = "42";

#?niecza 2 skip ":bin option for slurp fails"
Expand Down Expand Up @@ -91,7 +91,7 @@ sub all-basic(Callable $handle) {
$path.IO.spurt("42");
is slurp($path), "42", "IO::Handle slurp";

my Buf $buf = "meow".encode("ASCII");
my Blob $buf = "meow".encode("ASCII");
$path.IO.spurt($buf);
#?niecza skip "Excess arguments to slurp, unused named bin"
is slurp($path, :bin), $buf, "IO::Handle binary slurp";
Expand Down
7 changes: 3 additions & 4 deletions S32-str/encode.t
Expand Up @@ -5,10 +5,10 @@ plan 14;

# L<S32::Containers/Buf>

ok 'ab'.encode('ASCII') ~~ Buf, '$str.encode returns a Buf';
ok ('ab'.encode('ASCII') eqv Buf.new(97, 98)), 'encoding to ASCII';
ok 'ab'.encode('ASCII') ~~ blob8, '$str.encode returns a blob8';
ok ('ab'.encode('ASCII') eqv blob8.new(97, 98)), 'encoding to ASCII';
is 'ab'.encode('ASCII').elems, 2, 'right length of Buf';
ok ('ö'.encode('UTF-8') eqv Buf.new(195, 182)), 'encoding to UTF-8';
ok ('ö'.encode('UTF-8') eqv utf8.new(195, 182)), 'encoding to UTF-8';
is 'ab'.encode('UTF-8').elems, 2, 'right length of Buf';

is 'abc'.encode()[0], 97, 'can index one element in a Buf';
Expand All @@ -24,7 +24,6 @@ ok Buf.new(195, 182).decode ~~ Str, '.decode returns a Str';
is Buf.new(195, 182).decode, 'ö', 'decoding a Buf with UTF-8';
is Buf.new(246).decode('ISO-8859-1'), 'ö', 'decoding a Buf with Latin-1';

#?rakudo todo 'stringy'
ok Buf ~~ Stringy, 'Buf does Stringy';
ok Buf ~~ Positional, 'Buf does Positional';

Expand Down

0 comments on commit e2c0079

Please sign in to comment.