2018-07-20 21:47:49 +03:00
|
|
|
use wasm_bindgen::JsValue;
|
|
|
|
use wasm_bindgen_test::*;
|
|
|
|
use js_sys::*;
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn new() {
|
|
|
|
let x = ArrayBuffer::new(42);
|
|
|
|
let y: JsValue = x.into();
|
|
|
|
assert!(y.is_object());
|
|
|
|
}
|
|
|
|
|
2018-08-06 18:27:47 +03:00
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn byte_length() {
|
|
|
|
let buf = ArrayBuffer::new(42);
|
|
|
|
assert_eq!(buf.byte_length(), 42);
|
|
|
|
}
|
|
|
|
|
2018-07-20 21:47:49 +03:00
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn is_view() {
|
2018-07-26 00:33:44 +03:00
|
|
|
let x = Uint8Array::new(&JsValue::from(42));
|
|
|
|
assert!(ArrayBuffer::is_view(&JsValue::from(x)));
|
2018-07-20 21:47:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn slice() {
|
|
|
|
let buf = ArrayBuffer::new(4);
|
|
|
|
let slice = buf.slice(2);
|
|
|
|
assert!(JsValue::from(slice).is_object());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn slice_with_end() {
|
|
|
|
let buf = ArrayBuffer::new(4);
|
|
|
|
let slice = buf.slice_with_end(1, 2);
|
|
|
|
assert!(JsValue::from(slice).is_object());
|
|
|
|
}
|