File: disposal-subs.t

package info (click to toggle)
libtcl-perl 1.32%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 288 kB
  • sloc: perl: 417; tcl: 19; makefile: 14
file content (51 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download | duplicates (4)
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
# see how CODE REFs are created and then freed

use Tcl;

$| = 1;

print "1..2\n";

my $int = Tcl->new;

$int->call('after', 1000, sub {"foo, bar, fluffy\n";});

my $q = 0;
for (1 .. 1000) {
    my $r = 'aaa';
    $int->call('after', 1000, sub {"*";});
    $int->call('after', 1000, sub {$r++;"$r#";});

    $int->call('if', 1000, sub {
	$r++;
	$q++;
    });
}

$int->icall('after', 3000, 'set var fafafa');
$int->icall('vwait', 'var'); # will wait for 3 seconds

# we have a number of commands created in Tcl, '::perl' package,
# but they must have been disposed.
my @p1 = $int->icall('info', 'commands', '::perl::*');
print STDERR "[[@p1; $r]]\n";

print +($#p1>10?"not ":""), "ok 1\n";

for (1 .. 1000) {
    my $r = 'aaa';
    $int->call('after', 1000, sub {"*";});
    $int->call('after', 1000, sub {$r++;"$r#";});

    $int->call('if', 1000, sub {
	$r++;
	$q++;
    });
}
$int->icall('after', 300, 'set var fafafa');
$int->icall('vwait', 'var'); # will wait for 0.3 seconds; will still have procs
my @p2 = $int->icall('info', 'commands', '::perl::*');
print +($#p2<10?"not ":""), "ok 2\n";

# now we finish and procs destroyed on cleanup