From c0acd5be11547be4aa128db16e1cdce943ab488b Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 17 Oct 2019 12:20:34 -0700 Subject: [PATCH] Show the full hex value of a float that fails assert returns arithmetic nan or assert returns canonical nan. --- lib/spectests/tests/spectest.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/spectests/tests/spectest.rs b/lib/spectests/tests/spectest.rs index 62bfc7d53..587d576f8 100644 --- a/lib/spectests/tests/spectest.rs +++ b/lib/spectests/tests/spectest.rs @@ -445,8 +445,9 @@ mod tests { "AssertReturnCanonicalNan" ), message: format!( - "value is not canonical nan {:?}", - v + "value is not canonical nan {:?} ({:?})", + v, + value_to_hex(v.clone()), ), }, &test_key, @@ -512,8 +513,9 @@ mod tests { "AssertReturnArithmeticNan" ), message: format!( - "value is not arithmetic nan {:?}", - v + "value is not arithmetic nan {:?} ({:?})", + v, + value_to_hex(v.clone()), ), }, &test_key, @@ -945,6 +947,16 @@ mod tests { } } + fn value_to_hex(val: wasmer_runtime_core::types::Value) -> String { + match val { + wasmer_runtime_core::types::Value::I32(x) => format!("{:#x}", x), + wasmer_runtime_core::types::Value::I64(x) => format!("{:#x}", x), + wasmer_runtime_core::types::Value::F32(x) => format!("{:#x}", x.to_bits()), + wasmer_runtime_core::types::Value::F64(x) => format!("{:#x}", x.to_bits()), + wasmer_runtime_core::types::Value::V128(x) => format!("{:#x}", x), + } + } + #[derive(Debug, Clone, Eq, PartialEq)] pub enum SpectestValue { I32(i32),