[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
tkent at chromium.org
tkent at chromium.org
Thu Feb 4 21:36:04 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 07bbae18ebe561fdbe498df41d3302037ae3abd0
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Feb 2 04:42:43 2010 +0000
2010-02-01 Kent Tamura <tkent at chromium.org>
Reviewed by Darin Adler.
Fix a bug that Math.round() retunrs incorrect results for huge integers
https://bugs.webkit.org/show_bug.cgi?id=34462
* runtime/MathObject.cpp:
(JSC::mathProtoFuncRound): Avoid "arg + 0.5".
2010-02-01 Kent Tamura <tkent at chromium.org>
Reviewed by Darin Adler.
Fix a bug that Math.round() retunrs incorrect results for huge integers
https://bugs.webkit.org/show_bug.cgi?id=34462
* fast/js/math-expected.txt:
* fast/js/script-tests/math.js: Add test cases for Math.round() for huge numbers.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54197 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 95bb706..60796b4 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,13 @@
+2010-02-01 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Adler.
+
+ Fix a bug that Math.round() retunrs incorrect results for huge integers
+ https://bugs.webkit.org/show_bug.cgi?id=34462
+
+ * runtime/MathObject.cpp:
+ (JSC::mathProtoFuncRound): Avoid "arg + 0.5".
+
2010-02-01 Kwang Yul Seo <skyul at company100.net>
Reviewed by Eric Seidel.
diff --git a/JavaScriptCore/runtime/MathObject.cpp b/JavaScriptCore/runtime/MathObject.cpp
index 98ff3ba..8f22fba 100644
--- a/JavaScriptCore/runtime/MathObject.cpp
+++ b/JavaScriptCore/runtime/MathObject.cpp
@@ -218,7 +218,8 @@ JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec, JSObject*, JSValue, co
double arg = args.at(0).toNumber(exec);
if (signbit(arg) && arg >= -0.5)
return jsNumber(exec, -0.0);
- return jsNumber(exec, floor(arg + 0.5));
+ double integer = ceil(arg);
+ return jsNumber(exec, integer - (integer - arg > 0.5));
}
JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec, JSObject*, JSValue, const ArgList& args)
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 4263189..7b15d44 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-02-01 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Adler.
+
+ Fix a bug that Math.round() retunrs incorrect results for huge integers
+ https://bugs.webkit.org/show_bug.cgi?id=34462
+
+ * fast/js/math-expected.txt:
+ * fast/js/script-tests/math.js: Add test cases for Math.round() for huge numbers.
+
2010-02-01 Dmitry Titov <dimich at chromium.org>
Reviewed by David Levin.
diff --git a/LayoutTests/fast/js/math-expected.txt b/LayoutTests/fast/js/math-expected.txt
index ce43824..1b533e5 100644
--- a/LayoutTests/fast/js/math-expected.txt
+++ b/LayoutTests/fast/js/math-expected.txt
@@ -130,6 +130,17 @@ PASS Math.round(1.5) is 2
PASS Math.round(-1.5) is -1
PASS Math.round(1.6) is 2
PASS Math.round(-1.6) is -2
+PASS Math.round(8640000000000000) is 8640000000000000
+PASS Math.round(8640000000000000.5) is 8640000000000000
+PASS Math.round(8640000000000001) is 8640000000000001
+PASS Math.round(8640000000000002) is 8640000000000002
+PASS Math.round(9007199254740990) is 9007199254740990
+PASS Math.round(9007199254740991) is 9007199254740991
+PASS Math.round(-8640000000000000) is -8640000000000000
+PASS Math.round(-8640000000000001) is -8640000000000001
+PASS Math.round(-8640000000000002) is -8640000000000002
+PASS Math.round(-9007199254740990) is -9007199254740990
+PASS Math.round(-9007199254740991) is -9007199254740991
PASS Math.round(Infinity) is Infinity
PASS Math.round(-Infinity) is -Infinity
PASS Math.sin(NaN) is NaN
diff --git a/LayoutTests/fast/js/script-tests/math.js b/LayoutTests/fast/js/script-tests/math.js
index 3d0f93a..d6163db 100644
--- a/LayoutTests/fast/js/script-tests/math.js
+++ b/LayoutTests/fast/js/script-tests/math.js
@@ -191,6 +191,18 @@ shouldBe("Math.round(1.5)", "2");
shouldBe("Math.round(-1.5)", "-1");
shouldBe("Math.round(1.6)", "2");
shouldBe("Math.round(-1.6)", "-2");
+shouldBe("Math.round(8640000000000000)", "8640000000000000");
+// The following is expected. Double can't represent .5 in this case.
+shouldBe("Math.round(8640000000000000.5)", "8640000000000000");
+shouldBe("Math.round(8640000000000001)", "8640000000000001");
+shouldBe("Math.round(8640000000000002)", "8640000000000002");
+shouldBe("Math.round(9007199254740990)", "9007199254740990");
+shouldBe("Math.round(9007199254740991)", "9007199254740991");
+shouldBe("Math.round(-8640000000000000)", "-8640000000000000");
+shouldBe("Math.round(-8640000000000001)", "-8640000000000001");
+shouldBe("Math.round(-8640000000000002)", "-8640000000000002");
+shouldBe("Math.round(-9007199254740990)", "-9007199254740990");
+shouldBe("Math.round(-9007199254740991)", "-9007199254740991");
shouldBe("Math.round(Infinity)", "Infinity");
shouldBe("Math.round(-Infinity)", "-Infinity");
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list