diff options
Diffstat (limited to '')
-rw-r--r-- | toolkit/components/uniffi-fixtures/arithmetic/Cargo.toml | 21 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/arithmetic/build.rs (renamed from third_party/rust/uniffi-example-arithmetic/build.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/arithmetic/src/arithmetic.udl (renamed from third_party/rust/uniffi-example-arithmetic/src/arithmetic.udl) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/arithmetic/src/lib.rs (renamed from third_party/rust/uniffi-example-arithmetic/src/lib.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.kts (renamed from third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.kts) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.py | 37 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.rb (renamed from third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.rb) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.swift (renamed from third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.swift) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/arithmetic/tests/test_generated_bindings.rs (renamed from third_party/rust/uniffi-example-arithmetic/tests/test_generated_bindings.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/arithmetic/uniffi.toml (renamed from third_party/rust/uniffi-example-arithmetic/uniffi.toml) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/callbacks/Cargo.toml (renamed from toolkit/components/uniffi-fixture-callbacks/Cargo.toml) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/callbacks/build.rs (renamed from toolkit/components/uniffi-fixture-callbacks/build.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/callbacks/src/callbacks.udl (renamed from toolkit/components/uniffi-fixture-callbacks/src/callbacks.udl) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/callbacks/src/lib.rs (renamed from toolkit/components/uniffi-fixture-callbacks/src/lib.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/custom-types/Cargo.toml (renamed from toolkit/components/uniffi-example-custom-types/Cargo.toml) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/custom-types/build.rs (renamed from toolkit/components/uniffi-example-custom-types/build.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/custom-types/src/custom-types.udl (renamed from toolkit/components/uniffi-example-custom-types/src/custom-types.udl) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/custom-types/src/lib.rs (renamed from toolkit/components/uniffi-example-custom-types/src/lib.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/custom-types/tests/bindings/test_custom_types.kts (renamed from toolkit/components/uniffi-example-custom-types/tests/bindings/test_custom_types.kts) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/custom-types/tests/bindings/test_custom_types.swift (renamed from toolkit/components/uniffi-example-custom-types/tests/bindings/test_custom_types.swift) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/custom-types/tests/test_generated_bindings.rs (renamed from toolkit/components/uniffi-example-custom-types/tests/test_generated_bindings.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/custom-types/uniffi.toml (renamed from toolkit/components/uniffi-example-custom-types/uniffi.toml) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/external-types/Cargo.toml | 15 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/external-types/build.rs (renamed from toolkit/components/uniffi-fixture-external-types/build.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/external-types/src/external-types.udl (renamed from toolkit/components/uniffi-fixture-external-types/src/external-types.udl) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/external-types/src/lib.rs (renamed from toolkit/components/uniffi-fixture-external-types/src/lib.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/geometry/Cargo.toml | 20 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/geometry/build.rs (renamed from third_party/rust/uniffi-example-geometry/build.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/geometry/src/geometry.udl (renamed from third_party/rust/uniffi-example-geometry/src/geometry.udl) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/geometry/src/lib.rs (renamed from third_party/rust/uniffi-example-geometry/src/lib.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.kts (renamed from third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.kts) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.py (renamed from third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.py) | 2 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.rb (renamed from third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.rb) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.swift (renamed from third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.swift) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/geometry/tests/test_generated_bindings.rs (renamed from third_party/rust/uniffi-example-geometry/tests/test_generated_bindings.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/refcounts/Cargo.toml (renamed from toolkit/components/uniffi-fixture-refcounts/Cargo.toml) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/refcounts/build.rs (renamed from toolkit/components/uniffi-fixture-refcounts/build.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/refcounts/src/lib.rs | 32 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/refcounts/src/refcounts.udl (renamed from toolkit/components/uniffi-fixture-refcounts/src/refcounts.udl) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/Cargo.toml | 20 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/build.rs (renamed from third_party/rust/uniffi-example-rondpoint/build.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/src/lib.rs (renamed from third_party/rust/uniffi-example-rondpoint/src/lib.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/src/rondpoint.udl (renamed from third_party/rust/uniffi-example-rondpoint/src/rondpoint.udl) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.kts (renamed from third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.kts) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.py (renamed from third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.py) | 75 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.rb (renamed from third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.rb) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.swift (renamed from third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.swift) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/tests/test_generated_bindings.rs (renamed from third_party/rust/uniffi-example-rondpoint/tests/test_generated_bindings.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/sprites/Cargo.toml | 20 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/sprites/build.rs (renamed from third_party/rust/uniffi-example-sprites/build.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/sprites/src/lib.rs (renamed from third_party/rust/uniffi-example-sprites/src/lib.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/sprites/src/sprites.udl (renamed from third_party/rust/uniffi-example-sprites/src/sprites.udl) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.kts (renamed from third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.kts) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.py (renamed from third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.py) | 3 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.rb (renamed from third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.rb) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.swift (renamed from third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.swift) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/sprites/tests/test_generated_bindings.rs (renamed from third_party/rust/uniffi-example-sprites/tests/test_generated_bindings.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/todolist/Cargo.toml | 22 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/todolist/build.rs (renamed from third_party/rust/uniffi-example-todolist/build.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/todolist/src/lib.rs (renamed from third_party/rust/uniffi-example-todolist/src/lib.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/todolist/src/todolist.udl (renamed from third_party/rust/uniffi-example-todolist/src/todolist.udl) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.kts (renamed from third_party/rust/uniffi-example-todolist/tests/bindings/test_todolist.kts) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.py | 56 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.rb (renamed from third_party/rust/uniffi-example-todolist/tests/bindings/test_todolist.rb) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.swift (renamed from third_party/rust/uniffi-example-todolist/tests/bindings/test_todolist.swift) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/todolist/tests/test_generated_bindings.rs (renamed from third_party/rust/uniffi-example-todolist/tests/test_generated_bindings.rs) | 0 |
66 files changed, 301 insertions, 22 deletions
diff --git a/toolkit/components/uniffi-fixtures/arithmetic/Cargo.toml b/toolkit/components/uniffi-fixtures/arithmetic/Cargo.toml new file mode 100644 index 0000000000..b497b8cccc --- /dev/null +++ b/toolkit/components/uniffi-fixtures/arithmetic/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "uniffi-example-arithmetic" +edition = "2021" +version = "0.22.0" +authors = ["Firefox Sync Team <sync-team@mozilla.com>"] +license = "MPL-2.0" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +name = "arithmetical" + +[dependencies] +uniffi = { workspace = true } +thiserror = "1.0" + +[build-dependencies] +uniffi = { workspace = true, features = ["build"] } + +[dev-dependencies] +uniffi = { workspace = true, features = ["bindgen-tests"] } diff --git a/third_party/rust/uniffi-example-arithmetic/build.rs b/toolkit/components/uniffi-fixtures/arithmetic/build.rs index 303ac22d8d..303ac22d8d 100644 --- a/third_party/rust/uniffi-example-arithmetic/build.rs +++ b/toolkit/components/uniffi-fixtures/arithmetic/build.rs diff --git a/third_party/rust/uniffi-example-arithmetic/src/arithmetic.udl b/toolkit/components/uniffi-fixtures/arithmetic/src/arithmetic.udl index 117df4834a..117df4834a 100644 --- a/third_party/rust/uniffi-example-arithmetic/src/arithmetic.udl +++ b/toolkit/components/uniffi-fixtures/arithmetic/src/arithmetic.udl diff --git a/third_party/rust/uniffi-example-arithmetic/src/lib.rs b/toolkit/components/uniffi-fixtures/arithmetic/src/lib.rs index 92ab8c072b..92ab8c072b 100644 --- a/third_party/rust/uniffi-example-arithmetic/src/lib.rs +++ b/toolkit/components/uniffi-fixtures/arithmetic/src/lib.rs diff --git a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.kts b/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.kts index ef11850ae2..ef11850ae2 100644 --- a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.kts +++ b/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.kts diff --git a/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.py b/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.py new file mode 100644 index 0000000000..e1b4f71277 --- /dev/null +++ b/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.py @@ -0,0 +1,37 @@ +from arithmetic import InternalError, add, div, equal, sub + +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) diff --git a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.rb b/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.rb index 6669eb279f..6669eb279f 100644 --- a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.rb +++ b/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.rb diff --git a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.swift b/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.swift index a8e34680e4..a8e34680e4 100644 --- a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.swift +++ b/toolkit/components/uniffi-fixtures/arithmetic/tests/bindings/test_arithmetic.swift diff --git a/third_party/rust/uniffi-example-arithmetic/tests/test_generated_bindings.rs b/toolkit/components/uniffi-fixtures/arithmetic/tests/test_generated_bindings.rs index 168e6e1d4c..168e6e1d4c 100644 --- a/third_party/rust/uniffi-example-arithmetic/tests/test_generated_bindings.rs +++ b/toolkit/components/uniffi-fixtures/arithmetic/tests/test_generated_bindings.rs diff --git a/third_party/rust/uniffi-example-arithmetic/uniffi.toml b/toolkit/components/uniffi-fixtures/arithmetic/uniffi.toml index 883231dcaa..883231dcaa 100644 --- a/third_party/rust/uniffi-example-arithmetic/uniffi.toml +++ b/toolkit/components/uniffi-fixtures/arithmetic/uniffi.toml diff --git a/toolkit/components/uniffi-fixture-callbacks/Cargo.toml b/toolkit/components/uniffi-fixtures/callbacks/Cargo.toml index 19a8d61070..19a8d61070 100644 --- a/toolkit/components/uniffi-fixture-callbacks/Cargo.toml +++ b/toolkit/components/uniffi-fixtures/callbacks/Cargo.toml diff --git a/toolkit/components/uniffi-fixture-callbacks/build.rs b/toolkit/components/uniffi-fixtures/callbacks/build.rs index e7152d922a..e7152d922a 100644 --- a/toolkit/components/uniffi-fixture-callbacks/build.rs +++ b/toolkit/components/uniffi-fixtures/callbacks/build.rs diff --git a/toolkit/components/uniffi-fixture-callbacks/src/callbacks.udl b/toolkit/components/uniffi-fixtures/callbacks/src/callbacks.udl index a6d44ef598..a6d44ef598 100644 --- a/toolkit/components/uniffi-fixture-callbacks/src/callbacks.udl +++ b/toolkit/components/uniffi-fixtures/callbacks/src/callbacks.udl diff --git a/toolkit/components/uniffi-fixture-callbacks/src/lib.rs b/toolkit/components/uniffi-fixtures/callbacks/src/lib.rs index 9ada66bca5..9ada66bca5 100644 --- a/toolkit/components/uniffi-fixture-callbacks/src/lib.rs +++ b/toolkit/components/uniffi-fixtures/callbacks/src/lib.rs diff --git a/toolkit/components/uniffi-example-custom-types/Cargo.toml b/toolkit/components/uniffi-fixtures/custom-types/Cargo.toml index a05324952e..a05324952e 100644 --- a/toolkit/components/uniffi-example-custom-types/Cargo.toml +++ b/toolkit/components/uniffi-fixtures/custom-types/Cargo.toml diff --git a/toolkit/components/uniffi-example-custom-types/build.rs b/toolkit/components/uniffi-fixtures/custom-types/build.rs index 10b6d220da..10b6d220da 100644 --- a/toolkit/components/uniffi-example-custom-types/build.rs +++ b/toolkit/components/uniffi-fixtures/custom-types/build.rs diff --git a/toolkit/components/uniffi-example-custom-types/src/custom-types.udl b/toolkit/components/uniffi-fixtures/custom-types/src/custom-types.udl index 8fef8ff41a..8fef8ff41a 100644 --- a/toolkit/components/uniffi-example-custom-types/src/custom-types.udl +++ b/toolkit/components/uniffi-fixtures/custom-types/src/custom-types.udl diff --git a/toolkit/components/uniffi-example-custom-types/src/lib.rs b/toolkit/components/uniffi-fixtures/custom-types/src/lib.rs index 61aea7a11a..61aea7a11a 100644 --- a/toolkit/components/uniffi-example-custom-types/src/lib.rs +++ b/toolkit/components/uniffi-fixtures/custom-types/src/lib.rs diff --git a/toolkit/components/uniffi-example-custom-types/tests/bindings/test_custom_types.kts b/toolkit/components/uniffi-fixtures/custom-types/tests/bindings/test_custom_types.kts index d75bd99eee..d75bd99eee 100644 --- a/toolkit/components/uniffi-example-custom-types/tests/bindings/test_custom_types.kts +++ b/toolkit/components/uniffi-fixtures/custom-types/tests/bindings/test_custom_types.kts diff --git a/toolkit/components/uniffi-example-custom-types/tests/bindings/test_custom_types.swift b/toolkit/components/uniffi-fixtures/custom-types/tests/bindings/test_custom_types.swift index 5aaf6ff3b0..5aaf6ff3b0 100644 --- a/toolkit/components/uniffi-example-custom-types/tests/bindings/test_custom_types.swift +++ b/toolkit/components/uniffi-fixtures/custom-types/tests/bindings/test_custom_types.swift diff --git a/toolkit/components/uniffi-example-custom-types/tests/test_generated_bindings.rs b/toolkit/components/uniffi-fixtures/custom-types/tests/test_generated_bindings.rs index 38db89790e..38db89790e 100644 --- a/toolkit/components/uniffi-example-custom-types/tests/test_generated_bindings.rs +++ b/toolkit/components/uniffi-fixtures/custom-types/tests/test_generated_bindings.rs diff --git a/toolkit/components/uniffi-example-custom-types/uniffi.toml b/toolkit/components/uniffi-fixtures/custom-types/uniffi.toml index 873fa090fb..873fa090fb 100644 --- a/toolkit/components/uniffi-example-custom-types/uniffi.toml +++ b/toolkit/components/uniffi-fixtures/custom-types/uniffi.toml diff --git a/toolkit/components/uniffi-fixtures/external-types/Cargo.toml b/toolkit/components/uniffi-fixtures/external-types/Cargo.toml new file mode 100644 index 0000000000..b70673374e --- /dev/null +++ b/toolkit/components/uniffi-fixtures/external-types/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "uniffi-fixture-external-types" +edition = "2021" +version = "0.21.0" +authors = ["Firefox Sync Team <sync-team@mozilla.com>"] +license = "MPL-2.0" +publish = false + +[dependencies] +uniffi-example-geometry = { path = "../geometry/" } +uniffi = { workspace = true } +thiserror = "1.0" + +[build-dependencies] +uniffi = { workspace = true, features = ["build"] } diff --git a/toolkit/components/uniffi-fixture-external-types/build.rs b/toolkit/components/uniffi-fixtures/external-types/build.rs index 13f56ca56b..13f56ca56b 100644 --- a/toolkit/components/uniffi-fixture-external-types/build.rs +++ b/toolkit/components/uniffi-fixtures/external-types/build.rs diff --git a/toolkit/components/uniffi-fixture-external-types/src/external-types.udl b/toolkit/components/uniffi-fixtures/external-types/src/external-types.udl index d50fc680f7..d50fc680f7 100644 --- a/toolkit/components/uniffi-fixture-external-types/src/external-types.udl +++ b/toolkit/components/uniffi-fixtures/external-types/src/external-types.udl diff --git a/toolkit/components/uniffi-fixture-external-types/src/lib.rs b/toolkit/components/uniffi-fixtures/external-types/src/lib.rs index 2d12332312..2d12332312 100644 --- a/toolkit/components/uniffi-fixture-external-types/src/lib.rs +++ b/toolkit/components/uniffi-fixtures/external-types/src/lib.rs diff --git a/toolkit/components/uniffi-fixtures/geometry/Cargo.toml b/toolkit/components/uniffi-fixtures/geometry/Cargo.toml new file mode 100644 index 0000000000..a35ce906aa --- /dev/null +++ b/toolkit/components/uniffi-fixtures/geometry/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "uniffi-example-geometry" +edition = "2021" +version = "0.22.0" +authors = ["Firefox Sync Team <sync-team@mozilla.com>"] +license = "MPL-2.0" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +name = "uniffi_geometry" + +[dependencies] +uniffi = { workspace = true } + +[build-dependencies] +uniffi = { workspace = true, features = ["build"] } + +[dev-dependencies] +uniffi = { workspace = true, features = ["bindgen-tests"] } diff --git a/third_party/rust/uniffi-example-geometry/build.rs b/toolkit/components/uniffi-fixtures/geometry/build.rs index 2dd1c96bc3..2dd1c96bc3 100644 --- a/third_party/rust/uniffi-example-geometry/build.rs +++ b/toolkit/components/uniffi-fixtures/geometry/build.rs diff --git a/third_party/rust/uniffi-example-geometry/src/geometry.udl b/toolkit/components/uniffi-fixtures/geometry/src/geometry.udl index af60d429bf..af60d429bf 100644 --- a/third_party/rust/uniffi-example-geometry/src/geometry.udl +++ b/toolkit/components/uniffi-fixtures/geometry/src/geometry.udl diff --git a/third_party/rust/uniffi-example-geometry/src/lib.rs b/toolkit/components/uniffi-fixtures/geometry/src/lib.rs index d710b150bb..d710b150bb 100644 --- a/third_party/rust/uniffi-example-geometry/src/lib.rs +++ b/toolkit/components/uniffi-fixtures/geometry/src/lib.rs diff --git a/third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.kts b/toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.kts index 77bb9932ec..77bb9932ec 100644 --- a/third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.kts +++ b/toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.kts diff --git a/third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.py b/toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.py index fd6772be24..bfb6560626 100644 --- a/third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.py +++ b/toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.py @@ -1,4 +1,4 @@ -from geometry import * +from geometry import Line, Point, gradient, intersection ln1 = Line(start=Point(coord_x=0, coord_y=0), end=Point(coord_x=1, coord_y=2)) ln2 = Line(start=Point(coord_x=1, coord_y=1), end=Point(coord_x=2, coord_y=2)) diff --git a/third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.rb b/toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.rb index 90fdff684e..90fdff684e 100644 --- a/third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.rb +++ b/toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.rb diff --git a/third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.swift b/toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.swift index 58bd65607f..58bd65607f 100644 --- a/third_party/rust/uniffi-example-geometry/tests/bindings/test_geometry.swift +++ b/toolkit/components/uniffi-fixtures/geometry/tests/bindings/test_geometry.swift diff --git a/third_party/rust/uniffi-example-geometry/tests/test_generated_bindings.rs b/toolkit/components/uniffi-fixtures/geometry/tests/test_generated_bindings.rs index 4638d847c8..4638d847c8 100644 --- a/third_party/rust/uniffi-example-geometry/tests/test_generated_bindings.rs +++ b/toolkit/components/uniffi-fixtures/geometry/tests/test_generated_bindings.rs diff --git a/toolkit/components/uniffi-fixture-refcounts/Cargo.toml b/toolkit/components/uniffi-fixtures/refcounts/Cargo.toml index 877e502711..877e502711 100644 --- a/toolkit/components/uniffi-fixture-refcounts/Cargo.toml +++ b/toolkit/components/uniffi-fixtures/refcounts/Cargo.toml diff --git a/toolkit/components/uniffi-fixture-refcounts/build.rs b/toolkit/components/uniffi-fixtures/refcounts/build.rs index 9ea03e12de..9ea03e12de 100644 --- a/toolkit/components/uniffi-fixture-refcounts/build.rs +++ b/toolkit/components/uniffi-fixtures/refcounts/build.rs diff --git a/toolkit/components/uniffi-fixtures/refcounts/src/lib.rs b/toolkit/components/uniffi-fixtures/refcounts/src/lib.rs new file mode 100644 index 0000000000..6554625c62 --- /dev/null +++ b/toolkit/components/uniffi-fixtures/refcounts/src/lib.rs @@ -0,0 +1,32 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/// This crate exists to test managing the Rust Arc strong counts as JS objects are +/// created/destroyed. See `test_refcounts.js` for how it's used. +use std::sync::{Arc, Mutex}; + +pub struct SingletonObject; + +impl SingletonObject { + pub fn method(&self) {} +} + +static SINGLETON: Mutex<Option<Arc<SingletonObject>>> = Mutex::new(None); + +pub fn get_singleton() -> Arc<SingletonObject> { + Arc::clone( + SINGLETON + .lock() + .unwrap() + .get_or_insert_with(|| Arc::new(SingletonObject)), + ) +} + +pub fn get_js_refcount() -> i32 { + // Subtract 2: one for the reference in the Mutex and one for the temporary reference that + // we're calling Arc::strong_count on. + (Arc::strong_count(&get_singleton()) as i32) - 2 +} + +include!(concat!(env!("OUT_DIR"), "/refcounts.uniffi.rs")); diff --git a/toolkit/components/uniffi-fixture-refcounts/src/refcounts.udl b/toolkit/components/uniffi-fixtures/refcounts/src/refcounts.udl index 25ec83cfcc..25ec83cfcc 100644 --- a/toolkit/components/uniffi-fixture-refcounts/src/refcounts.udl +++ b/toolkit/components/uniffi-fixtures/refcounts/src/refcounts.udl diff --git a/toolkit/components/uniffi-fixtures/rondpoint/Cargo.toml b/toolkit/components/uniffi-fixtures/rondpoint/Cargo.toml new file mode 100644 index 0000000000..1d0be84785 --- /dev/null +++ b/toolkit/components/uniffi-fixtures/rondpoint/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "uniffi-example-rondpoint" +edition = "2021" +version = "0.22.0" +authors = ["Firefox Sync Team <sync-team@mozilla.com>"] +license = "MPL-2.0" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +name = "uniffi_rondpoint" + +[dependencies] +uniffi = { workspace = true } + +[build-dependencies] +uniffi = { workspace = true, features = ["build"] } + +[dev-dependencies] +uniffi = { workspace = true, features = ["bindgen-tests"] } diff --git a/third_party/rust/uniffi-example-rondpoint/build.rs b/toolkit/components/uniffi-fixtures/rondpoint/build.rs index f830879d09..f830879d09 100644 --- a/third_party/rust/uniffi-example-rondpoint/build.rs +++ b/toolkit/components/uniffi-fixtures/rondpoint/build.rs diff --git a/third_party/rust/uniffi-example-rondpoint/src/lib.rs b/toolkit/components/uniffi-fixtures/rondpoint/src/lib.rs index 3f2233ddaa..3f2233ddaa 100644 --- a/third_party/rust/uniffi-example-rondpoint/src/lib.rs +++ b/toolkit/components/uniffi-fixtures/rondpoint/src/lib.rs diff --git a/third_party/rust/uniffi-example-rondpoint/src/rondpoint.udl b/toolkit/components/uniffi-fixtures/rondpoint/src/rondpoint.udl index 7c8261d74e..7c8261d74e 100644 --- a/third_party/rust/uniffi-example-rondpoint/src/rondpoint.udl +++ b/toolkit/components/uniffi-fixtures/rondpoint/src/rondpoint.udl diff --git a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.kts b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.kts index cc5ddf2a86..cc5ddf2a86 100644 --- a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.kts +++ b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.kts diff --git a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.py b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.py index 0b47c0fa5a..df3e3fab18 100644 --- a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.py +++ b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.py @@ -1,18 +1,37 @@ -import sys import ctypes -from rondpoint import * +import sys -dico = Dictionnaire(un=Enumeration.DEUX, deux=True, petit_nombre=0, gros_nombre=123456789) +from rondpoint import ( + Dictionnaire, + Enumeration, + EnumerationAvecDonnees, + Retourneur, + Stringifier, + copie_carte, + copie_dictionnaire, + copie_enumeration, + copie_enumerations, + switcheroo, +) + +dico = Dictionnaire( + un=Enumeration.DEUX, deux=True, petit_nombre=0, gros_nombre=123456789 +) copyDico = copie_dictionnaire(dico) assert dico == copyDico assert copie_enumeration(Enumeration.DEUX) == Enumeration.DEUX -assert copie_enumerations([Enumeration.UN, Enumeration.DEUX]) == [Enumeration.UN, Enumeration.DEUX] -assert copie_carte({ - "0": EnumerationAvecDonnees.ZERO(), - "1": EnumerationAvecDonnees.UN(1), - "2": EnumerationAvecDonnees.DEUX(2, "deux"), -}) == { +assert copie_enumerations([Enumeration.UN, Enumeration.DEUX]) == [ + Enumeration.UN, + Enumeration.DEUX, +] +assert copie_carte( + { + "0": EnumerationAvecDonnees.ZERO(), + "1": EnumerationAvecDonnees.UN(1), + "2": EnumerationAvecDonnees.DEUX(2, "deux"), + } +) == { "0": EnumerationAvecDonnees.ZERO(), "1": EnumerationAvecDonnees.UN(1), "2": EnumerationAvecDonnees.DEUX(2, "deux"), @@ -30,11 +49,13 @@ assert EnumerationAvecDonnees.UN(1) != EnumerationAvecDonnees.UN(2) # lowering from rust and lifting into python. rt = Retourneur() + def affirmAllerRetour(vals, identique): for v in vals: id_v = identique(v) assert id_v == v, f"Round-trip failure: {v} => {id_v}" + MIN_I8 = -1 * 2**7 MAX_I8 = 2**7 - 1 MIN_I16 = -1 * 2**15 @@ -65,21 +86,29 @@ affirmAllerRetour([0x00000000, 0x12345678, 0xFFFFFFFF], rt.identique_u32) # Longs affirmAllerRetour([MIN_I64, -1, 0, 1, MAX_I64], rt.identique_i64) -affirmAllerRetour([0x0000000000000000, 0x1234567890ABCDEF, 0xFFFFFFFFFFFFFFFF], rt.identique_u64) +affirmAllerRetour( + [0x0000000000000000, 0x1234567890ABCDEF, 0xFFFFFFFFFFFFFFFF], rt.identique_u64 +) # Floats affirmAllerRetour([0.0, 0.5, 0.25, 1.0, F32_ONE_THIRD], rt.identique_float) # Doubles affirmAllerRetour( - [0.0, 0.5, 0.25, 1.0, 1.0 / 3, sys.float_info.max, sys.float_info.min], - rt.identique_double + [0.0, 0.5, 0.25, 1.0, 1.0 / 3, sys.float_info.max, sys.float_info.min], + rt.identique_double, ) # Strings affirmAllerRetour( - ["", "abc", "été", "ښي لاس ته لوستلو لوستل", "😻emoji 👨👧👦multi-emoji, 🇨🇭a flag, a canal, panama"], - rt.identique_string + [ + "", + "abc", + "été", + "ښي لاس ته لوستلو لوستل", + "😻emoji 👨👧👦multi-emoji, 🇨🇭a flag, a canal, panama", + ], + rt.identique_string, ) # Test one way across the FFI. @@ -97,11 +126,13 @@ affirmAllerRetour( # together, we've shown the correctness of the return leg. st = Stringifier() + def affirmEnchaine(vals, toString, rustyStringify=lambda v: str(v).lower()): for v in vals: str_v = toString(v) assert rustyStringify(v) == str_v, f"String compare error {v} => {str_v}" + # Test the efficacy of the string transport from rust. If this fails, but everything else # works, then things are very weird. wellKnown = st.well_known_string("python") @@ -124,7 +155,10 @@ affirmEnchaine([0x00000000, 0x12345678, 0xFFFFFFFF], st.to_string_u32) # Longs affirmEnchaine([MIN_I64, -1, 0, 1, MAX_I64], st.to_string_i64) -affirmEnchaine([0x0000000000000000, 0x1234567890ABCDEF, 0xFFFFFFFFFFFFFFFF], st.to_string_u64) +affirmEnchaine( + [0x0000000000000000, 0x1234567890ABCDEF, 0xFFFFFFFFFFFFFFFF], st.to_string_u64 +) + # Floats def rustyFloatToStr(v): @@ -134,13 +168,16 @@ def rustyFloatToStr(v): return str(int(v)) return str(v) + affirmEnchaine([0.0, 0.5, 0.25, 1.0], st.to_string_float, rustyFloatToStr) -assert st.to_string_float(F32_ONE_THIRD) == "0.33333334" # annoyingly different string repr +assert ( + st.to_string_float(F32_ONE_THIRD) == "0.33333334" +) # annoyingly different string repr # Doubles # TODO: float_info.max/float_info.min don't stringify-roundtrip properly yet, TBD. affirmEnchaine( - [0.0, 0.5, 0.25, 1.0, 1.0 / 3], - st.to_string_double, - rustyFloatToStr, + [0.0, 0.5, 0.25, 1.0, 1.0 / 3], + st.to_string_double, + rustyFloatToStr, ) diff --git a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.rb b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.rb index faa4062019..faa4062019 100644 --- a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.rb +++ b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.rb diff --git a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.swift b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.swift index d9f47058ed..d9f47058ed 100644 --- a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.swift +++ b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.swift diff --git a/third_party/rust/uniffi-example-rondpoint/tests/test_generated_bindings.rs b/toolkit/components/uniffi-fixtures/rondpoint/tests/test_generated_bindings.rs index d337374334..d337374334 100644 --- a/third_party/rust/uniffi-example-rondpoint/tests/test_generated_bindings.rs +++ b/toolkit/components/uniffi-fixtures/rondpoint/tests/test_generated_bindings.rs diff --git a/toolkit/components/uniffi-fixtures/sprites/Cargo.toml b/toolkit/components/uniffi-fixtures/sprites/Cargo.toml new file mode 100644 index 0000000000..3b4f96e143 --- /dev/null +++ b/toolkit/components/uniffi-fixtures/sprites/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "uniffi-example-sprites" +edition = "2021" +version = "0.22.0" +authors = ["Firefox Sync Team <sync-team@mozilla.com>"] +license = "MPL-2.0" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +name = "uniffi_sprites" + +[dependencies] +uniffi = { workspace = true } + +[build-dependencies] +uniffi = { workspace = true, features = ["build"] } + +[dev-dependencies] +uniffi = { workspace = true, features = ["bindgen-tests"] } diff --git a/third_party/rust/uniffi-example-sprites/build.rs b/toolkit/components/uniffi-fixtures/sprites/build.rs index 26ac3085b8..26ac3085b8 100644 --- a/third_party/rust/uniffi-example-sprites/build.rs +++ b/toolkit/components/uniffi-fixtures/sprites/build.rs diff --git a/third_party/rust/uniffi-example-sprites/src/lib.rs b/toolkit/components/uniffi-fixtures/sprites/src/lib.rs index d3cc11e408..d3cc11e408 100644 --- a/third_party/rust/uniffi-example-sprites/src/lib.rs +++ b/toolkit/components/uniffi-fixtures/sprites/src/lib.rs diff --git a/third_party/rust/uniffi-example-sprites/src/sprites.udl b/toolkit/components/uniffi-fixtures/sprites/src/sprites.udl index 6781c6cee5..6781c6cee5 100644 --- a/third_party/rust/uniffi-example-sprites/src/sprites.udl +++ b/toolkit/components/uniffi-fixtures/sprites/src/sprites.udl diff --git a/third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.kts b/toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.kts index 42451f28dd..42451f28dd 100644 --- a/third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.kts +++ b/toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.kts diff --git a/third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.py b/toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.py index d04742e076..1e91997001 100644 --- a/third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.py +++ b/toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.py @@ -1,4 +1,4 @@ -from sprites import * +from sprites import Point, Sprite, Vector sempty = Sprite(None) assert sempty.get_position() == Point(x=0, y=0) @@ -14,4 +14,3 @@ assert s.get_position() == Point(x=-3, y=4) srel = Sprite.new_relative_to(Point(x=0, y=1), Vector(dx=1, dy=1.5)) assert srel.get_position() == Point(x=1, y=2.5) - diff --git a/third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.rb b/toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.rb index fa73043979..fa73043979 100644 --- a/third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.rb +++ b/toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.rb diff --git a/third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.swift b/toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.swift index d5428ac679..d5428ac679 100644 --- a/third_party/rust/uniffi-example-sprites/tests/bindings/test_sprites.swift +++ b/toolkit/components/uniffi-fixtures/sprites/tests/bindings/test_sprites.swift diff --git a/third_party/rust/uniffi-example-sprites/tests/test_generated_bindings.rs b/toolkit/components/uniffi-fixtures/sprites/tests/test_generated_bindings.rs index 00dd779d68..00dd779d68 100644 --- a/third_party/rust/uniffi-example-sprites/tests/test_generated_bindings.rs +++ b/toolkit/components/uniffi-fixtures/sprites/tests/test_generated_bindings.rs diff --git a/toolkit/components/uniffi-fixtures/todolist/Cargo.toml b/toolkit/components/uniffi-fixtures/todolist/Cargo.toml new file mode 100644 index 0000000000..6673d01e07 --- /dev/null +++ b/toolkit/components/uniffi-fixtures/todolist/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "uniffi-example-todolist" +edition = "2021" +version = "0.22.0" +authors = ["Firefox Sync Team <sync-team@mozilla.com>"] +license = "MPL-2.0" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +name = "uniffi_todolist" + +[dependencies] +uniffi = { workspace = true } +once_cell = "1.12" +thiserror = "1.0" + +[build-dependencies] +uniffi = { workspace = true, features = ["build"] } + +[dev-dependencies] +uniffi = { workspace = true, features = ["bindgen-tests"] } diff --git a/third_party/rust/uniffi-example-todolist/build.rs b/toolkit/components/uniffi-fixtures/todolist/build.rs index 2dd2f68b75..2dd2f68b75 100644 --- a/third_party/rust/uniffi-example-todolist/build.rs +++ b/toolkit/components/uniffi-fixtures/todolist/build.rs diff --git a/third_party/rust/uniffi-example-todolist/src/lib.rs b/toolkit/components/uniffi-fixtures/todolist/src/lib.rs index 11cdc63aee..11cdc63aee 100644 --- a/third_party/rust/uniffi-example-todolist/src/lib.rs +++ b/toolkit/components/uniffi-fixtures/todolist/src/lib.rs diff --git a/third_party/rust/uniffi-example-todolist/src/todolist.udl b/toolkit/components/uniffi-fixtures/todolist/src/todolist.udl index 5c923314cd..5c923314cd 100644 --- a/third_party/rust/uniffi-example-todolist/src/todolist.udl +++ b/toolkit/components/uniffi-fixtures/todolist/src/todolist.udl diff --git a/third_party/rust/uniffi-example-todolist/tests/bindings/test_todolist.kts b/toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.kts index bb2b292224..bb2b292224 100644 --- a/third_party/rust/uniffi-example-todolist/tests/bindings/test_todolist.kts +++ b/toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.kts diff --git a/toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.py b/toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.py new file mode 100644 index 0000000000..e4e2cda6d6 --- /dev/null +++ b/toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.py @@ -0,0 +1,56 @@ +from todolist import TodoEntry, TodoList, get_default_list, set_default_list + +todo = TodoList() + +entry = TodoEntry(text="Write bindings for strings in records") + +todo.add_item("Write python bindings") + +assert todo.get_last() == "Write python bindings" + +todo.add_item("Write tests for bindings") + +assert todo.get_last() == "Write tests for bindings" + +todo.add_entry(entry) + +assert todo.get_last() == "Write bindings for strings in records" +assert todo.get_last_entry().text == "Write bindings for strings in records" + +todo.add_item( + "Test Ünicode hàndling without an entry can't believe I didn't test this at first 🤣" +) +assert ( + todo.get_last() + == "Test Ünicode hàndling without an entry can't believe I didn't test this at first 🤣" +) + +entry2 = TodoEntry( + text="Test Ünicode hàndling in an entry can't believe I didn't test this at first 🤣" +) +todo.add_entry(entry2) +assert ( + todo.get_last_entry().text + == "Test Ünicode hàndling in an entry can't believe I didn't test this at first 🤣" +) + +todo2 = TodoList() +assert todo != todo2 +assert todo is not todo2 + +assert get_default_list() is None + +set_default_list(todo) +assert todo.get_items() == get_default_list().get_items() + +todo2.make_default() +assert todo2.get_items() == get_default_list().get_items() + +todo.add_item("Test liveness after being demoted from default") +assert todo.get_last() == "Test liveness after being demoted from default" + +todo2.add_item("Test shared state through local vs default reference") +assert ( + get_default_list().get_last() + == "Test shared state through local vs default reference" +) diff --git a/third_party/rust/uniffi-example-todolist/tests/bindings/test_todolist.rb b/toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.rb index fc1a823f52..fc1a823f52 100644 --- a/third_party/rust/uniffi-example-todolist/tests/bindings/test_todolist.rb +++ b/toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.rb diff --git a/third_party/rust/uniffi-example-todolist/tests/bindings/test_todolist.swift b/toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.swift index 6ce72cadb2..6ce72cadb2 100644 --- a/third_party/rust/uniffi-example-todolist/tests/bindings/test_todolist.swift +++ b/toolkit/components/uniffi-fixtures/todolist/tests/bindings/test_todolist.swift diff --git a/third_party/rust/uniffi-example-todolist/tests/test_generated_bindings.rs b/toolkit/components/uniffi-fixtures/todolist/tests/test_generated_bindings.rs index cefdbfe1dc..cefdbfe1dc 100644 --- a/third_party/rust/uniffi-example-todolist/tests/test_generated_bindings.rs +++ b/toolkit/components/uniffi-fixtures/todolist/tests/test_generated_bindings.rs |