class TestCase::Accessor {
  use Point;
  
  our $VALUE_BYTE : rw byte;
  our $VALUE_SHORT : rw short;
  our $VALUE_INT : rw int;
  our $VALUE_LONG : rw long;
  our $VALUE_FLOAT : rw float;
  our $VALUE_DOUBLE : rw double;
  our $VALUE_OBJECT : rw Point;
  
  our $VALUE_REAL : int;
  our $VALUE_VIRTUAL : virtual rw int
    get {
      return $VALUE_REAL;
    }
    set {
      $VALUE_REAL = $_;
    }
  ;
  
  has value_byte : rw byte;
  has value_short : rw short;
  has value_int : rw int;
  has value_long : rw long;
  has value_float : rw float;
  has value_double : rw double;
  has value_object : rw Point;
  
  has value_real : int;
  has value_virtual : virtual rw int
    get {
      return $self->{value_real};
    }
    set {
      $self->{value_real} = $_;
    }
  ;
  
  our $VALUE_BYTE_USER_DEFINED : rw byte
    get {
      return $VALUE_BYTE_USER_DEFINED * 2;
    }
    set {
      $VALUE_BYTE_USER_DEFINED = (byte)($_ * 3);
    }
  ;
  
  our $VALUE_INT_USER_DEFINED : rw int
    get {
      return $VALUE_INT_USER_DEFINED * 2;
    }
    set {
      $VALUE_INT_USER_DEFINED = $_ * 3;
    }
  ;
  
  our $VALUE_INT_USER_DEFINED_WITH_ARG : rw int
    set ($_ : object) {
      $VALUE_INT_USER_DEFINED_WITH_ARG = (int)$_;
    }
  ;
  
  has value_byte_user_defined : rw byte
    get {
      return $self->{value_byte_user_defined} * 2;
    }
    set {
      $self->{value_byte_user_defined} = (byte)($_ * 3);
    }
  ;
  
  has value_int_user_defined : rw int
    get {
      return $self->{value_int_user_defined} * 2;
    }
    set {
      $self->{value_int_user_defined} = $_ * 3;
    }
  ;
  
  has value_int_user_defined_with_arg : rw int
    set ($value : object) {
      $self->{value_int_user_defined_with_arg} = (int)$value;
    }
  ;
  
  has value_int_user_defined_with_arg_and_return_type : rw int
    set : TestCase::Accessor ($_ : int) {
      $self->{value_int_user_defined_with_arg_and_return_type} = $_;
      return $self;
    }
  ;
  
  has value_int_return_type : rw int
    set : TestCase::Accessor
  ;
  
