Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const DEFAULT_INHERIT_ENV: bool = false;
const DEFAULT_KEEP_INIT_FUNC: bool = false;
const DEFAULT_WASM_MULTI_VALUE: bool = true;
const DEFAULT_WASM_MULTI_MEMORY: bool = true;
const DEFAULT_WASM_BULK_MEMORY: bool = false;
const DEFAULT_WASM_BULK_MEMORY: bool = true;
const DEFAULT_WASM_SIMD: bool = true;
const DEFAULT_WASM_REFERENCE_TYPES: bool = false;
const DEFAULT_WASM_REFERENCE_TYPES: bool = true;

/// The type of data that is stored in the `wasmtime::Store` during
/// initialization.
Expand Down Expand Up @@ -241,7 +241,7 @@ pub struct Wizer {
/// are currently supported. Modules which use other instructions, such as
/// `table.copy` will be rejected.
///
/// Disabled by default.
/// Enabled by default.
#[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))]
wasm_bulk_memory: Option<bool>,

Expand All @@ -257,7 +257,7 @@ pub struct Wizer {
/// but enables initializing Wasm modules that use encodings introduced
/// in the reference-types proposal.
///
/// Disabled by default.
/// Enabled by default.
#[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))]
wasm_reference_types: Option<bool>,
}
Expand Down Expand Up @@ -556,7 +556,7 @@ impl Wizer {
/// operations are currently supported. Modules which use other
/// instructions, such as `table.copy` will be rejected.
///
/// Defaults to `false`.
/// Defaults to `true`.
pub fn wasm_bulk_memory(&mut self, enable: bool) -> &mut Self {
self.wasm_bulk_memory = Some(enable);
self
Expand All @@ -576,7 +576,7 @@ impl Wizer {
/// but enables initializing Wasm modules that use encodings introduced
/// in the reference-types proposal.
///
/// Defaults to `false`.
/// Defaults to `true`.
pub fn wasm_reference_types(&mut self, enable: bool) -> &mut Self {
self.wasm_reference_types = Some(enable);
self
Expand Down
32 changes: 16 additions & 16 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,7 @@ fn reject_table_copy() -> Result<()> {

#[test]
fn reject_table_get_set() -> Result<()> {
let result = run_wat(
&[],
42,
r#"
let wat = r#"
(module
(table 3 funcref)

Expand All @@ -257,8 +254,15 @@ fn reject_table_get_set() -> Result<()> {

(elem (i32.const 0) $f $g $h)
)
"#,
);
"#;

let _ = env_logger::try_init();
let mut wizer = Wizer::new();
wizer.wasm_reference_types(false);

let wasm = wat_to_wasm(wat)?;
let result = wizen_and_run_wasm(&[], 42, &wasm, wizer);

assert!(result.is_err());

let err = result.unwrap_err();
Expand All @@ -271,7 +275,10 @@ fn reject_table_get_set() -> Result<()> {

#[test]
fn reject_table_get_set_with_reference_types_enabled() -> Result<()> {
let wat = r#"
let result = run_wat(
&[],
42,
r#"
(module
(table 3 funcref)

Expand All @@ -286,15 +293,8 @@ fn reject_table_get_set_with_reference_types_enabled() -> Result<()> {
table.set)

(elem (i32.const 0) $f $g $h)
)"#;

let _ = env_logger::try_init();
let mut wizer = Wizer::new();
wizer.wasm_reference_types(true);

let wasm = wat_to_wasm(wat)?;
let result = wizen_and_run_wasm(&[], 42, &wasm, wizer);

)"#,
);
assert!(result.is_err());

let err = result.unwrap_err();
Expand Down
Loading