File: ProhibitMixedBooleanOperators.run

package info (click to toggle)
libperl-critic-perl 1.088-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,792 kB
  • ctags: 1,556
  • sloc: perl: 17,417; lisp: 340; makefile: 2
file content (76 lines) | stat: -rw-r--r-- 2,035 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
##############################################################################
#      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/t/ValuesAndExpressions/ProhibitMixedBooleanOperators.run $
#     $Date: 2008-03-16 17:40:45 -0500 (Sun, 16 Mar 2008) $
#   $Author: clonezone $
# $Revision: 2187 $
##############################################################################


## name High-precedence passing
## failures 0
## cut

next if ! $finished || $foo < $bar;
if( $foo && !$bar || $baz){ do_something() }
this() && !that() || the_other(); 

#-----------------------------------------------------------------------------

## name Low-precedence passing
## failures 0
## cut

next if not $finished or $foo < $bar;
if( $foo and not $bar or $baz){ do_something() }
this() and not that() or the_other(); 

#-----------------------------------------------------------------------------

## name Basic failure
## failures 3
## cut

next if not $finished || $foo < $bar;
if( $foo && not $bar or $baz){ do_something() }
this() and ! that() or the_other(); 

#-----------------------------------------------------------------------------

## name High-precedence with low precedence self-equals
## failures 0
## cut

$sub ||= sub {
   return 1 and 2;
};

#-----------------------------------------------------------------------------

## name Mixed booleans in same statement, but different expressions
## failures 0
## cut

# See http://rt.cpan.org/Ticket/Display.html?id=27637
ok( ! 1, 'values are URLs' ) or diag 'never happens';

#-----------------------------------------------------------------------------

## name Mixed booleans in code blocks
## failures 0
## cut

eval {
    if (1 || 2) {
        return not 3;
    }
};

##############################################################################
# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 78
#   indent-tabs-mode: nil
#   c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :