From 10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:41:41 +0200 Subject: Merging upstream version 1.70.0+dfsg2. Signed-off-by: Daniel Baumann --- vendor/js-sys/tests/wasm/BigInt.rs | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 vendor/js-sys/tests/wasm/BigInt.rs (limited to 'vendor/js-sys/tests/wasm/BigInt.rs') diff --git a/vendor/js-sys/tests/wasm/BigInt.rs b/vendor/js-sys/tests/wasm/BigInt.rs new file mode 100644 index 000000000..a9cd30dfb --- /dev/null +++ b/vendor/js-sys/tests/wasm/BigInt.rs @@ -0,0 +1,43 @@ +use js_sys::BigInt; +use wasm_bindgen::prelude::*; +use wasm_bindgen_test::wasm_bindgen_test; + +/// `assert_eq!`, but the arguments are converted to `JsValue`s. +#[track_caller] +fn assert_jsvalue_eq(a: impl Into, b: impl Into) { + assert_eq!(a.into(), b.into()); +} + +#[wasm_bindgen_test] +fn from() { + // Test that all the `From` impls work properly. + assert_jsvalue_eq(BigInt::from(1u8), 1u64); + assert_jsvalue_eq(BigInt::from(1u16), 1u64); + assert_jsvalue_eq(BigInt::from(1u32), 1u64); + assert_jsvalue_eq(BigInt::from(1u64), 1u64); + assert_jsvalue_eq(BigInt::from(1u128), 1u64); + assert_jsvalue_eq(BigInt::from(1usize), 1u64); + assert_jsvalue_eq(BigInt::from(-3i8), -3i64); + assert_jsvalue_eq(BigInt::from(-3i16), -3i64); + assert_jsvalue_eq(BigInt::from(-3i32), -3i64); + assert_jsvalue_eq(BigInt::from(-3i64), -3i64); + assert_jsvalue_eq(BigInt::from(-3i128), -3i64); + assert_jsvalue_eq(BigInt::from(-3isize), -3i64); +} + +#[wasm_bindgen_test] +fn eq() { + // Test that all the `Eq` impls work properly. + assert_eq!(BigInt::from(1u64), 1u8); + assert_eq!(BigInt::from(1u64), 1u16); + assert_eq!(BigInt::from(1u64), 1u32); + assert_eq!(BigInt::from(1u64), 1u64); + assert_eq!(BigInt::from(1u64), 1u128); + assert_eq!(BigInt::from(1u64), 1usize); + assert_eq!(BigInt::from(-3i64), -3i8); + assert_eq!(BigInt::from(-3i64), -3i16); + assert_eq!(BigInt::from(-3i64), -3i32); + assert_eq!(BigInt::from(-3i64), -3i64); + assert_eq!(BigInt::from(-3i64), -3i128); + assert_eq!(BigInt::from(-3i64), -3isize); +} -- cgit v1.2.3