Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 75 lines (58 sloc) 2.649 kb
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
1 use v6;
2
3 use Test;
4
78711fd @sorear Fudge S06-advanced_subroutine_features/caller.t for Niecza (only one tes...
sorear authored
5
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
6
832f178 [t/spec] fix more smartlinks; down to 33 broken links
moritz authored
7 # L<S06/The C<callframe> and C<caller> functions>
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
8
9 # caller.subname
10 sub a_sub { b_sub() }
11 sub b_sub { try { caller.subname } }
99d737e [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
12 #?pugs todo "feature"
5f0bdab @coke niecza unfudge
coke authored
13 #?niecza todo "try interferes with caller counting"
99d737e [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
14 is ~a_sub(), "a_sub", "caller.sub works";
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
15
16 # caller.file
99d737e [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
17 #?pugs todo "feature"
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
18 ok index(~(try { caller.file }), "caller") >= 0, "caller.file works";
19
20 # caller.line (XXX: make sure to edit the expected line number!)
99d737e [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
21 #?pugs 2 todo "feature"
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
22 sub call_line { caller.line };
78711fd @sorear Fudge S06-advanced_subroutine_features/caller.t for Niecza (only one tes...
sorear authored
23 is call_line(), 23, "caller.line works";
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
24
13cc9c4 [t/spec] 71 typos in 32 files.
Util authored
25 # pugs: caller exposes a bug in the MMD mechanism where directly using autogenerated
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
26 # accessors on an object returned by a factory, rather than storing the object
27 # in an intermediate variable, works only when you chain methods with an
28 # explicit () between them: caller().subname - ok; caller.subname - error.
29
30 sub try_it {
31 my ($code, $expected, $desc) = @_;
32 is($code(), $expected, $desc);
33 }
34 sub try_it_caller { try_it(@_) } # (line 33.)
35 class A { method try_it_caller_A { &Main::try_it_caller(@_) } }
36 sub try_it_caller_caller { A.try_it_caller_A(@_) }
37 class B { method try_it_caller_B { &Main::try_it_caller_caller(@_) } }
38
78711fd @sorear Fudge S06-advanced_subroutine_features/caller.t for Niecza (only one tes...
sorear authored
39 #?DOES 1
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
40 sub chain { B.try_it_caller_B(@_) }
41
42 # pugs: must use parentheses after caller
43
44 # basic tests of caller object
78711fd @sorear Fudge S06-advanced_subroutine_features/caller.t for Niecza (only one tes...
sorear authored
45 #?niecza skip "NYI"
46 {
f85b8bf Fix a bunch of typeobject stringifications.
kboga authored
47 chain({ WHAT(caller()).gist }, "Control::Caller()", "caller object type");
78711fd @sorear Fudge S06-advanced_subroutine_features/caller.t for Niecza (only one tes...
sorear authored
48 chain({ caller().package }, "Main", "caller package");
49 chain({ caller().file }, $?FILE, "caller filename");
50 chain({ caller().line }, "32", "caller line");
51 chain({ caller().subname }, "&Main::try_it_caller", "caller subname");
52 chain({ caller().subtype }, "SubRoutine", "caller subtype"); # specme
53 chain({ caller().sub }, &try_it_caller, "caller sub (code)");
54 }
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
55
56 # select by code type
78711fd @sorear Fudge S06-advanced_subroutine_features/caller.t for Niecza (only one tes...
sorear authored
57 #?niecza skip "NYI"
58 {
59 chain({ caller(Any).subname }, "&Main::try_it_caller", "code type - Any");
60 chain({ caller("Any").subname }, "&Main::try_it_caller", "code type - Any (string)");
61 chain({ caller(Method).subname }, "&A::try_it_caller_A", "code type - Method");
62 chain({ caller("Moose") }, Mu, "code type - not found");
63 chain({ caller(:skip<1>).subname }, "&A::try_it_caller_A", ":skip<1>");
64 chain({ caller(:skip<128>) }, Mu, ":skip<128> - not found");
65 chain({ caller(Sub, :skip<1>).subname }, "&Main::try_it_caller_caller", "Sub, :skip<1>");
66 chain({ caller(Sub, :skip<2>).subname }, "&Main::chain", "Sub, :skip<2>");
67 chain({ caller(Method, :skip<1>).subname }, "&B::try_it_caller_B", "Method, :skip<1>");
68 }
97563ca [t/spec] slight edits to S06-advanced_subroutine_features/caller.t
finanalyst authored
69
70 # WRITEME: label tests
71
78711fd @sorear Fudge S06-advanced_subroutine_features/caller.t for Niecza (only one tes...
sorear authored
72 done;
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
73
74 # vim: ft=perl6
Something went wrong with that request. Please try again.