1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-26 20:28:49 +08:00

Fix and tests for Math.pow

This commit is contained in:
Robert Krimen
2013-02-22 19:57:48 -08:00
parent b53c800965
commit b364451afe
2 changed files with 52 additions and 15 deletions

View File

@@ -66,7 +66,12 @@ func builtinMath_min(call FunctionCall) Value {
func builtinMath_pow(call FunctionCall) Value {
// TODO Make sure this works according to the specification (15.8.2.13)
return toValue(math.Pow(toFloat(call.Argument(0)), toFloat(call.Argument(1))))
x := toFloat(call.Argument(0))
y := toFloat(call.Argument(1))
if x == 1 && math.IsInf(y, 0) {
return NaNValue()
}
return toValue(math.Pow(x, y))
}
func builtinMath_random(call FunctionCall) Value {