Comments (9)
I'd suggest simply changing the implementation of assert_eq
to use the stricter equality operator. Or is there any reason to ever use IEEE equality in the tests we want to write?
As for NaN tests, it is easy to express that in WASM itself, so I don't think we need to extend the assertion language just for that either.
from spec.
Btw, once your new float implementations land, =
and <>
on those types will automatically mean bitwise equality. So maybe it isn't even necessary to change anything here.
from spec.
You're right; there is no need for the looser equality in our tests. It just feels weird to me to give eq
a subtly different meaning in this context than it has in wasm itself.
As for NaN tests, it seems like it will be quite inconvenient to express any-NaN tests in terms of assert_eq regardless of whether it's the strict or loose version. The strict one tests for a specific bit pattern when we want to accept many, and the loose version requires we name the value so that we can reference it twice and form x <> x
. Or are you proposing we add NaN test functions inside the wasm modules themselves?
from spec.
BTW, you're right that = and <> now automatically do bitwise equality with my float implementations. How does that work, given that the types are abstract?
from spec.
Ah, I found a blog post which explains it.
from spec.
Agreed with what I think @rossberg-chromium is saying on NaNs: this should be done with a wasm function, e.g.: assert(is_nan(v))
.
from spec.
BTW, you're right that = and <> now automatically do bitwise equality with
my float implementations. How does that work, given that the types are
abstract?
In Ocaml, equality is generic, and does the "right" thing depending on the
runtime type of the value.
That actually is quite a dubious semantics, given that IEEE defines a
completely broken notion of equality for floats (which is not even close to
being an equivalence relation). And as you observed, it also breaks
abstraction. I'd prefer what e.g. SML does, where IEEE equality is a
separate operator.
from spec.
Ok, I now have an implementation of assert_eq_bits
and assert_nan
, and tests that use them (test/float32.wasm and test/float64.wasm), in this branch:
https://github.com/WebAssembly/spec/tree/float-tests
It's still experimental (the final version may not actually want to weigh in at 17 MiB of tests, etc.) but I think this demonstrates some nice properties of assert_eq_bits
and assert_nan
:
- It avoids using
=
and<>
on Float32.t and Float64.t values. Even if OCaml makes this work, it breaks the encapsulation of abstract types. - It avoids ambiguity on the term
eq
with respect to floating point types. - Each assert line in the test files test/float32.wasm and test/float64.wasm makes exactly one call into the wasm module, and does nothing but check the result value.
- It issues a human-readable error message when floating-point types are used for an integer assert, or integer types are used for a floating point assert.
What do people think?
from spec.
#81 implements this and is now merged.
from spec.
Related Issues (20)
- The definition of validation of br_table is inadequate HOT 3
- Question about validation of {element, data} segments HOT 1
- Wrong test cases in memory_init.wast HOT 3
- test case `as-load-operand` have an error HOT 1
- branching on function name HOT 7
- [interpreter] Source locations are broken since menhir switch HOT 2
- SIMD test optimization? HOT 3
- [core] SIMD Compare instructions link to the wrong "execution"/"validation" sections HOT 1
- Add a note indicating that section ids and section ordering do not correspond HOT 2
- Missing ability to access built older versions of the WebAssembly specification in archivable form HOT 2
- [JS API] 'run a host function' and 'create a host function' don't consistently handle completion records HOT 1
- Wording of README in proposals directory is misleading. HOT 6
- Test extreme alignments HOT 2
- Tests seem to cause side effects that other tests depend on HOT 2
- A question about max table size HOT 5
- Time to delete the old `master` branches? HOT 5
- Missing LICENSE file in the document directory HOT 1
- A question about the order of exports HOT 4
- [bikeshed] Some potential issues in js-api spec HOT 1
- [js-api] Bikeshed issues on wasm-3.0 branch HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spec.