Coverage for tests/codegen/test_variants.py: 97%

181 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-02-20 16:25 +0000

1from . import bindgen 

2from wasmtime import Store 

3from typing import Optional 

4 

5module = """ 

6 (component 

7 (import "host" (instance $i 

8 (type $e1 (enum "a" "b")) 

9 

10 (type $c1 (variant (case "a" s32) (case "b" s64))) 

11 (type $c2 (variant (case "a" s32) (case "b" float32))) 

12 (type $c3 (variant (case "a" s32) (case "b" float64))) 

13 (type $c4 (variant (case "a" s64) (case "b" float32))) 

14 (type $c5 (variant (case "a" s64) (case "b" float64))) 

15 (type $c6 (variant (case "a" float32) (case "b" float64))) 

16 

17 (type $z1 (variant (case "a" s32) (case "b"))) 

18 (type $z2 (variant (case "a" s64) (case "b"))) 

19 (type $z3 (variant (case "a" float32) (case "b"))) 

20 (type $z4 (variant (case "a" float64) (case "b"))) 

21 

22 (type $all-integers (variant 

23 (case "bool" bool) 

24 (case "u8" u8) 

25 (case "u16" u16) 

26 (case "u32" u32) 

27 (case "u64" u64) 

28 (case "s8" s8) 

29 (case "s16" s16) 

30 (case "s32" s32) 

31 (case "s64" s64) 

32 )) 

33 (type $all-floats (variant (case "f32" float32) (case "f64" float64))) 

34 (type $duplicated-s32 (variant 

35 (case "c1" s32) 

36 (case "c2" s32) 

37 (case "c3" s32) 

38 )) 

39 (type $distinguished (variant (case "s32" s32) (case "float32" float32))) 

40 (export $distinguished' "distinguished" (type (eq $distinguished))) 

41 

42 (type $nested-union (variant 

43 (case "d" $distinguished') 

44 (case "s32" s32) 

45 (case "float32" float32) 

46 )) 

47 (type $option-in-union (variant (case "o" (option s32)) (case "i" s32))) 

48 

49 (export $e1' "e1" (type (eq $e1))) 

50 

51 (export $c1' "c1" (type (eq $c1))) 

52 (export $c2' "c2" (type (eq $c2))) 

53 (export $c3' "c3" (type (eq $c3))) 

54 (export $c4' "c4" (type (eq $c4))) 

55 (export $c5' "c5" (type (eq $c5))) 

56 (export $c6' "c6" (type (eq $c6))) 

57 (type $casts (tuple $c1' $c2' $c3' $c4' $c5' $c6')) 

58 (export $casts' "casts" (type (eq $casts))) 

59 

60 (export $z1' "z1" (type (eq $z1))) 

61 (export $z2' "z2" (type (eq $z2))) 

62 (export $z3' "z3" (type (eq $z3))) 

63 (export $z4' "z4" (type (eq $z4))) 

64 (type $zeros (tuple $z1' $z2' $z3' $z4')) 

65 (export $zeros' "zeros" (type (eq $zeros))) 

66 

67 (export $all-integers' "all-integers" (type (eq $all-integers))) 

68 (export $all-floats' "all-floats" (type (eq $all-floats))) 

69 (export $duplicated-s32' "duplicated-s32" (type (eq $duplicated-s32))) 

70 (export $nested-union' "nested-union" (type (eq $nested-union))) 

71 (export $option-in-union' "option-in-union" (type (eq $option-in-union))) 

72 

73 (export "roundtrip-option" (func (param "a" (option float32)) (result (option u8)))) 

74 (export "roundtrip-result" (func 

75 (param "a" (result u32 (error float32))) 

76 (result (result float64 (error u8))) 

77 )) 

78 (export "roundtrip-enum" (func (param "a" $e1') (result $e1'))) 

79 (export "variant-casts" (func (param "a" $casts') (result $casts'))) 

80 (export "variant-zeros" (func (param "a" $zeros') (result $zeros'))) 

81 

82 (export "add-one-all-integers" (func (param "a" $all-integers') (result $all-integers'))) 

83 (export "add-one-all-floats" (func (param "a" $all-floats') (result $all-floats'))) 

84 (export "add-one-duplicated-s32" (func (param "a" $duplicated-s32') (result $duplicated-s32'))) 

85 (export "add-one-distinguished" (func (param "a" $distinguished') (result $distinguished'))) 

86 (export "add-one-nested-union" (func (param "a" $nested-union') (result $nested-union'))) 

87 (export "add-one-option-in-union" (func (param "a" $option-in-union') (result $option-in-union'))) 

88 (export "add-one-option-in-option" (func (param "a" (option (option s32))) (result (option (option s32))))) 

89 )) 

90 

91 (core module $libc (memory (export "m") 1)) 

92 (core instance $libc (instantiate $libc)) 

93 

94 (core func $r-opt (canon lower (func $i "roundtrip-option") (memory $libc "m"))) 

95 (core func $r-result (canon lower (func $i "roundtrip-result") (memory $libc "m"))) 

96 (core func $r-enum (canon lower (func $i "roundtrip-enum"))) 

97 (core func $v-casts (canon lower (func $i "variant-casts") (memory $libc "m"))) 

98 (core func $v-zeros (canon lower (func $i "variant-zeros") (memory $libc "m"))) 

99 (core func $a-int (canon lower (func $i "add-one-all-integers") (memory $libc "m"))) 

100 (core func $a-float (canon lower (func $i "add-one-all-floats") (memory $libc "m"))) 

101 (core func $a-dup (canon lower (func $i "add-one-duplicated-s32") (memory $libc "m"))) 

102 (core func $a-dist (canon lower (func $i "add-one-distinguished") (memory $libc "m"))) 

103 (core func $a-nest (canon lower (func $i "add-one-nested-union") (memory $libc "m"))) 

104 (core func $a-oinu (canon lower (func $i "add-one-option-in-union") (memory $libc "m"))) 

105 (core func $a-oino (canon lower (func $i "add-one-option-in-option") (memory $libc "m"))) 

106 

107 (core module $m 

108 (import "libc" "m" (memory 1)) 

109 (import "" "r-opt" (func $r-opt (param i32 f32 i32))) 

110 (import "" "r-result" (func $r-result (param i32 i32 i32))) 

111 (import "" "r-enum" (func $r-enum (param i32) (result i32))) 

112 (import "" "v-casts" (func $v-casts 

113 (param i32 i64 i32 i32 i32 i64 i32 i64 i32 i64 i32 i64 i32) 

114 )) 

115 (import "" "v-zeros" (func $v-zeros 

116 (param i32 i32 i32 i64 i32 f32 i32 f64 i32) 

117 )) 

118 (import "" "a-int" (func $a-int (param i32 i64 i32))) 

119 (import "" "a-float" (func $a-float (param i32 i64 i32))) 

120 (import "" "a-dup" (func $a-dup (param i32 i32 i32))) 

121 (import "" "a-dist" (func $a-dist (param i32 i32 i32))) 

122 (import "" "a-nest" (func $a-nest (param i32 i32 i32 i32))) 

123 (import "" "a-oinu" (func $a-oinu (param i32 i32 i32 i32))) 

124 (import "" "a-oino" (func $a-oino (param i32 i32 i32 i32))) 

125 

126 (func (export "r-opt") (param i32 f32) (result i32) 

127 (call $r-opt (local.get 0) (local.get 1) (i32.const 100)) 

128 i32.const 100) 

129 (func (export "r-result") (param i32 i32) (result i32) 

130 (call $r-result (local.get 0) (local.get 1) (i32.const 100)) 

131 i32.const 100) 

132 (func (export "r-enum") (param i32) (result i32) 

133 (call $r-enum (local.get 0))) 

134 (func (export "v-casts") 

135 (param i32 i64 i32 i32 i32 i64 i32 i64 i32 i64 i32 i64) 

136 (result i32) 

137 local.get 0 

138 local.get 1 

139 local.get 2 

140 local.get 3 

141 local.get 4 

142 local.get 5 

143 local.get 6 

144 local.get 7 

145 local.get 8 

146 local.get 9 

147 local.get 10 

148 local.get 11 

149 i32.const 80 

150 call $v-casts 

151 i32.const 80) 

152 (func (export "v-zeros") 

153 (param i32 i32 i32 i64 i32 f32 i32 f64) 

154 (result i32) 

155 local.get 0 

156 local.get 1 

157 local.get 2 

158 local.get 3 

159 local.get 4 

160 local.get 5 

161 local.get 6 

162 local.get 7 

163 i32.const 80 

164 call $v-zeros 

165 i32.const 80) 

166 

167 (func (export "a-int") (param i32 i64) (result i32) 

168 (call $a-int (local.get 0) (local.get 1) (i32.const 80)) 

169 i32.const 80) 

170 (func (export "a-float") (param i32 i64) (result i32) 

171 (call $a-float (local.get 0) (local.get 1) (i32.const 80)) 

172 i32.const 80) 

173 (func (export "a-dup") (param i32 i32) (result i32) 

174 (call $a-dup (local.get 0) (local.get 1) (i32.const 80)) 

175 i32.const 80) 

176 (func (export "a-dist") (param i32 i32) (result i32) 

177 (call $a-dist (local.get 0) (local.get 1) (i32.const 80)) 

178 i32.const 80) 

179 (func (export "a-nest") (param i32 i32 i32) (result i32) 

180 (call $a-nest (local.get 0) (local.get 1) (local.get 2) (i32.const 80)) 

181 i32.const 80) 

182 (func (export "a-oinu") (param i32 i32 i32) (result i32) 

183 (call $a-oinu (local.get 0) (local.get 1) (local.get 2) (i32.const 80)) 

184 i32.const 80) 

185 (func (export "a-oino") (param i32 i32 i32) (result i32) 

186 (call $a-oino (local.get 0) (local.get 1) (local.get 2) (i32.const 80)) 

187 i32.const 80) 

188 ) 

189 

190 (core instance $i (instantiate $m 

191 (with "libc" (instance $libc)) 

192 (with "" (instance 

193 (export "r-opt" (func $r-opt)) 

194 (export "r-result" (func $r-result)) 

195 (export "r-enum" (func $r-enum)) 

196 (export "v-casts" (func $v-casts)) 

197 (export "v-zeros" (func $v-zeros)) 

198 (export "a-int" (func $a-int)) 

199 (export "a-float" (func $a-float)) 

200 (export "a-dup" (func $a-dup)) 

201 (export "a-dist" (func $a-dist)) 

202 (export "a-nest" (func $a-nest)) 

203 (export "a-oinu" (func $a-oinu)) 

204 (export "a-oino" (func $a-oino)) 

205 )) 

206 )) 

207 

208 (type $e1 (enum "a" "b")) 

209 

210 (type $c1 (variant (case "a" s32) (case "b" s64))) 

211 (type $c2 (variant (case "a" s32) (case "b" float32))) 

212 (type $c3 (variant (case "a" s32) (case "b" float64))) 

213 (type $c4 (variant (case "a" s64) (case "b" float32))) 

214 (type $c5 (variant (case "a" s64) (case "b" float64))) 

215 (type $c6 (variant (case "a" float32) (case "b" float64))) 

216 (type $casts (tuple $c1 $c2 $c3 $c4 $c5 $c6)) 

217 

218 (type $z1 (variant (case "a" s32) (case "b"))) 

219 (type $z2 (variant (case "a" s64) (case "b"))) 

220 (type $z3 (variant (case "a" float32) (case "b"))) 

221 (type $z4 (variant (case "a" float64) (case "b"))) 

222 (type $zeros (tuple $z1 $z2 $z3 $z4)) 

223 

224 (type $all-integers (variant 

225 (case "bool" bool) 

226 (case "u8" u8) 

227 (case "u16" u16) 

228 (case "u32" u32) 

229 (case "u64" u64) 

230 (case "s8" s8) 

231 (case "s16" s16) 

232 (case "s32" s32) 

233 (case "s64" s64) 

234 )) 

235 (type $all-floats (variant (case "f32" float32) (case "f64" float64))) 

236 (type $duplicated-s32 (variant 

237 (case "c1" s32) 

238 (case "c2" s32) 

239 (case "c3" s32) 

240 )) 

241 (type $distinguished (variant (case "s32" s32) (case "float32" float32))) 

242 (type $nested-union (variant 

243 (case "d" $distinguished) 

244 (case "s32" s32) 

245 (case "float32" float32) 

246 )) 

247 (type $option-in-union (variant (case "o" (option s32)) (case "i" s32))) 

248 

249 (func $roundtrip-option (param "a" (option float32)) (result (option u8)) 

250 (canon lift (core func $i "r-opt") (memory $libc "m"))) 

251 (func $roundtrip-result 

252 (param "a" (result u32 (error float32))) 

253 (result (result float64 (error u8))) 

254 (canon lift (core func $i "r-result") (memory $libc "m"))) 

255 (func $roundtrip-enum (param "a" $e1) (result $e1) 

256 (canon lift (core func $i "r-enum"))) 

257 (func $variant-casts (param "a" $casts) (result $casts) 

258 (canon lift (core func $i "v-casts") (memory $libc "m"))) 

259 (func $variant-zeros (param "a" $zeros) (result $zeros) 

260 (canon lift (core func $i "v-zeros") (memory $libc "m"))) 

261 

262 (func $add-one-all-integers (param "a" $all-integers) (result $all-integers) 

263 (canon lift (core func $i "a-int") (memory $libc "m"))) 

264 (func $add-one-all-floats (param "a" $all-floats) (result $all-floats) 

265 (canon lift (core func $i "a-float") (memory $libc "m"))) 

266 (func $add-one-duplicated-s32 (param "a" $duplicated-s32) (result $duplicated-s32) 

267 (canon lift (core func $i "a-dup") (memory $libc "m"))) 

268 (func $add-one-distinguished (param "a" $distinguished) (result $distinguished) 

269 (canon lift (core func $i "a-dist") (memory $libc "m"))) 

270 (func $add-one-nested-union (param "a" $nested-union) (result $nested-union) 

271 (canon lift (core func $i "a-nest") (memory $libc "m"))) 

272 (func $add-one-option-in-union (param "a" $option-in-union) (result $option-in-union) 

273 (canon lift (core func $i "a-oinu") (memory $libc "m"))) 

274 (func $add-one-option-in-option (param "a" (option (option s32))) (result (option (option s32))) 

275 (canon lift (core func $i "a-oino") (memory $libc "m"))) 

276 

277 (instance (export "e") 

278 (export "e1" (type $e1)) 

279 

280 (export "c1" (type $c1)) 

281 (export "c2" (type $c2)) 

282 (export "c3" (type $c3)) 

283 (export "c4" (type $c4)) 

284 (export "c5" (type $c5)) 

285 (export "c6" (type $c6)) 

286 (export "casts" (type $casts)) 

287 

288 (export "z1" (type $z1)) 

289 (export "z2" (type $z2)) 

290 (export "z3" (type $z3)) 

291 (export "z4" (type $z4)) 

292 (export "zeros" (type $zeros)) 

293 

294 (export "all-integers" (type $all-integers)) 

295 (export "all-floats" (type $all-floats)) 

296 (export "duplicated-s32" (type $duplicated-s32)) 

297 (export "distinguished" (type $distinguished)) 

298 (export "nested-union" (type $nested-union)) 

299 (export "option-in-union" (type $option-in-union)) 

300 

301 (export "roundtrip-option" (func $roundtrip-option)) 

302 (export "roundtrip-result" (func $roundtrip-result)) 

303 (export "roundtrip-enum" (func $roundtrip-enum)) 

304 (export "variant-casts" (func $variant-casts)) 

305 (export "variant-zeros" (func $variant-zeros)) 

306 (export "add-one-all-integers" (func $add-one-all-integers)) 

307 (export "add-one-all-floats" (func $add-one-all-floats)) 

308 (export "add-one-duplicated-s32" (func $add-one-duplicated-s32)) 

309 (export "add-one-distinguished" (func $add-one-distinguished)) 

310 (export "add-one-nested-union" (func $add-one-nested-union)) 

311 (export "add-one-option-in-union" (func $add-one-option-in-union)) 

312 (export "add-one-option-in-option" (func $add-one-option-in-option)) 

313 ) 

314 ) 

315""" 

