fune/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.py
Ben Dean-Kawamura fb5bfb756d Bug 1766045 - Vendoring in Rust code for uniffi-bindgen-gecko-js r=glandium,supply-chain-reviewers
- Added `--enable-uniffi-fixtures` flag.  When set, we will compile in
  the UniFFI test fixtures into our shared Rust crate and eventually
  into `libxul`.
- Vendoring in the Rust crates needed for `uniffi-bindgen-gecko-js`

Differential Revision: https://phabricator.services.mozilla.com/D144467
2022-08-02 19:51:48 +00:00

37 lines
686 B
Python

from arithmetic import *
try:
add(18446744073709551615, 1)
assert(not("Should have thrown a IntegerOverflow exception!"))
except ArithmeticError.IntegerOverflow:
# It's okay!
pass
assert add(2, 4) == 6
assert add(4, 8) == 12
try:
sub(0, 1)
assert(not("Should have thrown a IntegerOverflow exception!"))
except ArithmeticError.IntegerOverflow:
# It's okay!
pass
assert sub(4, 2) == 2
assert sub(8, 4) == 4
assert div(8, 4) == 2
try:
div(8, 0)
except InternalError:
# It's okay!
pass
else:
assert(not("Should have panicked when dividing by zero"))
assert equal(2, 2)
assert equal(4, 4)
assert not equal(2, 4)
assert not equal(4, 8)