Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 94 lines (75 sloc) 2.134 kb
59fcce5 [t] cleaned up attributes/recursive.t and moved to spec/
moritz authored
1 use v6;
2
3 use Test;
4
88d78c6 [t/spec] Test for RT #67236
kyle authored
5 plan 19;
59fcce5 [t] cleaned up attributes/recursive.t and moved to spec/
moritz authored
6
7 =begin pod
8
9 Test attributes with recursively typed attributes
10
11 =end pod
12
13 #L<S12/Attributes>
14 {
15 class A {
16 has A $.attr is rw;
17 };
18
19 my A $a;
20 my A $b;
21 lives_ok {
22 $a .= new();
23 $b .= new(:attr($a));
24 }, 'Can instantiate class with recursively-typed attribute';
e14fe6a Solomon Foster Fix dodgy test. Fudge for niecza.
colomon authored
25 isa_ok $a, A, 'Sanity check, $a is of type A';
59fcce5 [t] cleaned up attributes/recursive.t and moved to spec/
moritz authored
26 ok $b.attr === $a, "Recursively-typed attribute stores correctly";
27 lives_ok { $a.attr = $b; }, "Cycles are fine";
28 ok $b.attr.attr === $b, "Cycles resolve correctly";
29 }
30
8aaac76 Matthew Wilson fix a bunch of smartlinks in S12, broken by me and TimToady++
diakopter authored
31 #L<S12/Class attributes/"Class attributes are declared">
59fcce5 [t] cleaned up attributes/recursive.t and moved to spec/
moritz authored
32 {
33 class B {
34 my B $.attr is rw;
35 };
36
37 my B $a;
23a618d Will Coleda pugs fudge
coke authored
38 #?pugs todo
59fcce5 [t] cleaned up attributes/recursive.t and moved to spec/
moritz authored
39 lives_ok {
40 $a .= new();
41 B.attr = $a;
42 }, "Can instantiate class with recursively-typed class lexical";
23a618d Will Coleda pugs fudge
coke authored
43 #?pugs skip 'Undeclared variable'
59fcce5 [t] cleaned up attributes/recursive.t and moved to spec/
moritz authored
44 ok B.attr === $a, "Recursively-typed class lexical stores correctly";
45
46 }
47
8aaac76 Matthew Wilson fix a bunch of smartlinks in S12, broken by me and TimToady++
diakopter authored
48 #L<S12/Invocants/current lexically-determined class ::?CLASS>
e14fe6a Solomon Foster Fix dodgy test. Fudge for niecza.
colomon authored
49 #?niecza skip 'A type must be provided ???'
59fcce5 [t] cleaned up attributes/recursive.t and moved to spec/
moritz authored
50 {
51 class C {
52 has ::?CLASS $.attr is rw;
53 };
54
55 my C $a;
56 my C $b;
57 lives_ok {
58 $a .= new();
59 $b .= new(:attr($a));
60 }, 'Can instantiate class with ::?CLASS attribute';
61 is $b.attr, $a, '::?CLASS attribute stores correctly';
62 lives_ok { $a.attr = $b; }, '::?CLASS cycles are fine';
63 ok $b.attr.attr === $b, '::?CLASS cycles resolve correctly';
64 lives_ok { $a.attr .= new(); }, 'Can instantiate attribute of type ::?CLASS';
65 isa_ok $a.attr, C, '::?CLASS instantiates to correct class';
66
67
68 class D is C { };
69 my D $d;
70 lives_ok {
71 $d .= new();
72 $d.attr .= new();
73 }, 'Can instantiate derived class with ::?CLASS attribute';
ba8e84a [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
74 #?pugs todo 'bug'
75 isa_ok $d.attr, C, '::?CLASS is lexical, not virtual';
59fcce5 [t] cleaned up attributes/recursive.t and moved to spec/
moritz authored
76 }
77
88d78c6 [t/spec] Test for RT #67236
kyle authored
78 # RT #67236
79 {
80 class Z {
81 has Z @.as is rw;
82 }
83
84 my $good_a = Z.new;
85 lives_ok { $good_a.as[0] = Z.new }, 'can assign';
86 isa_ok $good_a.as[0], Z;
87
88 my $bad_a = Z.new;
89 lives_ok { $bad_a.as.push( Z.new ) }, 'can push';
90 isa_ok $bad_a.as[0], Z;
91 }
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
92
93 # vim: ft=perl6
Something went wrong with that request. Please try again.