316bindgen('variants', module) 

317 

318from .generated.variants import Root, RootImports, imports 

319from .generated.variants import e 

320from .generated.variants.imports import host 

321from .generated.variants.types import Result, Ok, Err, Some 

322 

323 

324class Host(imports.HostHost): 

325 def roundtrip_option(self, a: Optional[float]) -> Optional[int]: 

326 if a: 

327 return int(a) 

328 return None 

329 

330 def roundtrip_result(self, a: Result[int, float]) -> Result[float, int]: 

331 if isinstance(a, Ok): 

332 return Ok(float(a.value)) 

333 return Err(int(a.value)) 

334 

335 def roundtrip_enum(self, a: host.E1) -> host.E1: 

336 return a 

337 

338 def variant_casts(self, a: host.Casts) -> host.Casts: 

339 return a 

340 

341 def variant_zeros(self, a: host.Zeros) -> host.Zeros: 

342 return a 

343 

344 def add_one_all_integers(self, num: host.AllIntegers) -> host.AllIntegers: 

345 # Bool 

346 if isinstance(num, host.AllIntegersBool): 

347 assert num.value in (True, False) 

348 return host.AllIntegersBool(not num.value) 

349 # The unsigned numbers 

350 elif isinstance(num, host.AllIntegersU8): 

