From 46766ed9255f1696c827ff280cf1cd525745da3d Mon Sep 17 00:00:00 2001 From: data-pup <16364986+data-pup@users.noreply.github.com> Date: Tue, 26 Nov 2019 10:59:24 -0500 Subject: [PATCH] add failing test for #636 --- tests/foo.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/foo.rs diff --git a/tests/foo.rs b/tests/foo.rs new file mode 100644 index 0000000000..a1c6d2cb0f --- /dev/null +++ b/tests/foo.rs @@ -0,0 +1,28 @@ +use cranelift_codegen::settings; +use wasmtime_jit::{CompilationStrategy, Compiler, NullResolver}; + +#[test] +fn instantiate_empty_module() { + // `(module)` + let wasm = vec![0x0, 0x61, 0x73, 0x6d, 0x01, 0x0, 0x0, 0x0]; + let compilation_strategy = CompilationStrategy::Cranelift; + + let isa = { + let flag_builder = settings::builder(); + let isa_builder = + cranelift_native::builder().expect("host machine is not a supported target"); + isa_builder.finish(settings::Flags::new(flag_builder)) + }; + + let mut compiler = Compiler::new(isa, compilation_strategy); + let mut imports_resolver = NullResolver {}; + + wasmtime_jit::instantiate( + &mut compiler, + &wasm, + &mut imports_resolver, + Default::default(), + true, + ) + .expect("failed to instantiate valid Wasm!"); +}