Sponsoring The Perl Toolchain Summit 2025: Help make this important event another success Learn more

class TestCase::LocalVar {
use Point;
use Fn;
our $VAR_PREC : int;
INIT {
$VAR_PREC = 11;
}
static method name : int () {
my $name = 1;
my $my_name = 2;
my ${name_brace} = 3;
my $_name = 4;
my $NAME = 5;
unless ($name == 1) {
return 0;
}
unless ($my_name == 2) {
return 0;
}
unless (${name_brace} == 3) {
return 0;
}
unless ($name_brace == 3) {
return 0;
}
unless ($_name == 4) {
return 0;
}
unless ($NAME == 5) {
return 0;
}
return 1;
}
static method var_brace : int () {
my ${var} = 5;
unless (${var} == 5) {
return 0;
}
return 1;
}
static method upper_case : int () {
my $VAR1 = 1;
unless ($VAR1 == 1) {
return 0;
}
return 1;
}
static method high_precidence_than_class_var : int () {
my $VAR_PREC = 3;
unless ($VAR_PREC == 3) {
return 0;
}
return 1;
}
static method with_logical_operator : int () {
# &&
{
{
my $num = 0;
1 && ($num = 1);
unless ($num == 1) {
return 0;
}
}
{
1 && (my $num = 1);
unless ($num == 1) {
return 0;
}
}
{
my $object = (Point)undef;
1 && ($object = Point->new);
unless ($object is_type Point) {
return 0;
}
}
{
1 && (my $object = Point->new);
unless ($object is_type Point) {
return 0;
}
}
{
my $object = (Point)undef;
if (1 && ($object = Point->new)) {
unless ($object is_type Point) {
return 0;
}
}
else {
return 0;
}
}
{
if (1 && (my $object = Point->new)) {
unless ($object is_type Point) {
return 0;
}
}
else {
return 0;
}
}
{
my $object = (Point)undef;
my $object2 = (Point)undef;
if (1 && ($object = Point->new) && ($object2 = Point->new)) {
unless ($object is_type Point) {
return 0;
}
unless ($object2 is_type Point) {
return 0;
}
}
else {
return 0;
}
}
{
if (1 && (my $object = Point->new) && (my $object2 = Point->new)) {
unless ($object is_type Point) {
return 0;
}
unless ($object2 is_type Point) {
return 0;
}
}
else {
return 0;
}
}
}
# ||
{
{
my $num = 0;
0 || ($num = 1);
unless ($num == 1) {
return 0;
}
}
{
0 || (my $num = 1);
unless ($num == 1) {
return 0;
}
}
{
my $object = (Bool)undef;
0 || ($object = Bool->FALSE);
unless ($object is_type Bool) {
return 0;
}
}
{
0 || (my $object = Bool->FALSE);
unless ($object is_type Bool) {
return 0;
}
}
{
my $object = (Bool)undef;
my $object2 = (Bool)undef;
if (0 || ($object = Bool->FALSE) || ($object2 = Bool->FALSE)) {
return 0;
}
else {
unless ($object is_type Bool) {
return 0;
}
unless ($object2 is_type Bool) {
return 0;
}
}
}
{
my $object2 = (Bool)undef;
if (0 || (my $object = Bool->FALSE) || ($object2 = Bool->FALSE) || 1) {
unless ($object is_type Bool) {
return 0;
}
unless ($object2 is_type Bool) {
return 0;
}
}
else {
return 0;
}
}
{
my $num = 0;
if (0 || (my $object = Bool->FALSE) || (my $object2 = Bool->FALSE) || ($num = 2)) {
unless ($num == 2) {
return 0;
}
unless ($object is_type Bool) {
return 0;
}
unless ($object2 is_type Bool) {
return 0;
}
}
else {
return 0;
}
}
}
# !
{
{
my $num = 0;
!($num = 1);
unless ($num == 1) {
return 0;
}
}
{
!(my $num = 1);
unless ($num == 1) {
return 0;
}
}
{
my $object = (Point)undef;
!($object = Point->new);
unless ($object is_type Point) {
return 0;
}
}
{
!(my $object = Point->new);
unless ($object is_type Point) {
return 0;
}
}
{
my $object = (Point)undef;
if (!!($object = Point->new)) {
unless ($object is_type Point) {
return 0;
}
}
else {
return 0;
}
}
{
if (!!(my $object = Point->new)) {
unless ($object is_type Point) {
return 0;
}
}
else {
return 0;
}
}
}
return 1;
}
static method temporary_local_var : int () {
my $_ = 1;
unless ($_ == 1) {
return 0;
}
my $_ = 2;
unless ($_ == 2) {
return 0;
}
my $_ = Point->new(1, 2);
unless ($_ is_type Point) {
return 0;
}
my $point = (my $_ = Point->new(1, 2), $_->clear, $_);
unless ($point->x == 0 && $point->y == 0) {
return 0;
}
my $_ : long;
my $map = (string[])Fn->map(method : string ($_ : string) { return $_ . "c"; }, ["a", "ab"]);
unless (Array->equals($map, ["ac", "abc"])) {
return 0;
}
return 1;
}
}