Coverage for tests/codegen/generated/variants/imports/host.py: 94%
186 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-02-20 16:25 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-02-20 16:25 +0000
1from ..types import Result, Some
2from abc import abstractmethod
3from dataclasses import dataclass
4from enum import Enum
5from typing import Optional, Protocol, Tuple, Union
7@dataclass
8class DistinguishedS32:
9 value: int
11@dataclass
12class DistinguishedFloat32:
13 value: float
15Distinguished = Union[DistinguishedS32, DistinguishedFloat32]
17class E1(Enum):
18 A = 0
19 B = 1
21@dataclass
22class C1A:
23 value: int
25@dataclass
26class C1B:
27 value: int
29C1 = Union[C1A, C1B]
31@dataclass
32class C2A:
33 value: int
35@dataclass
36class C2B:
37 value: float
39C2 = Union[C2A, C2B]
41@dataclass
42class C3A:
43 value: int
45@dataclass
46class C3B:
47 value: float
49C3 = Union[C3A, C3B]
51@dataclass
52class C4A:
53 value: int
55@dataclass
56class C4B:
57 value: float
59C4 = Union[C4A, C4B]
61@dataclass
62class C5A:
63 value: int
65@dataclass
66class C5B:
67 value: float
69C5 = Union[C5A, C5B]
71@dataclass
72class C6A:
73 value: float
75@dataclass
76class C6B:
77 value: float
79C6 = Union[C6A, C6B]
81Casts = Tuple[C1, C2, C3, C4, C5, C6]
82@dataclass
83class Z1A:
84 value: int
86@dataclass
87class Z1B:
88 pass
90Z1 = Union[Z1A, Z1B]
92@dataclass
93class Z2A:
94 value: int
96@dataclass
97class Z2B:
98 pass
100Z2 = Union[Z2A, Z2B]
102@dataclass
103class Z3A:
104 value: float
106@dataclass
107class Z3B:
108 pass
110Z3 = Union[Z3A, Z3B]
112@dataclass
113class Z4A:
114 value: float
116@dataclass
117class Z4B:
118 pass
120Z4 = Union[Z4A, Z4B]
122Zeros = Tuple[Z1, Z2, Z3, Z4]
123@dataclass
124class AllIntegersBool:
125 value: bool
127@dataclass
128class AllIntegersU8:
129 value: int
131@dataclass
132class AllIntegersU16:
133 value: int
135@dataclass
136class AllIntegersU32:
137 value: int
139@dataclass
140class AllIntegersU64:
141 value: int
143@dataclass
144class AllIntegersS8:
145 value: int
147@dataclass
148class AllIntegersS16:
149 value: int
151@dataclass
152class AllIntegersS32:
153 value: int
155@dataclass
156class AllIntegersS64:
157 value: int
159AllIntegers = Union[AllIntegersBool, AllIntegersU8, AllIntegersU16, AllIntegersU32, AllIntegersU64, AllIntegersS8, AllIntegersS16, AllIntegersS32, AllIntegersS64]
161@dataclass
162class AllFloatsF32:
163 value: float
165@dataclass
166class AllFloatsF64:
167 value: float
169AllFloats = Union[AllFloatsF32, AllFloatsF64]
171@dataclass
172class DuplicatedS32C1:
173 value: int
175@dataclass
176class DuplicatedS32C2:
177 value: int
179@dataclass
180class DuplicatedS32C3:
181 value: int
183DuplicatedS32 = Union[DuplicatedS32C1, DuplicatedS32C2, DuplicatedS32C3]
185@dataclass
186class NestedUnionD:
187 value: Distinguished
189@dataclass
190class NestedUnionS32:
191 value: int
193@dataclass
194class NestedUnionFloat32:
195 value: float
197NestedUnion = Union[NestedUnionD, NestedUnionS32, NestedUnionFloat32]
199@dataclass
200class OptionInUnionO:
201 value: Optional[int]
203@dataclass
204class OptionInUnionI:
205 value: int
207OptionInUnion = Union[OptionInUnionO, OptionInUnionI]
209class HostHost(Protocol):
210 @abstractmethod
211 def roundtrip_option(self, a: Optional[float]) -> Optional[int]:
212 raise NotImplementedError
213 @abstractmethod
214 def roundtrip_result(self, a: Result[int, float]) -> Result[float, int]:
215 raise NotImplementedError
216 @abstractmethod
217 def roundtrip_enum(self, a: E1) -> E1:
218 raise NotImplementedError
219 @abstractmethod
220 def variant_casts(self, a: Casts) -> Casts:
221 raise NotImplementedError
222 @abstractmethod
223 def variant_zeros(self, a: Zeros) -> Zeros:
224 raise NotImplementedError
225 @abstractmethod
226 def add_one_all_integers(self, a: AllIntegers) -> AllIntegers:
227 raise NotImplementedError
228 @abstractmethod
229 def add_one_all_floats(self, a: AllFloats) -> AllFloats:
230 raise NotImplementedError
231 @abstractmethod
232 def add_one_duplicated_s32(self, a: DuplicatedS32) -> DuplicatedS32:
233 raise NotImplementedError
234 @abstractmethod
235 def add_one_distinguished(self, a: Distinguished) -> Distinguished:
236 raise NotImplementedError
237 @abstractmethod
238 def add_one_nested_union(self, a: NestedUnion) -> NestedUnion:
239 raise NotImplementedError
240 @abstractmethod
241 def add_one_option_in_union(self, a: OptionInUnion) -> OptionInUnion:
242 raise NotImplementedError
243 @abstractmethod
244 def add_one_option_in_option(self, a: Optional[Some[Optional[int]]]) -> Optional[Some[Optional[int]]]:
245 raise NotImplementedError