package TestCase::Convert {
  use TestCase::Minimal;
  use TestCase::Interface::Interface;
  use SPVM::Comparator;
  
  sub convert_to_numeric_array : int () {
    my $onums_byte : object = new byte[3];
    my $nums_byte = (byte[])$onums_byte;
    my $onums_short : object = new short[3];
    my $nums_short = (short[])$onums_short;
    my $onums_int : object = new int[3];
    my $nums_int = (int[])$onums_int;
    my $onums_long : object = new long[3];
    my $nums_long = (long[])$onums_long;
    my $onums_float : object = new float[3];
    my $nums_float = (float[])$onums_float;
    my $onums_double : object = new double[3];
    my $nums_double = (double[])$onums_double;
    
    return 1;
  }

  sub convert_to_any_object : int () {
    my $object = (object)new TestCase::Minimal[3];
    
    return 1;
  }

  sub convert_to_undef_to_any_object : int () {
    my $minimal : TestCase::Minimal;
    my $object = (object)$minimal;
    
    if ($object == undef) {
      return 1;
    }
    
    return 0;
  }

  sub convert_to_undef_to_object : int () {
    my $minimal : TestCase::Minimal;
    my $object = (TestCase::Minimal)$minimal;
    
    if ($object == undef) {
      return 1;
    }
    
    return 0;
  }

  sub convert_to_interface : int () {
    my $comparator = sub : int ($self : self, $object1 : object, $object2 : object) {
      return 5;
    };
    
    my $object : object = $comparator;
    
    my $comparator2 = (SPVM::Comparator)$object;
    
    if ($comparator2->compare(undef, undef) == 5) {
      return 1;
    }
    
    return 0;
  }

  sub convert_to_undef_to_interface : int () {
    my $comparator : SPVM::Comparator;
    
    my $comparator2 = (SPVM::Comparator)$comparator;
    
    if ($comparator2 == undef) {
      return 1;
    }
    
    return 0;
  }

  sub convert_to_object_array : int () {
    my $ominimals : object = new TestCase::Minimal[3];
    my $minimals = (TestCase::Minimal[])$ominimals;
    
    return 1;
  }

  sub convert_to_interface_array : int () {
    my $ointerfaces : object = new TestCase::Interface::Interface[3];
    my $interfaces = (TestCase::Interface::Interface[])$ointerfaces;
    
    return 1;
  }

  # Convert type - floating point narrowing convertion
  sub convert_float_to_byte : int () {
    my $value = (byte)127.1f;
    
    if ($value == 127) {
      return 1;
    }
    
    return 0;
  }
  sub convert_float_to_short : int () {
    my $value = (short)32767.1f;
    
    if ($value == 32767) {
      return 1;
    }
    
    return 0;
  }
  sub convert_float_to_int : int () {
    my $value = (int)132767.1f;
    
    if ($value == 132767) {
      return 1;
    }
    
    return 0;
  }
  sub convert_float_to_long : int () {
    my $value = (long)132767.1f;
    
    if ($value == 132767L) {
      return 1;
    }
    
    return 0;
  }
  sub convert_double_to_byte : int () {
    my $value = (byte)127.1;
    
    if ($value == 127) {
      return 1;
    }
    
    return 0;
  }
  sub convert_double_to_short : int () {
    my $value = (short)32767.1;
    
    if ((int)$value == (int)(short)32767) {
      return 1;
    }
    
    return 0;
  }
  sub convert_double_to_int : int () {
    my $value = (int)2147483646.1;
    
    if ($value == 2147483646) {
      return 1;
    }
    
    return 0;
  }
  sub convert_double_to_long : int () {
    my $value = (long)2147483646.1;
    
    if ($value == 2147483646L) {
      return 1;
    }
    
    return 0;
  }
  sub convert_double_to_float : int () {
    my $value = (float)0.5;
    
    if ($value == 0.5f) {
      return 1;
    }
    
    return 0;
  }
  
  # Convert type - floating point widning convertion
  sub convert_byte_to_float : int () {
    my $value = (float)(byte)127;
    
    if ($value == 127.0f) {
      return 1;
    }
    
    return 0;
  }
  sub convert_short_to_float : int () {
    my $value = (float)(short)32767;
    
    if ($value == 32767.0f) {
      return 1;
    }
    
    return 0;
  }
  sub convert_int_to_float : int () {
    my $value = (float)32767;
    
    if ($value == 32767.0f) {
      return 1;
    }
    
    return 0;
  }
  sub convert_long_to_float : int () {
    my $value = (float)32767L;
    
    if ($value == 32767.0f) {
      return 1;
    }
    
    return 0;
  }
  sub convert_byte_to_double : int () {
    my $value = (double)(byte)127;
    
    if ($value == 127.0) {
      return 1;
    }
    
    return 0;
  }
  sub convert_short_to_double : int () {
    my $value = (double)(short)32767;
    
    if ($value == 32767.0) {
      return 1;
    }
    
    return 0;
  }
  sub convert_int_to_double : int () {
    my $value = (double)2147483647;
    if ($value == 2147483647.0) {
      return 1;
    }
    
    return 0;
  }
  sub convert_long_to_double : int () {
    my $value = (double)2147483647L;
    
    if ($value == 2147483647.0) {
      return 1;
    }
    
    return 0;
  }
  sub convert_float_to_double : int () {
    my $value = (double)32767.0f;
    
    if ($value == 32767.0) {
      return 1;
    }
    
    return 0;
  }
  
  # Convert type - widning convertion
  sub convert_byte_to_short_plus : int () {
    my $value = (short)(byte)0x7F;
    
    if ((int)$value == (int)(short)0x007F) {
      return 1;
    }
    
    return 0;
  }
  sub convert_byte_to_short_minus : int () {
    my $value = (short)(byte)0xFF;
    
    if ((int)$value == (int)(short)0xFFFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_byte_to_int_plus : int () {
    my $value = (int)(byte)0x7F;
    
    if ($value == 0x0000007F) {
      return 1;
    }
    
    return 0;
  }
  sub convert_byte_to_int_minus : int () {
    my $value = (int)(byte)0xFF;
    
    if ($value == 0xFFFFFFFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_byte_to_long_plus : int () {
    my $value = (long)(byte)0x7F;
    
    if ($value == 0x000000000000007FL) {
      return 1;
    }
    
    return 0;
  }
  sub convert_byte_to_long_minus : int () {
    my $value = (long)(byte)0xFF;
    
    if ($value == 0xFFFFFFFFFFFFFFFFL) {
      return 1;
    }
    
    return 0;
  }
  sub convert_short_to_int_plus : int () {
    my $value = (int)(short)0x7FFF;
    
    if ($value == 0x0000007FFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_short_to_int_minus : int () {
    my $value = (int)(short)0xFFFF;
    
    if ($value == 0xFFFFFFFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_short_to_long_plus : int () {
    my $value = (long)(short)0x7FFF;
    
    if ($value == 0x000000000000007FFFL) {
      return 1;
    }
    
    return 0;
  }
  sub convert_short_to_long_minus : int () {
    my $value = (long)(short)0xFFFF;
    
    if ($value == 0xFFFFFFFFFFFFFFFFL) {
      return 1;
    }
    
    return 0;
  }
  sub convert_int_to_long_plus : int () {
    my $value = (long)0x7FFFFFFF;
    
    if ($value == 0x000000007FFFFFFFL) {
      return 1;
    }
    
    return 0;
  }
  sub convert_int_to_long_minus : int () {
    my $value = (long)0xFFFFFFFF;
    
    if ($value == 0xFFFFFFFFFFFFFFFFL) {
      return 1;
    }
    
    return 0;
  }
  
  # Convert type - convert to same type
  sub convert_long_to_long : int () {
    my $value = (long)0xFFFFFFFFFFFFFFFFL;
    
    if ($value == 0xFFFFFFFFFFFFFFFFL) {
      return 1;
    }
    
    return 0;
  }
  sub convert_int_to_int : int () {
    my $value = (int)0xFFFFFFFF;
    
    if ($value == 0xFFFFFFFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_short_to_short : int () {
    my $value = (short)(short)0xFFFF;
    
    if ((int)$value == (int)(short)0xFFFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_byte_to_byte : int () {
    my $value = (byte)(byte)0xFF;
    
    if ($value == (byte)0xFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_float_to_float : int () {
    my $value = (float)0.5f;
    
    if ($value == 0.5f) {
      return 1;
    }
    
    return 0;
  }
  sub convert_double_to_double : int () {
    my $value = (double)0.5;
    
    if ($value == 0.5) {
      return 1;
    }
    
    return 0;
  }
  
  # Convert type - integral narrowing convertion
  sub convert_long_to_int : int () {
    my $value = (int)0xFFFFFFFFFFFFFFFFL;
    
    if ($value == 0xFFFFFFFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_long_to_short : int () {
    my $value = (short)0xFFFFFFFFFFFFFFFFL;
    
    if ((int)$value == (int)(short)0xFFFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_long_to_byte : int () {
    my $value = (byte)0xFFFFFFFFFFFFFFFFL;
    
    if ((int)$value == (int)(byte)0xFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_int_to_short : int () {
    my $value = (short)0xFFFFFFFF;
    
    if ((int)$value == (int)(short)0xFFFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_int_to_byte : int () {
    my $value = (byte)0xFFFFFFFF;
    
    if ((int)$value == (int)(byte)0xFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_short_to_byte : int () {
    my $value = (byte)(short)0xFFFF;
    
    if ((int)$value == (int)(byte)0xFF) {
      return 1;
    }
    
    return 0;
  }
  sub convert_to_str : int () {
    my $byte_string = (string)(byte)23;
    my $short_string = (string)(short)23;
    my $int_string = (string)23;
    my $long_string = (string)23L;
    my $float_string = (string)0.25000f;
    my $double_string = (string)0.25000;
    
    if ($byte_string eq "23") {
      if ($short_string eq "23") {
        if ($int_string eq "23") {
          if ($long_string eq "23") {
            if ($float_string eq "0.25") {
              if ($double_string eq "0.25") {
                return 1;
              }
            }
          }
        }
      }
    }
    
    return 0;
  }

  sub convert_byte_to_byte_object : int () {
    my $byte : byte = INT8_MIN();
    my $byte_obj = (SPVM::Byte)$byte;
    
    if ($byte_obj isa SPVM::Byte) {
      if ($byte_obj->val == INT8_MIN()) {
        return 1;
      }
    }
    return 0;
  }


  sub convert_short_to_short_object : int () {
    my $short : short = INT16_MIN();
    my $short_obj = (SPVM::Short)$short;
    
    if ($short_obj isa SPVM::Short) {
      if ($short_obj->val == INT16_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_int_to_int_object : int () {
    my $int : int = INT32_MIN();
    my $int_obj = (SPVM::Int)$int;
    
    if ($int_obj isa SPVM::Int) {
      if ($int_obj->val == INT32_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_long_to_long_object : int () {
    my $long : long = INT64_MIN();
    my $long_obj = (SPVM::Long)$long;
    
    if ($long_obj isa SPVM::Long) {
      if ($long_obj->val == INT64_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_float_to_float_object : int () {
    my $float : float = FLT_MIN();
    my $float_obj = (SPVM::Float)$float;
    
    if ($float_obj isa SPVM::Float) {
      if ($float_obj->val == FLT_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_double_to_double_object : int () {
    my $double : double = DBL_MIN();
    my $double_obj = (SPVM::Double)$double;
    
    if ($double_obj isa SPVM::Double) {
      if ($double_obj->val == DBL_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_byte_to_any_object : int () {
    my $byte : byte = INT8_MIN();
    my $byte_obj = (object)$byte;
    
    if ($byte_obj isa SPVM::Byte) {
      my $byte_obj2 = (SPVM::Byte)$byte_obj;
      if ($byte_obj2->val == INT8_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_short_to_any_object : int () {
    my $short : short = INT16_MIN();
    my $short_obj = (object)$short;
    
    if ($short_obj isa SPVM::Short) {
      my $short_obj2 = (SPVM::Short)$short_obj;
      if ($short_obj2->val == INT16_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_int_to_any_object : int () {
    my $int : int = INT32_MIN();
    my $int_obj = (object)$int;
    
    if ($int_obj isa SPVM::Int) {
      my $int_obj2 = (SPVM::Int)$int_obj;
      if ($int_obj2->val == INT32_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_long_to_any_object : int () {
    my $long : long = INT64_MIN();
    my $long_obj = (object)$long;
    
    if ($long_obj isa SPVM::Long) {
      my $long_obj2 = (SPVM::Long)$long_obj;
      if ($long_obj2->val == INT64_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_float_to_any_object : int () {
    my $float : float = FLT_MIN();
    my $float_obj = (object)$float;
    
    if ($float_obj isa SPVM::Float) {
      my $float_obj2 = (SPVM::Float)$float_obj;
      if ($float_obj2->val == FLT_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_double_to_any_object : int () {
    my $double : double = DBL_MIN();
    my $double_obj = (object)$double;
    
    if ($double_obj isa SPVM::Double) {
      my $double_obj2 = (SPVM::Double)$double_obj;
      if ($double_obj2->val == DBL_MIN()) {
        return 1;
      }
    }
    return 0;
  }

  sub convert_byte_object_to_byte : int () {
    my $byte_obj = SPVM::Byte->new(INT8_MIN());
    my $byte = (byte)$byte_obj;
    
    if ($byte == INT8_MIN()) {
      return 1;
    }
    return 0;
  }

  sub convert_short_object_to_short : int () {
    my $short_obj = SPVM::Short->new(INT16_MIN());
    my $short = (short)$short_obj;
    
    if ($short == INT16_MIN()) {
      return 1;
    }
    return 0;
  }

  sub convert_int_object_to_int : int () {
    my $int_obj = SPVM::Int->new(INT32_MIN());
    my $int = (int)$int_obj;
    
    if ($int == INT32_MIN()) {
      return 1;
    }
    return 0;
  }

  sub convert_long_object_to_long : int () {
    my $long_obj = SPVM::Long->new(INT64_MIN());
    my $long = (long)$long_obj;
    
    if ($long == INT64_MIN()) {
      return 1;
    }
    return 0;
  }

  sub convert_float_object_to_float : int () {
    my $float_obj = SPVM::Float->new(FLT_MIN());
    my $float = (float)$float_obj;
    
    if ($float == FLT_MIN()) {
      return 1;
    }
    return 0;
  }
  sub convert_double_object_to_double : int () {
    my $double_obj = SPVM::Double->new(DBL_MIN());
    my $double = (double)$double_obj;
    
    if ($double == DBL_MIN()) {
      return 1;
    }
    return 0;
  }

  sub convert_any_object_to_byte : int () {
    my $byte_obj = (object)SPVM::Byte->new(INT8_MIN());
    my $byte = (byte)$byte_obj;
    
    if ($byte == INT8_MIN()) {
      return 1;
    }
    return 0;
  }

  sub convert_any_object_to_short : int () {
    my $short_obj = (object)SPVM::Short->new(INT16_MIN());
    my $short = (short)$short_obj;
    
    if ($short == INT16_MIN()) {
      return 1;
    }
    return 0;
  }

  sub convert_any_object_to_int : int () {
    my $int_obj = (object)SPVM::Int->new(INT32_MIN());
    my $int = (int)$int_obj;
    
    if ($int == INT32_MIN()) {
      return 1;
    }
    return 0;
  }

  sub convert_any_object_to_long : int () {
    my $long_obj = (object)SPVM::Long->new(INT64_MIN());
    my $long = (long)$long_obj;
    
    if ($long == INT64_MIN()) {
      return 1;
    }
    return 0;
  }

  sub convert_any_object_to_float : int () {
    my $float_obj = (object)SPVM::Float->new(FLT_MIN());
    my $float = (float)$float_obj;
    
    if ($float == FLT_MIN()) {
      return 1;
    }
    return 0;
  }
  sub convert_any_object_to_double : int () {
    my $double_obj = (object)SPVM::Double->new(DBL_MIN());
    my $double = (double)$double_obj;
    
    if ($double == DBL_MIN()) {
      return 1;
    }
    return 0;
  }
}
