package TestCase::LogicalOperator {
  use TestCase::Minimal;

  sub logical_and_nagate : int () {
    if (!(1 && 1)) {
      return 0;
    }
    
    return 1;
  }
  
  sub logical_and_push_mortal_leave_scope : int () {
    my $minimals = new TestCase::Minimal[4];
    $minimals->[0] = TestCase::Minimal->new;
    $minimals->[0]{x} = 1;
    $minimals->[1] = TestCase::Minimal->new;
    $minimals->[1]{x} = 2;
    $minimals->[2] = TestCase::Minimal->new;
    $minimals->[2]{x} = 3;
    $minimals->[3] = TestCase::Minimal->new;
    $minimals->[3]{x} = 4;
    
    
    if ($minimals->[0]{x} == 1 && $minimals->[1]{x} == 2 && $minimals->[2]{x} == 3 && $minimals->[3]{x} == 4) {
      return 1;
    }
    
    return 0;
  }
  
  sub logical_not_true : int () {
    if (!1) {
      return 0;
    }
    
    return 1;
  }
  sub logical_not_false : int () {
    if (!0) {
      return 1;
    }
    
    return 0;
  }

  # logical or
  sub logical_or_both_true : int () {
    if (1 || 1) {
      return 1;
    }
    
    return 0;
  }
  
  sub logical_or_left_true : int () {
    if (1 || 0) {
      return 1;
    }
    
    return 0;
  }

  sub logical_or_right_true : int () {
    if (0 || 1) {
      return 1;
    }
    
    return 0;
  }

  sub logical_or_both_false : int () {
    if (0 || 0) {
      return 0;
    }
    
    return 1;
  }
  
  # logical and
  sub logical_and_both_true : int () {
    if (1 && 1) {
      return 1;
    }
    
    return 0;
  }
  
  sub logical_and_left_true : int () {
    if (1 && 0) {
      return 0;
    }
    
    return 1;
  }

  sub logical_and_right_true : int () {
    if (1 && 0) {
      return 0;
    }
    
    return 1;
  }

  sub logical_and_both_false : int () {
    if (0 && 0) {
      return 0;
    }
    
    return 1;
  }
}
