Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix printing float results from the CLI #2797

Merged
merged 1 commit into from
Apr 2, 2021
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
6 changes: 3 additions & 3 deletions src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ impl RunCommand {
match result {
Val::I32(i) => println!("{}", i),
Val::I64(i) => println!("{}", i),
Val::F32(f) => println!("{}", f),
Val::F64(f) => println!("{}", f),
Val::F32(f) => println!("{}", f32::from_bits(f)),
Val::F64(f) => println!("{}", f64::from_bits(f)),
Val::ExternRef(_) => println!("<externref>"),
Val::FuncRef(_) => println!("<externref>"),
Val::FuncRef(_) => println!("<funcref>"),
Val::V128(i) => println!("{}", i),
}
}
Expand Down
20 changes: 20 additions & 0 deletions tests/all/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ fn run_wasmtime_simple_wat() -> Result<()> {
"--disable-cache",
"4",
])?;
assert_eq!(
run_wasmtime(&[
"run",
wasm.path().to_str().unwrap(),
"--invoke",
"get_f32",
"--disable-cache",
])?,
"100\n"
);
assert_eq!(
run_wasmtime(&[
"run",
wasm.path().to_str().unwrap(),
"--invoke",
"get_f64",
"--disable-cache",
])?,
"100\n"
);
Ok(())
}

Expand Down
4 changes: 3 additions & 1 deletion tests/wasm/simple.wat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
(func (export "simple") (param i32) (result i32)
local.get 0
)
)
(func (export "get_f32") (result f32) f32.const 100)
(func (export "get_f64") (result f64) f64.const 100)
)