We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f888397 commit d1b71f3Copy full SHA for d1b71f3
t/nqp/25-class.t
@@ -2,11 +2,11 @@
2
3
# class
4
5
-plan(2);
+plan(5);
6
7
class XYZ {
8
method foo($x) {
9
- say($x);
+ ok($x eq 'ok 1');
10
}
11
12
@@ -19,11 +19,29 @@ $xyz.foo('ok 1');
19
20
class QRS {
21
22
+ ok($x eq 'ok 2');
23
24
25
26
my $qrs := QRS.new();
27
28
$qrs.foo('ok 2');
29
30
+class ABC {
31
+ my $foo := 15;
32
+ my sub helper($x) {
33
+ $x*2;
34
+ }
35
+ method foo($x) {
36
+ helper($x);
37
38
+ method bar($x) {
39
+ $foo := $foo + $x;
40
+ $foo;
41
42
+}
43
+
44
+my $abc := ABC.new();
45
+ok($abc.foo(100) == 200,"using a lexical sub inside a method");
46
+ok($abc.bar(10) == 25,"using a outer lexical inside a method");
47
+ok($abc.bar(1) == 26,"the value of the lexical persisting");
0 commit comments