Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Unified Diff: src/harmony-math.js

Issue 28723002: Harmony: implement Math.sign. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: complete test Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/harmony-math.js
diff --git a/test/mjsunit/regress/regress-2489.js b/src/harmony-math.js
similarity index 79%
copy from test/mjsunit/regress/regress-2489.js
copy to src/harmony-math.js
index 882c4f794a88e24d1d64e86a466b27c39f51e625..2e9b42a75e7cf368af023c29baaf9cd24663a3b8 100644
--- a/test/mjsunit/regress/regress-2489.js
+++ b/src/harmony-math.js
@@ -25,26 +25,25 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --allow-natives-syntax
+'use strict';
-"use strict";
-
-function f(a, b) {
- return g("c", "d");
+// ES6 draft 09-27-13, section 20.2.2.28.
+function MathSign(x) {
+ if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
+ if (x > 0) return 1;
+ if (x < 0) return -1;
+ if (x === 0) return x;
+ return NAN;
}
-function g(a, b) {
- g.constructor.apply(this, arguments);
-}
-g.constructor = function(a, b) {
- assertEquals("c", a);
- assertEquals("d", b);
+function ExtendMath() {
+ %CheckIsBootstrapping();
+
+ // Set up the non-enumerable functions on the Math object.
+ InstallFunctions($Math, DONT_ENUM, $Array(
+ "sign", MathSign
+ ));
}
-f("a", "b");
-f("a", "b");
-%OptimizeFunctionOnNextCall(f);
-f("a", "b");
-g.x = "deopt";
-f("a", "b");
+ExtendMath();

Powered by Google App Engine
This is Rietveld 408576698