Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

44 lines (34 sloc) 1.388 kb
use v6;
use Test;
plan 26;
ok (~^"foo".encode eqv Buf.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 ("aaaaa".encode ~& "aa".encode eqv "aa\0\0\0".encode),
'~& extends rightwards';
ok ("aaaaa".encode ~| "aa".encode eqv "aaaaa".encode),
'~| extends rightwards';
ok ("aaaaa".encode ~^ "aa".encode eqv "\0\0aaa".encode),
'~^ extends rightwards';
my $a = Buf.new(1, 2, 3);
my $b = Buf.new(1, 2, 3, 4);
ok $a eq $a, 'eq +';
nok $a eq $b, 'eq -';
ok $a ne $b, 'ne +';
nok $a ne $a, 'ne -';
ok $a lt $b, 'lt +';
nok $a lt $a, 'lt -';
nok $b lt $a, 'lt -';
ok $b gt $a, 'gt +';
nok $b gt $b, 'gt -';
nok $a gt $b, 'gt -';
is $a cmp $a, Order::Same, 'cmp (same)';
is $a cmp $b, Order::Increase, 'cmp (smaller)';
is $b cmp $a, Order::Decrease, 'cmp (larger)';
ok $a ~ $b eq Buf.new(1, 2, 3, 1, 2, 3, 4), '~ and eq work on bufs';
is_deeply Buf.new(1, 2, 3) ~ Buf.new(4, 5), Buf.new(1, 2, 3, 4, 5), '~ concatenates';
nok Buf.new(), 'empty Buf is false';
ok Buf.new(1), 'non-empty Buf is true';
ok Buf.new(1, 2, 3, 4).subbuf(2) eqv Buf.new(3, 4), '.subbuf(start)';
ok Buf.new(1, 2, 3, 4).subbuf(1, 2) eqv Buf.new(2, 3), '.subbuf(start, len)';
Jump to Line
Something went wrong with that request. Please try again.