| 1 | // This test orders the interface definitions intentionally |
| 2 | // in such a way that interface `Re` is first, and `Fe` is |
| 3 | // last. The goal is testing that the embedding expansion |
| 4 | // works independently from the source order, and that both |
| 5 | // can be checked/compiled/used at the same time. |
| 6 | interface Re { |
| 7 | I1 |
| 8 | I2 |
| 9 | m_ie() int |
| 10 | } |
| 11 | |
| 12 | interface I1 { |
| 13 | I0 |
| 14 | m1() int |
| 15 | } |
| 16 | |
| 17 | interface I2 { |
| 18 | I0 |
| 19 | m2() int |
| 20 | } |
| 21 | |
| 22 | interface I0 { |
| 23 | m0() int |
| 24 | } |
| 25 | |
| 26 | interface Fe { |
| 27 | I1 |
| 28 | I2 |
| 29 | m_ie() int |
| 30 | } |
| 31 | |
| 32 | struct StructIE { |
| 33 | x int = 456 |
| 34 | } |
| 35 | |
| 36 | fn (s StructIE) m0() int { |
| 37 | println(@METHOD) |
| 38 | return 0 |
| 39 | } |
| 40 | |
| 41 | fn (s StructIE) m1() int { |
| 42 | println(@METHOD) |
| 43 | return 1 |
| 44 | } |
| 45 | |
| 46 | fn (s StructIE) m2() int { |
| 47 | println(@METHOD) |
| 48 | return 2 |
| 49 | } |
| 50 | |
| 51 | fn (s StructIE) m_ie() int { |
| 52 | println(@METHOD) |
| 53 | return 3 |
| 54 | } |
| 55 | |
| 56 | fn test_ie_recursive_forward() { |
| 57 | i := Fe(StructIE{}) |
| 58 | eprintln(i) |
| 59 | assert 0 == i.m0() |
| 60 | assert 1 == i.m1() |
| 61 | assert 2 == i.m2() |
| 62 | assert 3 == i.m_ie() |
| 63 | if i is StructIE { |
| 64 | assert i.x == 456 |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | fn test_ie_recursive_backward() { |
| 69 | i := Re(StructIE{}) |
| 70 | eprintln(i) |
| 71 | assert 0 == i.m0() |
| 72 | assert 1 == i.m1() |
| 73 | assert 2 == i.m2() |
| 74 | assert 3 == i.m_ie() |
| 75 | if i is StructIE { |
| 76 | assert i.x == 456 |
| 77 | } |
| 78 | } |
| 79 | |