  static method field_accessor : int () {
    {
      my $object = new TestCase::Accessor;
      
      $object->{value_byte} = 1;
      
      my $value_field = $object->{value_byte};
      unless ($value_field isa byte) {
        return 0;
      }
      unless ($value_field == 1) {
        return 0;
      }
      
      my $value_var = 2;
      $object->set_value_byte($value_var);
      
      my $value_reader = $object->value_byte;
      unless ($value_reader isa int) {
        return 0;
      }
      unless ($value_reader == 2) {
        return 0;
      }
    }
    
    {
      my $object = new TestCase::Accessor;
      
      $object->{value_short} = 1;
      
      my $value_field = $object->{value_short};
      unless ($value_field isa short) {
        return 0;
      }
      unless ($value_field == 1) {
        return 0;
      }
      
      my $value_var = 2;
      $object->set_value_short($value_var);
      
      my $value_reader = $object->value_short;
      unless ($value_reader isa int) {
        return 0;
      }
      unless ($value_reader == 2) {
        return 0;
      }
    }

    {
      my $object = new TestCase::Accessor;
      
      $object->{value_int} = 1;
      
      my $value_field = $object->{value_int};
      unless ($value_field isa int) {
        return 0;
      }
      unless ($value_field == 1) {
        return 0;
      }
      
      my $value_var = 2;
      $object->set_value_int($value_var);
      
      my $value_reader = $object->value_int;
      unless ($value_reader isa int) {
        return 0;
      }
      unless ($value_reader == 2) {
        return 0;
      }
    }

    {
      my $object = new TestCase::Accessor;
      
      $object->{value_long} = 1;
      
      my $value_field = $object->{value_long};
      unless ($value_field isa long) {
        return 0;
      }
      unless ($value_field == 1) {
        return 0;
      }
      
      my $value_var = 2;
      $object->set_value_long($value_var);
      
      my $value_reader = $object->value_long;
      unless ($value_reader isa long) {
        return 0;
      }
      unless ($value_reader == 2) {
        return 0;
      }
    }

    {
      my $object = new TestCase::Accessor;
      
      $object->{value_float} = 1f;
      
      my $value_field = $object->{value_float};
      unless ($value_field isa float) {
        return 0;
      }
      unless ($value_field == 1f) {
        return 0;
      }
      
      my $value_var = 2;
      $object->set_value_float($value_var);
      
      my $value_reader = $object->value_float;
      unless ($value_reader isa float) {
        return 0;
      }
      unless ($value_reader == 2f) {
        return 0;
      }
    }

    {
      my $object = new TestCase::Accessor;
      
      $object->{value_double} = 1;
      
      my $value_field = $object->{value_double};
      unless ($value_field isa double) {
        return 0;
      }
      unless ($value_field == 1) {
        return 0;
      }
      
      my $value_var = 2;
      $object->set_value_double($value_var);
      
      my $value_reader = $object->value_double;
      unless ($value_reader isa double) {
        return 0;
      }
      unless ($value_reader == 2) {
        return 0;
      }
    }

    {
      my $object = new TestCase::Accessor;
      
      my $point = Point->new;
      $object->{value_object} = $point;
      
      my $value_field = $object->{value_object};
      unless ($value_field isa Point) {
        return 0;
      }
      unless ($value_field == $point) {
        return 0;
      }
      
      my $value_var = Point->new;
      $object->set_value_object($value_var);
      
      my $value_reader = $object->value_object;
      unless ($value_reader isa Point) {
        return 0;
      }
      unless ($value_reader == $value_var) {
        return 0;
      }
    }
    
    {
      my $object = new TestCase::Accessor;
      
      $object->set_value_virtual(1);
      
      unless ($object->value_virtual == 1) {
        return 0;
      }
    }
    
    return 1;
  }

  static method field_accessor_user_defined : int () {
    
    {
      my $object = new TestCase::Accessor;
      
      $object->set_value_int_user_defined(2);
      
      unless ($object->{value_int_user_defined} == 6) {
        return 0;
      }
      
      unless ($object->value_int_user_defined == 12) {
        return 0;
      }
      
    }
    
    {
      my $object = new TestCase::Accessor;
      
      $object->set_value_byte_user_defined(2);
      
      unless ($object->{value_byte_user_defined} == 6) {
        return 0;
      }
      
      unless ($object->value_byte_user_defined == 12) {
        return 0;
      }
      
    }
    
    {
      my $object = new TestCase::Accessor;
      
      $object->set_value_int_user_defined_with_arg((object)2);
      
      unless ($object->value_int_user_defined_with_arg == 2) {
        return 0;
      }
    }
    
    {
      my $object = new TestCase::Accessor;
      
      my $ret = $object->set_value_int_user_defined_with_arg_and_return_type(2);
      
      unless ($object->{value_int_user_defined_with_arg_and_return_type} == 2) {
        return 0;
      }
      
      unless ($ret is_type TestCase::Accessor) {
        return 0;
      }
    }
    
    {
      my $object = new TestCase::Accessor;
      
      my $ret = $object->set_value_int_return_type(2);
      
      unless ($object->{value_int_return_type} == 2) {
        return 0;
      }
      
      unless ($ret is_type TestCase::Accessor) {
        return 0;
      }
    }
    
    return 1;
  }
  
