NASHORN-28.js revision 2:da1e581c933b
1254721Semaste/* 2254721Semaste * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 3254721Semaste * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4254721Semaste * 5254721Semaste * This code is free software; you can redistribute it and/or modify it 6254721Semaste * under the terms of the GNU General Public License version 2 only, as 7254721Semaste * published by the Free Software Foundation. 8254721Semaste * 9254721Semaste * This code is distributed in the hope that it will be useful, but WITHOUT 10254721Semaste * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11254721Semaste * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12254721Semaste * version 2 for more details (a copy is included in the LICENSE file that 13296417Sdim * accompanied this code). 14296417Sdim * 15296417Sdim * You should have received a copy of the GNU General Public License version 16296417Sdim * 2 along with this work; if not, write to the Free Software Foundation, 17254721Semaste * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18254721Semaste * 19288943Sdim * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20254721Semaste * or visit www.oracle.com if you need additional information or have any 21254721Semaste * questions. 22254721Semaste */ 23288943Sdim 24254721Semaste/** 25254721Semaste * NASHORN-28: Issues with String representation of numbers. 26254721Semaste * 27254721Semaste * @test 28254721Semaste * @run 29254721Semaste */ 30254721Semaste 31280031Sdimvar str = String(0.0000001); 32280031Sdimif (str != "1e-7") { 33288943Sdim fail("1e-7 expected, but got " + str); 34254721Semaste} else { 35254721Semaste print("yes, it is 1e-7"); 36254721Semaste} 37254721Semaste 38254721Semasteif (String(-0.000001) !== "-0.000001") { 39254721Semaste fail('String(-0.000001) === "-0.000001". got ' + (String(-0.000001))); 40254721Semaste} else { 41254721Semaste print('yes, String(-0.000001) === "-0.000001"'); 42254721Semaste} 43254721Semaste 44254721Semasteif (String(-1e-6) !== "-0.000001") { 45254721Semaste fail('String(-1e-6) === "0.000001". got ' + (String(-1e-6))); 46254721Semaste} else { 47254721Semaste print('yes, String(-1e-6) === "0.000001"'); 48254721Semaste} 49254721Semaste 50254721Semasteif (String(-1E-6) !== "-0.000001") { 51254721Semaste fail('String(-1E-6) === "0.000001". got ' + (String(-1E-6))); 52254721Semaste} else { 53254721Semaste print('yes, String(-1E-6) === "0.000001"'); 54254721Semaste} 55254721Semaste