|
1 |
| -using ResultsWorld.wit.imports.test.results; |
2 |
| - |
3 | 1 | namespace ResultsWorld.wit.exports.test.results
|
4 | 2 | {
|
5 | 3 | public class TestImpl : ITest
|
6 | 4 | {
|
7 | 5 | public static float StringError(float a)
|
8 | 6 | {
|
9 |
| - return ResultsWorld.wit.imports.test.results.TestInterop.StringError(a); |
| 7 | + return imports.test.results.TestInterop.StringError(a); |
10 | 8 | }
|
11 | 9 |
|
12 | 10 | public static float EnumError(float a)
|
13 | 11 | {
|
14 | 12 | try {
|
15 |
| - return ResultsWorld.wit.imports.test.results.TestInterop.EnumError(a); |
16 |
| - } catch (WitException e) { |
17 |
| - switch ((ResultsWorld.wit.imports.test.results.ITest.E) e.Value) { |
18 |
| - case ResultsWorld.wit.imports.test.results.ITest.E.A: |
19 |
| - throw new WitException(ITest.E.A, 0); |
20 |
| - case ResultsWorld.wit.imports.test.results.ITest.E.B: |
21 |
| - throw new WitException(ITest.E.B, 0); |
22 |
| - case ResultsWorld.wit.imports.test.results.ITest.E.C: |
23 |
| - throw new WitException(ITest.E.C, 0); |
24 |
| - default: |
25 |
| - throw new Exception("unreachable"); |
26 |
| - } |
| 13 | + return imports.test.results.TestInterop.EnumError(a); |
| 14 | + } catch (WitException<imports.test.results.ITest.E> e) { |
| 15 | + throw new WitException(e.TypedValue, 0); |
27 | 16 | }
|
28 | 17 | }
|
29 | 18 |
|
30 | 19 | public static float RecordError(float a)
|
31 | 20 | {
|
32 | 21 | try {
|
33 |
| - return ResultsWorld.wit.imports.test.results.TestInterop.RecordError(a); |
34 |
| - } catch (WitException e) { |
35 |
| - var value = (ResultsWorld.wit.imports.test.results.ITest.E2) e.Value; |
36 |
| - throw new WitException(new ITest.E2(value.line, value.column), 0); |
| 22 | + return imports.test.results.TestInterop.RecordError(a); |
| 23 | + } catch (WitException<imports.test.results.ITest.E2> e) { |
| 24 | + throw new WitException(new ITest.E2(e.TypedValue.line, e.TypedValue.column), 0); |
37 | 25 | }
|
38 | 26 | }
|
39 | 27 |
|
40 | 28 | public static float VariantError(float a)
|
41 | 29 | {
|
42 | 30 | try {
|
43 |
| - return ResultsWorld.wit.imports.test.results.TestInterop.VariantError(a); |
44 |
| - } catch (WitException e) { |
45 |
| - var value = (ResultsWorld.wit.imports.test.results.ITest.E3) e.Value; |
46 |
| - switch (value.Tag) { |
47 |
| - case ResultsWorld.wit.imports.test.results.ITest.E3.Tags.E1: |
48 |
| - switch (value.AsE1) { |
49 |
| - case ResultsWorld.wit.imports.test.results.ITest.E.A: |
50 |
| - throw new WitException(ITest.E3.E1(ITest.E.A), 0); |
51 |
| - case ResultsWorld.wit.imports.test.results.ITest.E.B: |
52 |
| - throw new WitException(ITest.E3.E1(ITest.E.B), 0); |
53 |
| - case ResultsWorld.wit.imports.test.results.ITest.E.C: |
54 |
| - throw new WitException(ITest.E3.E1(ITest.E.C), 0); |
55 |
| - default: |
56 |
| - throw new Exception("unreachable"); |
57 |
| - } |
58 |
| - case ResultsWorld.wit.imports.test.results.ITest.E3.Tags.E2: { |
59 |
| - throw new WitException(ITest.E3.E2(new ITest.E2(value.AsE2.line, value.AsE2.column)), 0); |
60 |
| - } |
61 |
| - default: |
62 |
| - throw new Exception("unreachable"); |
63 |
| - } |
| 31 | + return imports.test.results.TestInterop.VariantError(a); |
| 32 | + } catch (WitException<imports.test.results.ITest.E3> e) |
| 33 | + when (e.TypedValue.Tag == imports.test.results.ITest.E3.Tags.E1) { |
| 34 | + throw new WitException(ITest.E3.E1((ITest.E)Enum.Parse(typeof(ITest.E), e.TypedValue.AsE1.ToString())), 0); |
| 35 | + } catch (WitException<imports.test.results.ITest.E3> e) |
| 36 | + when (e.TypedValue.Tag == imports.test.results.ITest.E3.Tags.E2) { |
| 37 | + throw new WitException(ITest.E3.E2(new ITest.E2(e.TypedValue.AsE2.line, e.TypedValue.AsE2.column)), 0); |
| 38 | + } |
| 39 | + catch { |
| 40 | + throw new Exception("unreachable"); |
64 | 41 | }
|
65 | 42 | }
|
66 | 43 |
|
67 | 44 | public static uint EmptyError(uint a)
|
68 | 45 | {
|
69 |
| - return ResultsWorld.wit.imports.test.results.TestInterop.EmptyError(a); |
| 46 | + return imports.test.results.TestInterop.EmptyError(a); |
70 | 47 | }
|
71 | 48 |
|
72 | 49 | public static void DoubleError(uint a)
|
73 | 50 | {
|
74 |
| - ResultsWorld.wit.imports.test.results.TestInterop.DoubleError(a); |
| 51 | + imports.test.results.TestInterop.DoubleError(a); |
75 | 52 | }
|
76 | 53 | }
|
77 | 54 | }
|
0 commit comments