Add a check if NotStartedModuleRef has a start function

This commit is contained in:
Elichai Turkel 2019-02-27 20:25:39 +02:00
parent 188ad62955
commit 8bcabae7be
No known key found for this signature in database
GPG Key ID: 5607C93B5F86650C
1 changed files with 11 additions and 3 deletions

View File

@ -714,6 +714,14 @@ impl<'a> NotStartedModuleRef<'a> {
}
self.instance
}
/// Whether or not the module has a `start` function.
///
///
/// Returns `true` if it has a `start` function.
pub fn has_start(&self) -> bool {
self.loaded_module.module().start_section().is_some()
}
}
fn eval_init_expr(init_expr: &InitExpr, module: &ModuleInstance) -> RuntimeValue {
@ -793,9 +801,9 @@ mod tests {
(start $f))
"#,
);
ModuleInstance::new(&module_with_start, &ImportsBuilder::default())
.unwrap()
.assert_no_start();
let module = ModuleInstance::new(&module_with_start, &ImportsBuilder::default()).unwrap();
assert!(!module.has_start());
module.assert_no_start();
}
#[test]