File: export_to_tcl.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 (28 lines) | stat: -rw-r--r-- 718 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
# tests convenience sub export_to_tcl

use Test;
BEGIN {plan tests=>4}
use Tcl;

my $int = Tcl->new;

$tcl::foo = $tcl::foo = 'qwerty';
my $x = "some perl scalar var";

$int->export_to_tcl(subs_from=>'tcl',vars_from=>'tcl');
$int->export_to_tcl(subs=>{lala=>sub{"ok"}}, namespace=>'');
$int->export_to_tcl(vars=>{foo1=>\$x}, namespace=>'');

# this should croak:
#$int->export_to_tcl(vars=>{foo=>$x}, namespace=>'');

$int->export_to_tcl(subs_from=>''); # this will bind sub named sub1 below
sub sub1 {"sub1 its me"}
sub tcl::sub2 {"sub2 its me"}

ok($int->call('perl::sub1'),"sub1 its me");
ok($int->call('lala'),"ok");

ok($int->Eval('set perl::foo'),'qwerty');
ok($int->call('set','foo1'),'some perl scalar var');