mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-15 22:11:23 +00:00
.cargo
crates
backend
cli
cli-support
futures
js-sys
src
tests
wasm
Array.rs
ArrayBuffer.rs
ArrayIterator.rs
Boolean.rs
DataView.rs
Date.rs
Error.rs
EvalError.rs
Function.js
Function.rs
Generator.js
Generator.rs
Intl.rs
JSON.rs
JsString.js
JsString.rs
Map.rs
MapIterator.rs
Math.rs
Number.rs
Object.js
Object.rs
Promise.rs
Proxy.js
Proxy.rs
RangeError.rs
ReferenceError.rs
Reflect.js
Reflect.rs
RegExp.rs
Set.rs
SetIterator.rs
Symbol.js
Symbol.rs
SyntaxError.rs
TypeError.rs
TypedArray.rs
UriError.rs
WeakMap.rs
WeakSet.rs
WebAssembly.js
WebAssembly.rs
global_fns.rs
main.rs
headless.js
headless.rs
CHANGELOG.md
Cargo.toml
README.md
macro
macro-support
shared
test
test-macro
typescript
wasm-interpreter
web-sys
webidl
webidl-tests
examples
guide
releases
src
tests
.appveyor.yml
.eslintignore
.eslintrc
.gitattributes
.gitignore
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
Cargo.toml
LICENSE-APACHE
LICENSE-MIT
README.md
build.rs
package.json
publish.rs
46 lines
995 B
Rust
46 lines
995 B
Rust
use wasm_bindgen::JsValue;
|
|
use wasm_bindgen_test::*;
|
|
use wasm_bindgen::JsCast;
|
|
use js_sys::*;
|
|
|
|
#[wasm_bindgen_test]
|
|
fn new() {
|
|
let x = ArrayBuffer::new(42);
|
|
let y: JsValue = x.into();
|
|
assert!(y.is_object());
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
fn byte_length() {
|
|
let buf = ArrayBuffer::new(42);
|
|
assert_eq!(buf.byte_length(), 42);
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
fn is_view() {
|
|
let x = Uint8Array::new(&JsValue::from(42));
|
|
assert!(ArrayBuffer::is_view(&JsValue::from(x)));
|
|
}
|
|
|
|
#[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());
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
fn arraybuffer_inheritance() {
|
|
let buf = ArrayBuffer::new(4);
|
|
assert!(buf.is_instance_of::<ArrayBuffer>());
|
|
assert!(buf.is_instance_of::<Object>());
|
|
let _: &Object = buf.as_ref();
|
|
}
|