-
Notifications
You must be signed in to change notification settings - Fork 51
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
Enable Wasm tests #574
Enable Wasm tests #574
Conversation
64351b7
to
8cda171
Compare
@charleskorn ready to review! |
Hi, @krzema12 if (expectedResult.isNaN()) {
result.isNaN() shouldBe true
} else {
result shouldBe expectedResult
} Because this is not correct to compare NaN to itself. This only works for jvm because the assertion uses class Scratch {
public static void main(String[] args) {
System.out.println(Float.NaN == Float.NaN); // false
System.out.println(Objects.equals(Float.NaN, Float.NaN)); // true
}
} But in JS, NaN is always not equal to another NaN |
Thanks @OptimumCode! Will try it. |
What for the rest of the failing tests: I believe the only thing we can do here is to extract them into separate test blocks and disable them for JS target. Disabling can be done like this: import io.kotest.common.Platform
import io.kotest.common.platform
import io.kotest.core.test.Enabled
test("throws an appropriate exception").config(enabledOrReasonIf = {
if (platform == Platform.JS) {
Enabled.disabled("valid floating points for JS")
} else {
Enabled.enabled
}
}) The reason for this is JS... 0x2 and 0o2 are valid numbers with floating points in JS. Here is how public actual fun String.toDouble(): Double = (+(this.asDynamic())).unsafeCast<Double>().also {
if (it.isNaN() && !this.isNaN() || it == 0.0 && this.isBlank())
numberFormatError(this)
} Basically, every valid number is a valid number with floating point in JS... But one thing I cannot understand here is how those tests pass for the wasmJs target. This is a mystery for me at the moment |
I suggest focusing on Wasm in this PR, to deliver some value quicker, and let's tackle JS tests separately. |
Sure, I absolutely agree with you. Just wanted to leave some notes because you said there were some issues with JS tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @krzema12!
Two changes were needed:
build/js/yarn.lock
and then running the tests again: https://youtrack.jetbrains.com/issue/KT-68950/Wasm-test-task-fails-with-multiple-Could-not-write-XML-test-results-...#focus=Comments-27-9945807.0-0JS tests still fail, mostly with
AssertionFailedError: expected:<NaN> but was:<NaN>
, so leaving them disabled.