class TestCase::Operator::TernaryOperator {
  
  static method ternary_op : int () {
    
    {
      my $left = "true";
      my $right = "false";
      
      my $ret = 1 ? $left : $right;
      
      unless ($ret is_compile_type string) {
        return 0;
      }
    }
    
    {
      my $left = "true";
      my $right = "false";
      
      my $ret = 1 ? $left : $right;
      
      unless ($ret == $left) {
        return 0;
      }
      
      unless ($ret eq "true") {
        return 0;
      }
    }
    
    {
      my $left = (string)undef;
      my $right = "false";
      
      my $ret = 0 ? $left : $right;
      
      unless ($ret == $right) {
        return 0;
      }
      
      
      unless ($ret eq "false") {
        return 0;
      }
    }
    
    {
      my $ret = 1 ? "true" : "false";
      
      unless ($ret eq "true") {
        return 0;
      }
    }
    
    {
      my $ret = 0 ? (string)undef : "false";
      
      unless ($ret eq "false") {
        return 0;
      }
      
    }
    
    {
      my $ret = 0 ? "1" : 0 ? "3" : "2";
      
      unless ($ret eq "2") {
        return 0;
      }
      
    }
    
    {
      my $ret = 0 ? "1" : 1 ? "3" : "2";
      
      unless ($ret eq "3") {
        return 0;
      }
      
    }
    
    {
      my $left = 2;
      my $right = 3;
      
      my $ret = 1 ? $left : $right;
      
      unless ($ret is_compile_type int) {
        return 0;
      }
      unless ($ret == 2) {
        return 0;
      }
    }
    
    {
      my $left = 2;
      my $right = 3;
      
      my $ret = 0 ? $left : $right;
      
      unless ($ret == 3) {
        return 0;
      }
    }
    
    # Operator Precidence
    {
      {
        my $ret = my $flag = 5 ? 1 + 3 : 5 + 3;
        
        unless ($ret == 4) {
          return 0;
        }
      }
      
      {
        my $ret = my $flag = 0 ? 1 + 3 : 5 + 3;
        
        unless ($ret == 8) {
          return 0;
        }
      }
    }
    
    {
      my $name = 0 ? "abc" : undef;
      
      unless ($name is_compile_type string) {
        return 0;
      }
      
      if ($name) {
        return 0;
      }
      
    }
    
    {
      my $name = (byte)1 ? "abc" : undef;
      
      unless ($name eq "abc") {
        return 0;
      }
    }
    return 1;
  }
  
}
