retrieve shortcut list from inferior process.
[sepia.git] / t / 50expect.t
blobbaf043ae3724085eed155e1b43bcb7163e5d7e0c
1 #!/usr/bin/env perl
3 BEGIN {
4 eval 'use Test::Expect';
5 if ($@) {
6 print "# requires Test::Expect\n1..1\nok 1\n";
7 exit 0;
8 } else {
9 eval 'use Test::Simple tests => 36';
13 use FindBin '$Bin';
14 use Sepia;
15 use Sepia::Xref;
17 expect_run
18 command => "$^X -Mblib -MSepia -MSepia::Xref -e Sepia::repl",
19 prompt => [-re => 'main @[^>]*> '],
20 quit => ',quit';
21 expect_handle()->log_file('/tmp/b')
22 if exists $ENV{USER} && $ENV{USER} eq 'seano';
24 expect ",help",
25 q!REPL commands (prefixed with ','):
26 break [F:N [E]] Set a breakpoint in F at line N (or at current
27 position), enabled if E evalutes to true.
28 cd DIR Change directory to DIR
29 debug [0|1] Enable or disable debugging.
30 delete Delete current breakpoint.
31 format [dumper|dump|yaml|plain]
32 Set output formatter (default: dumper)
33 help Display this message
34 lsbreak List breakpoints.
35 methods X [RE] List methods for reference or package X,
36 matching optional pattern RE.
38 package PACKAGE Set evaluation package to PACKAGE
39 quit Quit the REPL
40 reload Reload Sepia.pm and relaunch the REPL.
41 shell CMD ... Run CMD in the shell.
42 strict [0|1] Turn 'use strict' mode on or off
43 wantarray [0|1] Set or toggle evaluation context
44 who PACKAGE [RE] List variables and subs in PACKAGE matching optional
45 pattern RE.!
46 if 0;
48 expect_send ",wh Sepia::Xref xref";
49 expect_like qr/xref \s+ xref_definitions \s+ xref_main \s+ xref_cv \s+ xref_exclude \s+ xref_object \s* /x;
51 expect_send '{ package A; sub a {}; package X; @ISA = qw(A); sub x {} };';
52 expect ",wh X", 'X:://
53 @ISA x', 'package list';
54 expect ",me X", 'a x', 'methods 1';
56 expect '$x = bless {}, X;', '$x = bless {}, X;'; # XXX: stupid expect.
57 expect ',me $x', ",me \$x\na x", 'methods 2'; # XXX: stupid expect.
59 ######################################################################
60 ## Debugger
61 expect ',lsb', '';
62 expect_send ',debug 1';
63 expect_send "do '$Bin/testy.pl';", 'get testy';
65 expect 'fib1 10', '55', 'plain fib';
66 expect ',br testy.pl:6', "break testy.pl:6 if 1", 'break?';
67 expect_send 'fib1 10';
68 # sleep 1;
69 expect_like qr|_<$Bin/testy.pl:6>|, 'break in fib';
70 # XXX AGAIN STUPID EXPECT!
71 expect '$n = 3', "\$n = 3\n3", 'munge lexicals';
72 expect '$n = 3', "\$n = 3\n3", 'munge lexicals';
73 # Solaris has different whitespace output here.
74 # Also, / */ doesn't seem to work.
75 expect_send ',in', 'munged';
76 expect_like qr{\[3\] DB::DB:\n[ \t]\$n = \\3}, 'munged';
77 # qr{\[3\] DB::DB:\n? *\$n = \\3.*};
78 expect ',del', '';
79 expect ',con', '2', 'return from fib';
80 expect_send 'fib2 10', 'bad fib';
81 expect_like qr/_<$Bin\/testy.pl:12>/;
82 expect_send ',q', 'quit';
83 # expect_like qr/_<$Bin\/testy.pl:12>/;
84 expect_like qr/error: asdf/, 'saw die message';
86 print <<'EOS' if 0; # for debugging
87 ,help
88 ,wh Sepia::Xref xref
89 { package A; sub a {}; package X; @ISA = qw(A); sub x {} };
90 ,wh X
91 ,me X
92 $x = bless {}, X;
93 ,me $x
94 ,lsb
95 ,debug 1
96 do 'testy.pl';
97 fib1 10
98 ,br testy.pl:6
99 fib1 10
100 $n = 3
102 ,del
103 ,con
104 fib2 10