File tree 2 files changed +55
-1
lines changed
2 files changed +55
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: fed62af8873bd7319a380dc9f07cf9fef9414131
2
+ refs/heads/master: bf84d20f7cfba43abb7c895f31b3da23c1fd4a9a
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+
3
+ // The Internet made me do it.
4
+
5
+ obj cat ( ) {
6
+ fn ack ( ) -> str {
7
+ ret "ack" ;
8
+ }
9
+ fn meow ( ) -> str {
10
+ ret "meow" ;
11
+ }
12
+ fn zzz ( ) -> str {
13
+ ret self . meow ( ) ;
14
+ }
15
+ }
16
+
17
+ let shortcat = cat ( ) ;
18
+
19
+ let longcat = obj ( ) {
20
+ fn lol ( ) -> str {
21
+ ret "lol" ;
22
+ }
23
+ fn nyan ( ) -> str {
24
+ ret "nyan" ;
25
+ }
26
+ with shortcat
27
+ } ;
28
+
29
+ let longercat = obj ( ) {
30
+ fn meow ( ) -> str {
31
+ ret "zzz" ;
32
+ }
33
+ with shortcat
34
+ } ;
35
+
36
+ let evenlongercat = obj ( ) {
37
+ fn meow ( ) -> str {
38
+ ret "zzzzzz" ;
39
+ }
40
+ with longercat
41
+ } ;
42
+
43
+ // Tests self-call.
44
+ assert ( shortcat. zzz ( ) == "meow" ) ;
45
+
46
+ // Tests forwarding/backwarding + self-call.
47
+ assert ( longcat. zzz ( ) == "meow" ) ;
48
+
49
+ // Tests forwarding/backwarding + self-call + override.
50
+ assert ( longercat. zzz ( ) == "zzz" ) ;
51
+
52
+ // Tests two-level forwarding/backwarding + self-call + override.
53
+ assert ( evenlongercat. zzz ( ) == "zzzzzz" ) ;
54
+ }
You can’t perform that action at this time.
0 commit comments