File: damian.t

package info (click to toggle)
libwant-perl 0.09-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 108 kB
  • ctags: 15
  • sloc: perl: 140; makefile: 55
file content (54 lines) | stat: -rw-r--r-- 942 bytes parent folder | download | duplicates (7)
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
BEGIN { $| = 1; print "1..26\n"; }
use warnings;
use strict;

# Test that we can load the module
my $loaded;
END {print "not ok 1\n" unless $loaded;}
use Want;
$loaded = 1;
print "ok 1\n";

# Test for Damian's loop bug

sub do_something_anything {}
my $ok = 2;
my @answers = (1,1,0,0,1,1,0,0,1,1,0,0,
               0,0,1,1,0,0,1,1,0,0,1,1);
sub okedoke {
  print((shift == shift @answers? "ok " : "not ok "),
  	$ok++, "\n");
}

my $flipflop = 0;

sub foo {
	okedoke(want 'BOOL');
	return $flipflop=!$flipflop;   # alternate true and false
}

for (1..3) {
	while (foo() ) {
		do_something_anything;
	}
	while (my $answer = foo() ) {
		do_something_anything;
	}
}

sub bar {
	okedoke(want '!BOOL');
	return $flipflop=!$flipflop;   # alternate true and false
}

for (1..3) {
	while (bar() ) {
		do_something_anything;
	}
	my $answer;
	while ($answer = bar() ) {
		do_something_anything;
	}
}

print (@answers == 0 ? "ok 26\n" : "not ok 26\n");