351 lower_limit = 0 

352 upper_limit = 2**8 

353 assert lower_limit <= num.value < upper_limit 

354 return host.AllIntegersU8((num.value + 1) % upper_limit) 

355 elif isinstance(num, host.AllIntegersU16): 

356 lower_limit = 0 

357 upper_limit = 2**16 

358 assert lower_limit <= num.value < upper_limit 

359 return host.AllIntegersU16((num.value + 1) % upper_limit) 

360 elif isinstance(num, host.AllIntegersU32): 

361 lower_limit = 0 

362 upper_limit = 2**32 

363 assert lower_limit <= num.value < upper_limit 

364 return host.AllIntegersU32((num.value + 1) % upper_limit) 

365 elif isinstance(num, host.AllIntegersU64): 

366 lower_limit = 0 

367 upper_limit = 2**64 

368 assert lower_limit <= num.value < upper_limit 

369 return host.AllIntegersU64((num.value + 1) % upper_limit) 

370 # The signed numbers 

371 elif isinstance(num, host.AllIntegersS8): 

372 lower_limit = -2**7 

373 upper_limit = 2**7 

374 assert lower_limit <= num.value < upper_limit 

375 return host.AllIntegersS8(num.value + 1) 

376 elif isinstance(num, host.AllIntegersS16): 

