Skip to content

Commit

Permalink
Fix to handle Infinity radix in parseInt properly
Browse files Browse the repository at this point in the history
  • Loading branch information
robertkrimen committed Nov 15, 2012
1 parent 2a36c82 commit aef569f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func builtinGlobal_parseInt(call FunctionCall) Value {
radix := call.Argument(1)
radixValue := 0
if radix.IsDefined() {
radixValue = int(toInteger(radix))
radixValue = int(toI32(radix))
}
value, err := strconv.ParseInt(string_, radixValue, 64)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ func TestString_substr(t *testing.T) {

test(`"abcd".substr(3, 5)`, "d")
}

1 change: 1 addition & 0 deletions otto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,7 @@ func Test_parseInt(t *testing.T) {
// TODO parseInt should return 10 in this scenario
test(`parseInt("0x0aXyzzy")`, "10")
}
test(`parseInt("0x0a", Infinity)`, "10")
}

func Test_parseFloat(t *testing.T) {
Expand Down

0 comments on commit aef569f

Please sign in to comment.