mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-18 19:20:51 +00:00
parent
fb5e6e9c06
commit
2d4f36c9da
@ -3061,6 +3061,13 @@ pub mod WebAssembly {
|
||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length)
|
||||
#[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
|
||||
pub fn length(this: &Table) -> u32;
|
||||
|
||||
/// The `get()` prototype method of the `WebAssembly.Table()` object
|
||||
/// retrieves a function reference stored at a given index.
|
||||
///
|
||||
/// [MDN documentation](
|
||||
#[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
|
||||
pub fn get(this: &Table, index: u32) -> Result<Function, JsValue>;
|
||||
}
|
||||
|
||||
// WebAssembly.Memory
|
||||
|
@ -127,6 +127,9 @@ fn table_error() {
|
||||
fn table() {
|
||||
let table = WebAssembly::Table::new(&get_table_object().into()).unwrap();
|
||||
assert_eq!(table.length(), 1);
|
||||
|
||||
assert!(table.get(0).is_ok());
|
||||
assert!(table.get(999).is_err());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user