377 lower_limit = -2**15 

378 upper_limit = 2**15 

379 assert lower_limit <= num.value < upper_limit 

380 return host.AllIntegersS16(num.value + 1) 

381 elif isinstance(num, host.AllIntegersS32): 

382 lower_limit = -2**31 

383 upper_limit = 2**31 

384 assert lower_limit <= num.value < upper_limit 

385 return host.AllIntegersS32(num.value + 1) 

386 elif isinstance(num, host.AllIntegersS64): 

387 lower_limit = -2**63 

388 upper_limit = 2**63 

389 assert lower_limit <= num.value < upper_limit 

390 return host.AllIntegersS64(num.value + 1) 

391 else: 

392 raise ValueError("Invalid input value!") 

393 

394 def add_one_all_floats(self, num: host.AllFloats) -> host.AllFloats: 

395 if isinstance(num, host.AllFloatsF32): 

396 return host.AllFloatsF32(num.value + 1) 

397 if isinstance(num, host.AllFloatsF64): 

398 return host.AllFloatsF64(num.value + 1) 

399 else: 

400 raise ValueError("Invalid input value!") 

401 

402 def add_one_duplicated_s32(self, num: host.DuplicatedS32) -> host.DuplicatedS32: 

403 if isinstance(num, host.DuplicatedS32C1): 

