Path: blob/aarch64-shenandoah-jdk8u272-b10/nashorn/test/script/basic/JDK-8008298.js
32281 views
/*1* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/222324/**25* JDK-8008298: Add tests to cover specialized versions of Math functions.26* Excerise all specialized Math functions with various literal values.27*28* @test29* @run30*/3132if (Math.abs(-88) != 88) {33fail("Math.abs for int value");34}3536if (Math.abs(-2147483648) != 2147483648) {37fail("Math.abs failed for long value");38}3940if (Math.acos(1.0) != 0) {41fail("Math.acos failed on double value");42}4344if (Math.asin(0.0) != 0) {45fail("Math.asin failed on double value");46}4748if (Math.atan(0.0) != 0) {49fail("Math.atan failed on double value");50}5152if (Math.ceil(1) != 1) {53fail("Math.ceil failed on int value");54}5556if (Math.ceil(2147483648) != 2147483648) {57fail("Math.ceil failed on long value");58}5960if (Math.ceil(-0.3) != 0) {61fail("Math.ceil failed on double value");62}6364if (Math.floor(1) != 1) {65fail("Math.floor failed on int value");66}6768if (Math.floor(2147483648) != 2147483648) {69fail("Math.floor failed on long value");70}7172if (Math.floor(0.3) != 0) {73fail("Math.floor failed on double value");74}7576if (Math.log(1.0) != 0) {77fail("Math.log failed on double value");78}7980if (Math.max(2, 28) != 28) {81fail("Math.max failed for int values");82}8384if (Math.max(2147483649, 2147483648) != 2147483649) {85fail("Math.max failed for long values");86}8788if (Math.max(0.0, -2.5) != 0.0) {89fail("Math.max failed for double values");90}9192if (Math.min(2, 28) != 2) {93fail("Math.min failed for int values");94}9596if (Math.min(2147483649, 2147483648) != 2147483648) {97fail("Math.min failed for long values");98}99100if (Math.min(0.0, 2.5) != 0.0) {101fail("Math.min failed for double values");102}103104if (Math.sqrt(4) != 2) {105fail("Math.sqrt failed for int value");106}107108if (Math.tan(0.0) != 0.0) {109fail("Math.tan failed for double value");110}111112113