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