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

Side by Side Diff: test/mjsunit/es6/math-cbrt.js

Issue 394833002: Ship ES6 Math functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/es6/math-clz32.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-maths
6
7 assertTrue(isNaN(Math.cbrt(NaN))); 5 assertTrue(isNaN(Math.cbrt(NaN)));
8 assertTrue(isNaN(Math.cbrt(function() {}))); 6 assertTrue(isNaN(Math.cbrt(function() {})));
9 assertTrue(isNaN(Math.cbrt({ toString: function() { return NaN; } }))); 7 assertTrue(isNaN(Math.cbrt({ toString: function() { return NaN; } })));
10 assertTrue(isNaN(Math.cbrt({ valueOf: function() { return "abc"; } }))); 8 assertTrue(isNaN(Math.cbrt({ valueOf: function() { return "abc"; } })));
11 assertEquals("Infinity", String(1/Math.cbrt(0))); 9 assertEquals("Infinity", String(1/Math.cbrt(0)));
12 assertEquals("-Infinity", String(1/Math.cbrt(-0))); 10 assertEquals("-Infinity", String(1/Math.cbrt(-0)));
13 assertEquals("Infinity", String(Math.cbrt(Infinity))); 11 assertEquals("Infinity", String(Math.cbrt(Infinity)));
14 assertEquals("-Infinity", String(Math.cbrt(-Infinity))); 12 assertEquals("-Infinity", String(Math.cbrt(-Infinity)));
15 13
16 for (var i = 1E-100; i < 1E100; i *= Math.PI) { 14 for (var i = 1E-100; i < 1E100; i *= Math.PI) {
17 assertEqualsDelta(i, Math.cbrt(i*i*i), i * 1E-15); 15 assertEqualsDelta(i, Math.cbrt(i*i*i), i * 1E-15);
18 } 16 }
19 17
20 for (var i = -1E-100; i > -1E100; i *= Math.E) { 18 for (var i = -1E-100; i > -1E100; i *= Math.E) {
21 assertEqualsDelta(i, Math.cbrt(i*i*i), -i * 1E-15); 19 assertEqualsDelta(i, Math.cbrt(i*i*i), -i * 1E-15);
22 } 20 }
23 21
24 // Let's be exact at least for small integers. 22 // Let's be exact at least for small integers.
25 for (var i = 2; i < 10000; i++) { 23 for (var i = 2; i < 10000; i++) {
26 assertEquals(i, Math.cbrt(i*i*i)); 24 assertEquals(i, Math.cbrt(i*i*i));
27 } 25 }
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/es6/math-clz32.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698