  static method class_var_accessor : int () {
    
    {
      $VALUE_BYTE = 1;
      
      unless ($VALUE_BYTE isa byte) {
        return 0;
      }
      unless ($VALUE_BYTE == 1) {
        return 0;
      }
      
      TestCase::Accessor->SET_VALUE_BYTE(2);
      unless (TestCase::Accessor->VALUE_BYTE isa int) {
        return 0;
      }
      unless (TestCase::Accessor->VALUE_BYTE == 2) {
        return 0;
      }
    }
    {
      $VALUE_SHORT = 1;
      
      unless ($VALUE_SHORT isa short) {
        return 0;
      }
      unless ($VALUE_SHORT == 1) {
        return 0;
      }
      
      TestCase::Accessor->SET_VALUE_SHORT(2);
      unless (TestCase::Accessor->VALUE_SHORT isa int) {
        return 0;
      }
      unless (TestCase::Accessor->VALUE_SHORT == 2) {
        return 0;
      }
    }
    
    {
      $VALUE_INT = 1;
      
      unless ($VALUE_INT isa int) {
        return 0;
      }
      unless ($VALUE_INT == 1) {
        return 0;
      }
      
      TestCase::Accessor->SET_VALUE_INT(2);
      unless (TestCase::Accessor->VALUE_INT isa int) {
        return 0;
      }
      unless (TestCase::Accessor->VALUE_INT == 2) {
        return 0;
      }
    }
    {
      $VALUE_LONG = 1;
      
      unless ($VALUE_LONG isa long) {
        return 0;
      }
      unless ($VALUE_LONG == 1) {
        return 0;
      }
      
      TestCase::Accessor->SET_VALUE_LONG(2);
      unless (TestCase::Accessor->VALUE_LONG isa long) {
        return 0;
      }
      unless (TestCase::Accessor->VALUE_LONG == 2) {
        return 0;
      }
    }
    {
      $VALUE_FLOAT = 1;
      
      unless ($VALUE_FLOAT isa float) {
        return 0;
      }
      unless ($VALUE_FLOAT == 1) {
        return 0;
      }
      
      TestCase::Accessor->SET_VALUE_FLOAT(2);
      unless (TestCase::Accessor->VALUE_FLOAT isa float) {
        return 0;
      }
      unless (TestCase::Accessor->VALUE_FLOAT == 2) {
        return 0;
      }
    }
    {
      $VALUE_DOUBLE = 1;
      
      unless ($VALUE_DOUBLE isa double) {
        return 0;
      }
      unless ($VALUE_DOUBLE == 1) {
        return 0;
      }
      
      TestCase::Accessor->SET_VALUE_DOUBLE(2);
      unless (TestCase::Accessor->VALUE_DOUBLE isa double) {
        return 0;
      }
      unless (TestCase::Accessor->VALUE_DOUBLE == 2) {
        return 0;
      }
    }
    {
      my $value_object = Point->new;
      $VALUE_OBJECT = $value_object;
      
      unless ($VALUE_OBJECT isa Point) {
        return 0;
      }
      unless ($VALUE_OBJECT == $value_object) {
        return 0;
      }
      
      my $value_object2 = Point->new;
      TestCase::Accessor->SET_VALUE_OBJECT($value_object2);
      unless (TestCase::Accessor->VALUE_OBJECT isa Point) {
        return 0;
      }
      unless (TestCase::Accessor->VALUE_OBJECT == $value_object2) {
        return 0;
      }
      $VALUE_OBJECT = undef;
    }
    
    {
      TestCase::Accessor->SET_VALUE_VIRTUAL(1);
      unless (TestCase::Accessor->VALUE_VIRTUAL == 1) {
        return 0;
      }
    }
    
    return 1;
  }

  static method class_var_user_defined : int () {
    
    {
      &SET_VALUE_INT_USER_DEFINED(2);
      
      unless ($VALUE_INT_USER_DEFINED == 6) {
        return 0;
      }
      
      unless (&VALUE_INT_USER_DEFINED == 12) {
        return 0;
      }
      
    }
    
    {
      &SET_VALUE_BYTE_USER_DEFINED(2);
      
      unless ($VALUE_BYTE_USER_DEFINED == 6) {
        return 0;
      }
      
      unless (&VALUE_BYTE_USER_DEFINED == 12) {
        return 0;
      }
      
    }
    
    {
      &SET_VALUE_INT_USER_DEFINED_WITH_ARG((object)2);
      
      unless (&VALUE_INT_USER_DEFINED_WITH_ARG == 2) {
        return 0;
      }
      
    }
    
    return 1;
  }
  
}
