Add a check if NotStartedModuleRef has a start function (#173)

* Add a check if NotStartedModuleRef has a start function

* Removed redundant doc comment

Co-Authored-By: elichai <elichai.turkel@gmail.com>
This commit is contained in:
Elichai Turkel 2019-02-28 18:19:04 +02:00 committed by Sergei Pepyakin
parent 188ad62955
commit 8403cc3411
1 changed files with 10 additions and 3 deletions

View File

@ -714,6 +714,13 @@ 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 +800,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]