xref: /openbsd/gnu/usr.bin/perl/dist/Term-ReadLine/t/Tk.t (revision 898184e3)
1#!perl
2
3use Test::More;
4
5eval "use Tk; 1" or
6    plan skip_all => "Tk is not installed.";
7
8# seeing as the entire point of this test is to test the event handler,
9# we need to mock as little as possible.  To keep things tightly controlled,
10# we'll use the Stub directly.
11BEGIN {
12    $ENV{PERL_RL} = 'Stub o=0';
13}
14
15my $mw;
16eval {
17    use File::Spec;
18    $mw = MainWindow->new(); $mw->withdraw();
19    1;
20} or plan skip_all => "Tk can't start. DISPLAY not set?";
21
22# need to delay this so that Tk is loaded first.
23require Term::ReadLine;
24
25plan tests => 3;
26
27my $t = Term::ReadLine->new('Tk');
28ok($t, "Created object");
29is($t->ReadLine, 'Term::ReadLine::Stub', 'Correct type');
30$t->tkRunning(1);
31
32my $text = 'some text';
33my $T = $text . "\n";
34
35my $w = Tk::after($mw,0,
36                  sub {
37                      pass("Event loop called");
38                      exit 0;
39                  });
40
41my $result = $t->readline('Do not press enter>');
42fail("Should not get here.");
43