mirror of
https://github.com/robertkrimen/otto
synced 2025-10-19 19:55:30 +08:00
Fix for S15.1.2.3_A2_T10
This commit is contained in:
parent
e314343b47
commit
87e059e861
14
bug_test.go
14
bug_test.go
|
@ -675,3 +675,17 @@ func Test_S15_1_2_2_A2_T10(t *testing.T) {
|
||||||
`, true)
|
`, true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_S15_1_2_3_A2_T10(t *testing.T) {
|
||||||
|
tt(t, func() {
|
||||||
|
test, _ := test()
|
||||||
|
|
||||||
|
test(`
|
||||||
|
parseFloat("\u180E" + "1.1") === parseFloat("1.1");
|
||||||
|
`, true)
|
||||||
|
|
||||||
|
test(`
|
||||||
|
parseFloat("\u180E" + "\u180E" + "\u180E" + "1.1") === parseFloat("1.1");
|
||||||
|
`, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -153,7 +153,8 @@ var parseFloat_matchValid = regexp.MustCompile(`[0-9eE\+\-\.]|Infinity`)
|
||||||
|
|
||||||
func builtinGlobal_parseFloat(call FunctionCall) Value {
|
func builtinGlobal_parseFloat(call FunctionCall) Value {
|
||||||
// Caveat emptor: This implementation does NOT match the specification
|
// Caveat emptor: This implementation does NOT match the specification
|
||||||
input := strings.TrimSpace(call.Argument(0).string())
|
input := strings.Trim(call.Argument(0).string(), builtinString_trim_whitespace)
|
||||||
|
|
||||||
if parseFloat_matchBadSpecial.MatchString(input) {
|
if parseFloat_matchBadSpecial.MatchString(input) {
|
||||||
return NaNValue()
|
return NaNValue()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user