OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --harmony-maths |
| 6 |
| 7 assertTrue(isNaN(Math.cbrt(NaN))); |
| 8 assertTrue(isNaN(Math.cbrt(function() {}))); |
| 9 assertTrue(isNaN(Math.cbrt({ toString: function() { return NaN; } }))); |
| 10 assertTrue(isNaN(Math.cbrt({ valueOf: function() { return "abc"; } }))); |
| 11 assertEquals("Infinity", String(1/Math.cbrt(0))); |
| 12 assertEquals("-Infinity", String(1/Math.cbrt(-0))); |
| 13 assertEquals("Infinity", String(Math.cbrt(Infinity))); |
| 14 assertEquals("-Infinity", String(Math.cbrt(-Infinity))); |
| 15 |
| 16 for (var i = 1E-100; i < 1E100; i *= Math.PI) { |
| 17 assertEqualsDelta(i, Math.cbrt(i*i*i), i * 1E-15); |
| 18 } |
| 19 |
| 20 for (var i = -1E-100; i > -1E100; i *= Math.E) { |
| 21 assertEqualsDelta(i, Math.cbrt(i*i*i), -i * 1E-15); |
| 22 } |
| 23 |
| 24 // Let's be exact at least for small integers. |
| 25 for (var i = 2; i < 10000; i++) { |
| 26 assertEquals(i, Math.cbrt(i*i*i)); |
| 27 } |
OLD | NEW |