Sha256: 55a8070545f477acea07aebccad1bfd36bac88202923c357f894d6721046f53e

Contents?: true

Size: 1.54 KB

Versions: 11

Compression:

Stored size: 1.54 KB

Contents

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<JsValue>, b: impl Into<JsValue>) {
    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);
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wasmtime-23.0.2 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs
wasmtime-22.0.0 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs
wasmtime-21.0.1 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs
wasmtime-20.0.2 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs
wasmtime-20.0.0 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs
wasmtime-18.0.3 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs
wasmtime-17.0.1 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs
wasmtime-17.0.0 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs
wasmtime-16.0.0 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs
wasmtime-15.0.1 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs
wasmtime-15.0.0 ./ext/cargo-vendor/js-sys-0.3.66/tests/wasm/BigInt.rs