Commit | Line | Data |
---|---|---|
c07656ed FC |
1 | #!perl |
2 | ||
3 | print "1..14\n"; | |
4 | ||
5 | { | |
6 | our sub foo { 42 } | |
7 | print "not " unless foo == 42; | |
8 | print "ok 1 - calling our sub from same package\n"; | |
9 | print "not " unless &foo == 42; | |
10 | print "ok 2 - calling our sub from same package (amper)\n"; | |
11 | package bar; | |
12 | sub bar::foo { 43 } | |
13 | print "not " unless foo == 42; | |
14 | print "ok 3 - calling our sub from another package # TODO\n"; | |
15 | print "not " unless &foo == 42; | |
16 | print "ok 4 - calling our sub from another package (amper)\n"; | |
17 | } | |
18 | package bar; | |
19 | print "not " unless foo == 43; | |
20 | print "ok 5 - our sub falling out of scope\n"; | |
21 | print "not " unless &foo == 43; | |
22 | print "ok 6 - our sub falling out of scope (called via amper)\n"; | |
23 | package main; | |
24 | { | |
25 | sub bar::a { 43 } | |
26 | our sub a { | |
27 | if (shift) { | |
28 | package bar; | |
29 | print "not " unless a == 43; | |
30 | print "ok 7 - our sub invisible inside itself\n"; | |
31 | print "not " unless &a == 43; | |
32 | print "ok 8 - our sub invisible inside itself (called via amper)\n"; | |
33 | } | |
34 | 42 | |
35 | } | |
36 | a(1); | |
37 | sub bar::b { 43 } | |
38 | our sub b; | |
39 | our sub b { | |
40 | if (shift) { | |
41 | package bar; | |
42 | print "not " unless b == 42; | |
43 | print "ok 9 - our sub visible inside itself after decl # TODO\n"; | |
44 | print "not " unless &b == 42; | |
45 | print "ok 10 - our sub visible inside itself after decl (amper)\n"; | |
46 | } | |
47 | 42 | |
48 | } | |
49 | b(1) | |
50 | } | |
51 | sub c { 42 } | |
52 | sub bar::c { 43 } | |
53 | { | |
54 | our sub c; | |
55 | package bar; | |
56 | print "not " unless c == 42; | |
57 | print "ok 11 - our sub foo; makes lex alias for existing sub # TODO\n"; | |
58 | print "not " unless &c == 42; | |
59 | print "ok 12 - our sub foo; makes lex alias for existing sub (amper)\n"; | |
60 | } | |
61 | { | |
62 | our sub d; | |
63 | sub d { 'd42' } | |
64 | sub bar::d { 'd43' } | |
65 | package bar; | |
66 | print "not " unless d eq 'd42'; | |
67 | print "ok 13 - our sub foo; applies to subsequent sub foo {} # TODO\n"; | |
68 | print "not " unless &d eq 'd42'; | |
69 | print "ok 14 - our sub foo; applies to subsequent sub foo {} (amper)\n"; | |
70 | } |