404 return host.DuplicatedS32C1(num.value + 1) 

405 if isinstance(num, host.DuplicatedS32C2): 

406 return host.DuplicatedS32C2(num.value + 1) 

407 if isinstance(num, host.DuplicatedS32C3): 

408 return host.DuplicatedS32C3(num.value + 1) 

409 else: 

410 raise ValueError("Invalid input value!") 

411 

412 def add_one_distinguished(self, a: host.Distinguished) -> host.Distinguished: 

413 a.value += 1 

414 return a 

415 

416 def add_one_nested_union(self, a: host.NestedUnion) -> host.NestedUnion: 

417 if isinstance(a, host.NestedUnionD): 

418 a.value.value += 1 

419 return host.NestedUnionD(a.value) 

420 if isinstance(a, host.NestedUnionS32): 

421 return host.NestedUnionS32(a.value + 1) 

422 if isinstance(a, host.NestedUnionFloat32): 

423 return host.NestedUnionFloat32(a.value + 1) 

424 else: 

425 raise ValueError("Invalid input value!") 

426 

427 def add_one_option_in_union(self, a: host.OptionInUnion) -> host.OptionInUnion: 

428 if isinstance(a, host.OptionInUnionO): 

429 if a.value is None: 

430 return host.OptionInUnionO(None) 

