From 8416cf247764680cbe2bda1cca69a1310c7afa4f Mon Sep 17 00:00:00 2001 From: Redfire Date: Sat, 2 Dec 2023 14:09:26 +0800 Subject: [PATCH] Added Test for BigInt64Array --- mozjs/tests/typedarray.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mozjs/tests/typedarray.rs b/mozjs/tests/typedarray.rs index f9d99f2b7e7..d4fb6c4dbc3 100644 --- a/mozjs/tests/typedarray.rs +++ b/mozjs/tests/typedarray.rs @@ -9,7 +9,7 @@ use mozjs::jsval::UndefinedValue; use mozjs::rooted; use mozjs::rust::{JSEngine, RealmOptions, Runtime, SIMPLE_GLOBAL_CLASS}; use mozjs::typedarray; -use mozjs::typedarray::{CreateWith, Float32Array, Uint32Array}; +use mozjs::typedarray::{BigInt64Array, CreateWith, Float32Array, Uint32Array}; #[test] fn typedarray() { @@ -97,5 +97,15 @@ fn typedarray() { typedarray!(in(context) let mut array: Float32Array = rval.get()); array.as_mut().unwrap().update(&[0.5, 1.0, 2.0]); assert_eq!(array.unwrap().as_slice(), &[0.5, 1.0, 2.0, 2.0, 4.0]); + + rooted!(in(context) let mut rval = ptr::null_mut::()); + assert!(BigInt64Array::create(context, CreateWith::Slice(&[-6, -1, 0, 2, 5]), rval.handle_mut()).is_ok()); + + typedarray!(in(context) let array: BigInt64Array = rval.get()); + assert_eq!(array.unwrap().as_slice(), &[-6, -1, 0, 2, 5]); + + typedarray!(in(context) let mut array: BigInt64Array = rval.get()); + array.as_mut().unwrap().update(&[-12, -2, -1]); + assert_eq!(array.unwrap().as_slice(), &[-12, -2, -1, 2, 5]); } }