mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 13:18:20 +00:00
Make FuncRef nullable at the API level
This commit is contained in:
@@ -67,7 +67,7 @@ fn table_new() -> Result<()> {
|
||||
maximum: None,
|
||||
};
|
||||
let f = Function::new_native(&store, || {});
|
||||
let table = Table::new(&store, table_type, Value::FuncRef(f))?;
|
||||
let table = Table::new(&store, table_type, Value::FuncRef(Some(f)))?;
|
||||
assert_eq!(*table.ty(), table_type);
|
||||
|
||||
// Anyrefs not yet supported
|
||||
@@ -92,7 +92,7 @@ fn table_get() -> Result<()> {
|
||||
maximum: Some(1),
|
||||
};
|
||||
let f = Function::new_native(&store, |num: i32| num + 1);
|
||||
let table = Table::new(&store, table_type, Value::FuncRef(f.clone()))?;
|
||||
let table = Table::new(&store, table_type, Value::FuncRef(Some(f.clone())))?;
|
||||
assert_eq!(*table.ty(), table_type);
|
||||
let _elem = table.get(0).unwrap();
|
||||
// assert_eq!(elem.funcref().unwrap(), f);
|
||||
@@ -115,13 +115,13 @@ fn table_grow() -> Result<()> {
|
||||
maximum: Some(10),
|
||||
};
|
||||
let f = Function::new_native(&store, |num: i32| num + 1);
|
||||
let table = Table::new(&store, table_type, Value::FuncRef(f.clone()))?;
|
||||
let table = Table::new(&store, table_type, Value::FuncRef(Some(f.clone())))?;
|
||||
// Growing to a bigger maximum should return None
|
||||
let old_len = table.grow(12, Value::FuncRef(f.clone()));
|
||||
let old_len = table.grow(12, Value::FuncRef(Some(f.clone())));
|
||||
assert!(old_len.is_err());
|
||||
|
||||
// Growing to a bigger maximum should return None
|
||||
let old_len = table.grow(5, Value::FuncRef(f.clone()))?;
|
||||
let old_len = table.grow(5, Value::FuncRef(Some(f.clone())))?;
|
||||
assert_eq!(old_len, 0);
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user