431 else: 

432 return host.OptionInUnionO(a.value + 1) 

433 if isinstance(a, host.OptionInUnionI): 

434 return host.OptionInUnionI(a.value + 1) 

435 else: 

436 raise ValueError("Invalid input value!") 

437 

438 def add_one_option_in_option(self, a: Optional[Some[Optional[int]]]) -> Optional[Some[Optional[int]]]: 

439 if isinstance(a, Some): 

440 if a.value is None: 

441 return Some(None) 

442 else: 

443 return Some(a.value + 1) 

444 if a is None: 

445 return None 

446 else: 

447 raise ValueError("Invalid input value!") 

448 

449 

450def test_bindings(): 

451 store = Store() 

452 wasm = Root(store, RootImports(host=Host())) 

453 

454 exports = wasm.e() 

455 assert exports.roundtrip_option(store, 1.) == 1 

456 assert exports.roundtrip_option(store, None) is None 

457 assert exports.roundtrip_option(store, 2.) == 2 

458 

459 assert exports.roundtrip_result(store, Ok(2)) == Ok(2) 

460 assert exports.roundtrip_result(store, Ok(4)) == Ok(4) 

461 assert exports.roundtrip_result(store, Err(5)) == Err(5) 

462 

463 assert exports.roundtrip_enum(store, e.E1.A) == e.E1.A 

464 assert exports.roundtrip_enum(store, e.E1.B) == e.E1.B 

465 

466 a1, a2, a3, a4, a5, a6 = exports.variant_casts(store, ( 

467 e.C1A(1), 

468 e.C2A(2), 

469 e.C3A(3), 

470 e.C4A(4), 

471 e.C5A(5), 

472 e.C6A(6.), 

473 )) 

474 assert a1 == e.C1A(1) 

475 assert a2 == e.C2A(2) 

476 assert a3 == e.C3A(3) 

477 assert a4 == e.C4A(4) 

478 assert a5 == e.C5A(5) 

479 assert a6 == e.C6A(6.) 

480 

481 b1, b2, b3, b4, b5, b6 = exports.variant_casts(store, ( 

482 e.C1B(1), 

483 e.C2B(2), 

484 e.C3B(3), 

485 e.C4B(4), 

486 e.C5B(5), 

487 e.C6B(6.), 

488 )) 

489 assert b1 == e.C1B(1) 

490 assert b2 == e.C2B(2) 

491 assert b3 == e.C3B(3) 

492 assert b4 == e.C4B(4) 

493 assert b5 == e.C5B(5) 

494 assert b6 == e.C6B(6.) 

495 

496 z1, z2, z3, z4 = exports.variant_zeros(store, ( 

497 e.Z1A(1), 

498 e.Z2A(2), 

499 e.Z3A(3.), 

500 e.Z4A(4.), 

501 )) 

502 assert z1 == e.Z1A(1) 

503 assert z2 == e.Z2A(2) 

504 assert z3 == e.Z3A(3.) 

505 assert z4 == e.Z4A(4.) 

506 

507 # All-Integers 

508 # Booleans 

509 assert exports.add_one_all_integers(store, e.AllIntegersBool(False)) == e.AllIntegersBool(True) 

510 assert exports.add_one_all_integers(store, e.AllIntegersBool(True)) == e.AllIntegersBool(False) 

511 # Unsigned integers 

512 assert exports.add_one_all_integers(store, e.AllIntegersU8(0)) == e.AllIntegersU8(1) 

513 assert exports.add_one_all_integers(store, e.AllIntegersU8(2**8 - 1)) == e.AllIntegersU8(0) 

514 assert exports.add_one_all_integers(store, e.AllIntegersU16(0)) == e.AllIntegersU16(1) 

515 assert exports.add_one_all_integers(store, e.AllIntegersU16(2**16 - 1)) == e.AllIntegersU16(0) 

