|
| 1 | +import wit.test.resource_alias_redux.runner; |
| 2 | + |
| 3 | +import wit.test.resource_alias_redux.runner.imports.the_test : Thing1 = Thing; |
| 4 | +import wit.test.resource_alias_redux.resource_alias1.imports : Foo1 = Foo, Thing2 = Thing; |
| 5 | +import wit.test.resource_alias_redux.resource_alias2.imports : Foo2 = Foo; |
| 6 | + |
| 7 | +import wit.common; |
| 8 | + |
| 9 | +@witExport("$root", "run") |
| 10 | +void run() { |
| 11 | + auto thing1 = Thing.makeNew("Ni Hao".witList); |
| 12 | + scope(exit) thing1.witDrop; |
| 13 | + |
| 14 | + { |
| 15 | + Thing1[1] things = [thing1]; |
| 16 | + auto result = test(things.witList); |
| 17 | + thing1 = Thing1.init; // consumed |
| 18 | + scope(exit) result.witFree; |
| 19 | + assert(result.length == 1); |
| 20 | + |
| 21 | + { |
| 22 | + auto str = result[0].get; |
| 23 | + scope(exit) str.witFree; |
| 24 | + |
| 25 | + assert(str == "Ni Hao GuestThing GuestThing.get"); |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + |
| 30 | + auto thing2 = Thing2.makeNew("Ciao".witList); |
| 31 | + scope(exit) thing2.witDrop; |
| 32 | + |
| 33 | + { |
| 34 | + auto result = a(Foo1(thing: thing2)); |
| 35 | + thing2 = Thing2.init; // consumed |
| 36 | + scope(exit) result.witFree; |
| 37 | + assert(result.length == 1); |
| 38 | + |
| 39 | + { |
| 40 | + auto str = result[0].get; |
| 41 | + scope(exit) str.witFree; |
| 42 | + |
| 43 | + assert(str == "Ciao GuestThing GuestThing.get"); |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + |
| 48 | + auto thing3 = Thing2.makeNew("Ciao".witList); |
| 49 | + scope(exit) thing3.witDrop; |
| 50 | + auto thing4 = Thing2.makeNew("Aloha".witList); |
| 51 | + scope(exit) thing4.witDrop; |
| 52 | + |
| 53 | + { |
| 54 | + auto result = b(Foo2(thing: thing3), Bar(thing: thing4)); |
| 55 | + thing3 = Thing2.init; // consumed |
| 56 | + thing4 = Thing2.init; // consumed |
| 57 | + scope(exit) result.witFree; |
| 58 | + assert(result.length == 2); |
| 59 | + |
| 60 | + { |
| 61 | + auto str = result[0].get; |
| 62 | + scope(exit) str.witFree; |
| 63 | + |
| 64 | + assert(str == "Ciao GuestThing GuestThing.get"); |
| 65 | + } |
| 66 | + |
| 67 | + { |
| 68 | + auto str = result[1].get; |
| 69 | + scope(exit) str.witFree; |
| 70 | + |
| 71 | + assert(str == "Aloha GuestThing GuestThing.get"); |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +alias Exports = wit.test.resource_alias_redux.runner.Exports!( |
| 77 | + run |
| 78 | +); |
0 commit comments