Code/Expression/Op/Not.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 45 CC 4 SCAR 17.6
CC
4
Cov
0%
output
12.0
new
6.0
unary
2.0
CRAP 5.8
1 package JavaScript::Code::Expression::Op::Not;
2
3 use strict;
4 use vars qw[ $VERSION ];
5 use base qw[ JavaScript::Code::Expression::Op ];
6
7 $VERSION = '0.02';
8
9 =head1 NAME
10
11 JavaScript::Code::Expression::Op::not
12
13 =head1 METHODS
14
15 =head2 new
16
17 =cut
18
19 sub new {
20 my $obj = shift;
21 my $class = ref $obj || $obj;
22
23 die("'$class' is a unary operator and must take exactly 1 operand.")
24 unless @_ == 1;
25
26 return bless [@_], $class;
27 }
28
29 =head2 $self->unary
30
31 =cut
32
33 sub unary { return 1; }
34
35 =head2 $self->precedence( )
36
37 =cut
38
39 sub precedence { return 300; }
40
41 =head2 $self->output( )
42
43 =cut
44
45 sub output {
46 my ( $self, $precedence ) = @_;
47 $precedence = 0 if not defined $precedence;
48
49 my $output = ($self->children())[0]->output( $self->precedence );
50 $output = "!$output";
51 $output = "($output)" if $precedence > $self->precedence;
52
53 return $output;
54 }
55
56 =head1 SEE ALSO
57
58 L<JavaScript::Code>
59
60 =head1 AUTHOR
61
62 Sascha Kiefer, C<esskar@cpan.org>
63
64 =head1 LICENSE
65
66 This library is free software, you can redistribute it and/or modify it under
67 the same terms as Perl itself.
68
69 =cut
70
71 1;
72