Skip to content

Commit 8786f76

Browse files
committed
Added Test for BigInt64Array
1 parent 0f2c1ff commit 8786f76

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

mozjs/tests/typedarray.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use mozjs::jsval::UndefinedValue;
99
use mozjs::rooted;
1010
use mozjs::rust::{JSEngine, RealmOptions, Runtime, SIMPLE_GLOBAL_CLASS};
1111
use mozjs::typedarray;
12-
use mozjs::typedarray::{CreateWith, Float32Array, Uint32Array};
12+
use mozjs::typedarray::{BigInt64Array, CreateWith, Float32Array, Uint32Array};
1313

1414
#[test]
1515
fn typedarray() {
@@ -97,5 +97,15 @@ fn typedarray() {
9797
typedarray!(in(context) let mut array: Float32Array = rval.get());
9898
array.as_mut().unwrap().update(&[0.5, 1.0, 2.0]);
9999
assert_eq!(array.unwrap().as_slice(), &[0.5, 1.0, 2.0, 2.0, 4.0]);
100+
101+
rooted!(in(context) let mut rval = ptr::null_mut::<JSObject>());
102+
assert!(BigInt64Array::create(context, CreateWith::Slice(&[-6, -1, 0, 2, 5]), rval.handle_mut()).is_ok());
103+
104+
typedarray!(in(context) let array: BigInt64Array = rval.get());
105+
assert_eq!(array.unwrap().as_slice(), &[-6, -1, 0, 2, 5]);
106+
107+
typedarray!(in(context) let mut array: BigInt64Array = rval.get());
108+
array.as_mut().unwrap().update(&[-12, -2, -1]);
109+
assert_eq!(array.unwrap().as_slice(), &[-12, -2, -1, 2, 5]);
100110
}
101111
}

0 commit comments

Comments
 (0)