[Wasm] Fix invalid float and double sign parser for '-Infinity' value
This commit is contained in:
committed by
Space Team
parent
44190937b0
commit
5a46cb1c40
@@ -144,8 +144,11 @@ class StringNumberConversionTest {
|
|||||||
assertProduces("7.7e1", 77.0)
|
assertProduces("7.7e1", 77.0)
|
||||||
assertProduces("+770e-1", 77.0)
|
assertProduces("+770e-1", 77.0)
|
||||||
|
|
||||||
assertProduces("-NaN", -Double.NaN)
|
assertProduces("NaN", Double.NaN)
|
||||||
|
assertProduces("Infinity", Double.POSITIVE_INFINITY)
|
||||||
assertProduces("+Infinity", Double.POSITIVE_INFINITY)
|
assertProduces("+Infinity", Double.POSITIVE_INFINITY)
|
||||||
|
assertProduces("-NaN", -Double.NaN)
|
||||||
|
assertProduces("-Infinity", Double.NEGATIVE_INFINITY)
|
||||||
|
|
||||||
assertFailsOrNull("7..7")
|
assertFailsOrNull("7..7")
|
||||||
assertFailsOrNull("007 not a number")
|
assertFailsOrNull("007 not a number")
|
||||||
@@ -165,8 +168,11 @@ class StringNumberConversionTest {
|
|||||||
assertProduces("7.7e1", 77.0f)
|
assertProduces("7.7e1", 77.0f)
|
||||||
assertProduces("+770e-1", 77.0f)
|
assertProduces("+770e-1", 77.0f)
|
||||||
|
|
||||||
assertProduces("-NaN", -Float.NaN)
|
assertProduces("NaN", Float.NaN)
|
||||||
|
assertProduces("Infinity", Float.POSITIVE_INFINITY)
|
||||||
assertProduces("+Infinity", Float.POSITIVE_INFINITY)
|
assertProduces("+Infinity", Float.POSITIVE_INFINITY)
|
||||||
|
assertProduces("-NaN", -Float.NaN)
|
||||||
|
assertProduces("-Infinity", Float.NEGATIVE_INFINITY)
|
||||||
|
|
||||||
assertFailsOrNull("7..7")
|
assertFailsOrNull("7..7")
|
||||||
assertFailsOrNull("007 not a number")
|
assertFailsOrNull("007 not a number")
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ internal fun parseDouble(string: String): Double {
|
|||||||
if (tryParseWord("Infinity")) {
|
if (tryParseWord("Infinity")) {
|
||||||
parseUnsignificants()
|
parseUnsignificants()
|
||||||
if (index != string.length) numberFormatError(string)
|
if (index != string.length) numberFormatError(string)
|
||||||
return if (!isNegative) Double.POSITIVE_INFINITY else -Double.NEGATIVE_INFINITY
|
return if (!isNegative) Double.POSITIVE_INFINITY else Double.NEGATIVE_INFINITY
|
||||||
}
|
}
|
||||||
|
|
||||||
val numberBuilder = StringBuilder()
|
val numberBuilder = StringBuilder()
|
||||||
|
|||||||
Reference in New Issue
Block a user