516 assert exports.add_one_all_integers(store, e.AllIntegersU32(0)) == e.AllIntegersU32(1) 

517 assert exports.add_one_all_integers(store, e.AllIntegersU32(2**32 - 1)) == e.AllIntegersU32(0) 

518 assert exports.add_one_all_integers(store, e.AllIntegersU64(0)) == e.AllIntegersU64(1) 

519 assert exports.add_one_all_integers(store, e.AllIntegersU64(2**64 - 1)) == e.AllIntegersU64(0) 

520 # Signed integers 

521 assert exports.add_one_all_integers(store, e.AllIntegersS8(0)) == e.AllIntegersS8(1) 

522 assert exports.add_one_all_integers(store, e.AllIntegersS8(2**7 - 2)) == e.AllIntegersS8(2**7 - 1) 

523 assert exports.add_one_all_integers(store, e.AllIntegersS8(-8)) == e.AllIntegersS8(-7) 

524 assert exports.add_one_all_integers(store, e.AllIntegersS16(0)) == e.AllIntegersS16(1) 

525 assert exports.add_one_all_integers(store, e.AllIntegersS16(2**15 - 2)) == e.AllIntegersS16(2**15 - 1) 

526 assert exports.add_one_all_integers(store, e.AllIntegersS16(-8)) == e.AllIntegersS16(-7) 

527 assert exports.add_one_all_integers(store, e.AllIntegersS32(0)) == e.AllIntegersS32(1) 

528 assert exports.add_one_all_integers(store, e.AllIntegersS32(2**31 - 2)) == e.AllIntegersS32(2**31 - 1) 

529 assert exports.add_one_all_integers(store, e.AllIntegersS32(-8)) == e.AllIntegersS32(-7) 

530 assert exports.add_one_all_integers(store, e.AllIntegersS64(0)) == e.AllIntegersS64(1) 

531 assert exports.add_one_all_integers(store, e.AllIntegersS64(2**63 - 2)) == e.AllIntegersS64(2**63 - 1) 

532 assert exports.add_one_all_integers(store, e.AllIntegersS64(-8)) == e.AllIntegersS64(-7) 

533 

534 assert exports.add_one_all_floats(store, e.AllFloatsF32(0.0)) == e.AllFloatsF32(1.0) 

535 assert exports.add_one_all_floats(store, e.AllFloatsF64(0.0)) == e.AllFloatsF64(1.0) 

536 

537 assert exports.add_one_duplicated_s32(store, e.DuplicatedS32C1(0)) == e.DuplicatedS32C1(1) 

538 assert exports.add_one_duplicated_s32(store, e.DuplicatedS32C2(1)) == e.DuplicatedS32C2(2) 

539 assert exports.add_one_duplicated_s32(store, e.DuplicatedS32C3(2)) == e.DuplicatedS32C3(3) 

540 

541 assert exports.add_one_distinguished(store, e.DistinguishedS32(1)) == e.DistinguishedS32(2) 

542 assert exports.add_one_distinguished(store, e.DistinguishedFloat32(2.)) == e.DistinguishedFloat32(3.) 

543 

544 assert exports.add_one_nested_union(store, e.NestedUnionD(e.DistinguishedS32(1))) == e.NestedUnionD(e.DistinguishedS32(2)) 

545 assert exports.add_one_nested_union(store, e.NestedUnionD(e.DistinguishedFloat32(2.))) == e.NestedUnionD(e.DistinguishedFloat32(3.)) 

546 assert exports.add_one_nested_union(store, e.NestedUnionS32(3)) == e.NestedUnionS32(4) 

547 assert exports.add_one_nested_union(store, e.NestedUnionFloat32(4.)) == e.NestedUnionFloat32(5.) 

548 

549 assert exports.add_one_option_in_union(store, e.OptionInUnionO(1)) == e.OptionInUnionO(2) 

550 assert exports.add_one_option_in_union(store, e.OptionInUnionO(None)) == e.OptionInUnionO(None) 

551 assert exports.add_one_option_in_union(store, e.OptionInUnionI(1)) == e.OptionInUnionI(2) 

552 

553 assert exports.add_one_option_in_option(store, Some(1)) == Some(2) 

554 assert exports.add_one_option_in_option(store, Some(None)) == Some(None) 

555 assert exports.add_one_option_in_option(store, None) is None