JDK-8008298.js revision 97:5851c5dac260
1/* 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25/** 26 * JDK-8008298: Add tests to cover specialized versions of Math functions. 27 * Excerise all specialized Math functions with various literal values. 28 * 29 * @test 30 * @run 31 */ 32 33if (Math.abs(-88) != 88) { 34 fail("Math.abs for int value"); 35} 36 37if (Math.abs(-2147483648) != 2147483648) { 38 fail("Math.abs failed for long value"); 39} 40 41if (Math.acos(1.0) != 0) { 42 fail("Math.acos failed on double value"); 43} 44 45if (Math.asin(0.0) != 0) { 46 fail("Math.asin failed on double value"); 47} 48 49if (Math.atan(0.0) != 0) { 50 fail("Math.atan failed on double value"); 51} 52 53if (Math.ceil(1) != 1) { 54 fail("Math.ceil failed on int value"); 55} 56 57if (Math.ceil(2147483648) != 2147483648) { 58 fail("Math.ceil failed on long value"); 59} 60 61if (Math.ceil(-0.3) != 0) { 62 fail("Math.ceil failed on double value"); 63} 64 65if (Math.floor(1) != 1) { 66 fail("Math.floor failed on int value"); 67} 68 69if (Math.floor(2147483648) != 2147483648) { 70 fail("Math.floor failed on long value"); 71} 72 73if (Math.floor(0.3) != 0) { 74 fail("Math.floor failed on double value"); 75} 76 77if (Math.log(1.0) != 0) { 78 fail("Math.log failed on double value"); 79} 80 81if (Math.max(2, 28) != 28) { 82 fail("Math.max failed for int values"); 83} 84 85if (Math.max(2147483649, 2147483648) != 2147483649) { 86 fail("Math.max failed for long values"); 87} 88 89if (Math.max(0.0, -2.5) != 0.0) { 90 fail("Math.max failed for double values"); 91} 92 93if (Math.min(2, 28) != 2) { 94 fail("Math.min failed for int values"); 95} 96 97if (Math.min(2147483649, 2147483648) != 2147483648) { 98 fail("Math.min failed for long values"); 99} 100 101if (Math.min(0.0, 2.5) != 0.0) { 102 fail("Math.min failed for double values"); 103} 104 105if (Math.sqrt(4) != 2) { 106 fail("Math.sqrt failed for int value"); 107} 108 109if (Math.tan(0.0) != 0.0) { 110 fail("Math.tan failed for double value"); 111} 112