use v6;
use Test;
plan 9;
{
my $foo = 42;
try { $foo.infix:<=>(23) };
is $foo, 23, "basic scalar assignment using .infix:<=>";
}
{
my $foo = 42;
try { my @array = <a b c>; $foo.infix:<=>(@array) };
is ~$foo, "a b c", "scalar assignment using .infix:<=>";
}
{
my $foo = 42;
try { $foo.infix:<=>(23) = 19 };
is $foo, 19, ".infix:<=> returns an lvalue (1)";
}
{
my $foo = 42;
try { $foo.infix:<=>(23).infix:<=>(19) };
is $foo, 19, ".infix:<=> returns an lvalue (2)";
}
{
dies_ok { 42.infix:<=>(23) }, ".infix:<=> can't assign to constants";
}
{
my ($foo, $bar);
try { ($foo, $bar).infix:<=>(13, 14) };
is $foo, 13, "array assignment using .infix:<=> (1)", :todo<feature>;
is $bar, 14, "array assignment using .infix:<=> (2)", :todo<feature>;
}
{
my $foo = 42;
my $bar = 23;
eval '$foo does role {
method infix:<=> {
$bar++;
}
}';
$foo = "new";
is $foo, 42, "overriding infix:<=> (1)", :todo<feature>;
is $bar, 24, "overriding infix:<=> (2)", :todo<feature>;
}