PageRenderTime 14ms CodeModel.GetById 1ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/perl5/operator_overload_break_runme.pl

#
Perl | 55 lines | 32 code | 19 blank | 4 comment | 8 complexity | eb51c76bac09fe4fb29c6fed00617677 MD5 | raw file
 1#!/usr/bin/perl -w
 2use strict;
 3use Test::More tests => 9;
 4
 5use operator_overload_break;
 6
 7# Workaround for 
 8#   ok( not (expression) , "test description" );
 9# does not working in older versions of Perl, eg 5.004_04
10sub ok_not ($;$) {
11    my($test, $name) = @_;
12    $test = not $test;
13    ok($test, $name);
14}
15
16pass("loaded");
17
18my $op = operator_overload_break::Op->new(5);
19
20isa_ok($op, "operator_overload_break::Op");
21
22ok((2 == $op - 3),
23   "subtraction");
24
25$op->{k} = 37;
26
27ok((40 == $op + 3),
28   "addition");
29
30$op->{k} = 22;
31
32ok((10 == (32 - $op)),
33   "reversed subtraction");
34
35ok_not((3 == $op),
36       'not equal');
37
38$op->{k} = 3;
39
40++$op;
41
42ok(($op == 4),
43   "pre-increment operator");
44
45$op++;
46
47ok(($op == 5),
48   "post-increment operator");
49
50my $op2 = ++$op;
51
52$op2 = $op++;
53
54ok(($op == 7) and ($op2 == 7),
55   "multiple post-increments");