1// Copyright 2013 the V8 project authors. All rights reserved. 2// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3// 4// Redistribution and use in source and binary forms, with or without 5// modification, are permitted provided that the following conditions 6// are met: 7// 1. Redistributions of source code must retain the above copyright 8// notice, this list of conditions and the following disclaimer. 9// 2. Redistributions in binary form must reproduce the above copyright 10// notice, this list of conditions and the following disclaimer in the 11// documentation and/or other materials provided with the distribution. 12// 13// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY 14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 24description("KDE JS Test"); 25shouldBe("Number()", "0"); 26shouldBe("Number(1)", "1"); 27shouldBe("Number(1.1)", "1.1"); 28shouldBe("Number('1.2')", "1.2"); 29shouldBe("isNaN(Number('a'))", "true"); 30 31shouldBe("(new Number()).valueOf()", "0"); 32shouldBe("(new Number(.4)).valueOf()", "0.4"); 33shouldBe("(new Number('1.')).valueOf()", "1"); 34shouldBe("isNaN(new Number('a'))", "true"); 35 36shouldBe("isNaN(Number.NaN)", "true"); 37shouldBe("Number.NEGATIVE_INFINITY", "-Infinity"); 38shouldBe("Number.POSITIVE_INFINITY", "Infinity"); 39 40shouldBe("(1).toString()", "'1'"); 41shouldBe("typeof (1).toString()", "'string'"); 42shouldBe("(10).toString(16)", "'a'"); 43shouldBe("(8.5).toString(16)", "'8.8'"); 44shouldBe("(-8.5).toString(16)", "'-8.8'"); 45shouldBe("Number.NaN.toString(16)", "'NaN'"); 46shouldBe("Number.POSITIVE_INFINITY.toString(16)", "'Infinity'"); 47shouldBe("Number.NEGATIVE_INFINITY.toString(16)", "'-Infinity'"); 48shouldBe("Number.MAX_VALUE.toString(2).length", "1024"); 49shouldBe("(1).valueOf()", "1"); 50shouldBe("typeof (1).valueOf()", "'number'"); 51 52function toFixedOrException(val,fractionDigits) 53{ 54 var s = ""; 55 try { 56 s = String(Number(val).toFixed(fractionDigits)); 57 } 58 catch (e) { 59 s = String(e); 60 } 61 return s; 62} 63 64shouldBe("Number(1234.567).toFixed(0)","\"1235\""); 65shouldBe("Number(1234.567).toFixed(undefined)","\"1235\""); 66shouldBe("Number(-1234.567).toFixed(0)","\"-1235\""); 67shouldBe("Number(-1234.567).toFixed(undefined)","\"-1235\""); 68shouldBe("Number(0).toFixed(7)","\"0.0000000\""); 69shouldBe("Number(0.003).toFixed(0)","\"0\""); 70shouldBe("Number(-0.003).toFixed(0)","\"-0\""); 71shouldBe("Number(40.1234567890123).toFixed(7)","\"40.1234568\""); 72shouldBe("Number(-40.1234567890123).toFixed(7)","\"-40.1234568\""); 73shouldBe("Number(4).toFixed(7)","\"4.0000000\""); 74shouldBe("Number(-4).toFixed(7)","\"-4.0000000\""); 75shouldBe("Number(0.000056).toFixed(7)","\"0.0000560\""); 76shouldBe("Number(-0.000056).toFixed(7)","\"-0.0000560\""); 77shouldBe("Number(NaN).toFixed(7)","\"NaN\""); 78shouldBe("Number(Infinity).toFixed(7)","\"Infinity\""); 79shouldBe("Number(-Infinity).toFixed(7)","\"-Infinity\""); 80shouldBe("Number(Math.pow(10,4)).toFixed(13)","\"10000.0000000000000\""); 81shouldBe("Number(Math.pow(10,17)).toFixed(16)","\"100000000000000000.0000000000000000\""); 82shouldBe("Number(Math.pow(10,18)).toFixed(17)","\"1000000000000000000.00000000000000000\""); 83shouldBe("Number(Math.pow(10,19)).toFixed(18)","\"10000000000000000000.000000000000000000\""); 84shouldBe("Number(Math.pow(10,17)).toFixed(20)","\"100000000000000000.00000000000000000000\""); 85shouldBe("Number(Math.pow(10,18)).toFixed(20)","\"1000000000000000000.00000000000000000000\""); 86shouldBe("Number(Math.pow(10,19)).toFixed(20)","\"10000000000000000000.00000000000000000000\""); 87shouldBe("Number(Math.pow(10,20)).toFixed(20)","\"100000000000000000000.00000000000000000000\""); 88shouldBe("Number(Math.pow(10,21)).toFixed(20)","\"1e+21\""); 89shouldBe("Number(-Math.pow(10,4)).toFixed(13)","\"-10000.0000000000000\""); 90shouldBe("Number(-Math.pow(10,17)).toFixed(16)","\"-100000000000000000.0000000000000000\""); 91shouldBe("Number(-Math.pow(10,18)).toFixed(17)","\"-1000000000000000000.00000000000000000\""); 92shouldBe("Number(-Math.pow(10,19)).toFixed(18)","\"-10000000000000000000.000000000000000000\""); 93shouldBe("Number(-Math.pow(10,17)).toFixed(20)","\"-100000000000000000.00000000000000000000\""); 94shouldBe("Number(-Math.pow(10,18)).toFixed(20)","\"-1000000000000000000.00000000000000000000\""); 95shouldBe("Number(-Math.pow(10,19)).toFixed(20)","\"-10000000000000000000.00000000000000000000\""); 96shouldBe("Number(-Math.pow(10,20)).toFixed(20)","\"-100000000000000000000.00000000000000000000\""); 97shouldBe("Number(-Math.pow(10,21)).toFixed(20)","\"-1e+21\""); 98shouldBeTrue("toFixedOrException(2,-1).indexOf('Range') >= 0"); 99shouldBe("Number(2).toFixed(0)","\"2\""); 100shouldBe("Number(2).toFixed(20)","\"2.00000000000000000000\""); 101shouldBeTrue("toFixedOrException(2,21).indexOf('Range') >= 0"); 102shouldBeTrue("toFixedOrException(-2,-1).indexOf('Range') >= 0"); 103shouldBe("Number(-2).toFixed(0)","\"-2\""); 104shouldBe("Number(-2).toFixed(20)","\"-2.00000000000000000000\""); 105shouldBeTrue("toFixedOrException(-2,21).indexOf('Range') >= 0"); 106 107 108 109 110shouldBe("Number(NaN).toExponential()","\"NaN\""); 111shouldBe("Number(Infinity).toExponential()","\"Infinity\""); 112shouldBe("Number(-Infinity).toExponential()","\"-Infinity\""); 113shouldBe("Number(NaN).toExponential(4)","\"NaN\""); 114shouldBe("Number(Infinity).toExponential(4)","\"Infinity\""); 115shouldBe("Number(-Infinity).toExponential(4)","\"-Infinity\""); 116shouldBe("Number(123.456).toExponential()","\"1.23456e+2\""); 117shouldBeTrue("try { Number(123.456).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }"); 118shouldBe("Number(123.456).toExponential(0)","\"1e+2\""); 119shouldBe("Number(123.456).toExponential(1)","\"1.2e+2\""); 120shouldBe("Number(123.456).toExponential(2)","\"1.23e+2\""); 121shouldBe("Number(123.456).toExponential(3)","\"1.235e+2\""); 122shouldBe("Number(123.456).toExponential(4)","\"1.2346e+2\""); 123shouldBe("Number(123.456).toExponential(5)","\"1.23456e+2\""); 124shouldBe("Number(123.456).toExponential(6)","\"1.234560e+2\""); 125shouldBe("Number(123.456).toExponential(7)","\"1.2345600e+2\""); 126shouldBe("Number(123.456).toExponential(8)","\"1.23456000e+2\""); 127shouldBe("Number(123.456).toExponential(9)","\"1.234560000e+2\""); 128shouldBe("Number(123.456).toExponential(10)","\"1.2345600000e+2\""); 129shouldBe("Number(123.456).toExponential(11)","\"1.23456000000e+2\""); 130shouldBe("Number(123.456).toExponential(12)","\"1.234560000000e+2\""); 131shouldBe("Number(123.456).toExponential(13)","\"1.2345600000000e+2\""); 132shouldBe("Number(123.456).toExponential(14)","\"1.23456000000000e+2\""); 133shouldBe("Number(123.456).toExponential(15)","\"1.234560000000000e+2\""); 134shouldBe("Number(123.456).toExponential(16)","\"1.2345600000000000e+2\""); 135shouldBe("Number(123.456).toExponential(17)","\"1.23456000000000003e+2\""); 136shouldBe("Number(123.456).toExponential(18)","\"1.234560000000000031e+2\""); 137shouldBe("Number(123.456).toExponential(19)","\"1.2345600000000000307e+2\""); 138shouldBe("Number(123.456).toExponential(20)","\"1.23456000000000003070e+2\""); 139shouldBeTrue("try { Number(123.456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }"); 140shouldBe("Number(-123.456).toExponential()","\"-1.23456e+2\""); 141shouldBeTrue("try { Number(-123.456).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }"); 142shouldBe("Number(-123.456).toExponential(0)","\"-1e+2\""); 143shouldBe("Number(-123.456).toExponential(1)","\"-1.2e+2\""); 144shouldBe("Number(-123.456).toExponential(2)","\"-1.23e+2\""); 145shouldBe("Number(-123.456).toExponential(3)","\"-1.235e+2\""); 146shouldBe("Number(-123.456).toExponential(4)","\"-1.2346e+2\""); 147shouldBe("Number(-123.456).toExponential(5)","\"-1.23456e+2\""); 148shouldBe("Number(-123.456).toExponential(6)","\"-1.234560e+2\""); 149shouldBe("Number(-123.456).toExponential(7)","\"-1.2345600e+2\""); 150shouldBe("Number(-123.456).toExponential(8)","\"-1.23456000e+2\""); 151shouldBe("Number(-123.456).toExponential(9)","\"-1.234560000e+2\""); 152shouldBe("Number(-123.456).toExponential(10)","\"-1.2345600000e+2\""); 153shouldBe("Number(-123.456).toExponential(11)","\"-1.23456000000e+2\""); 154shouldBe("Number(-123.456).toExponential(12)","\"-1.234560000000e+2\""); 155shouldBe("Number(-123.456).toExponential(13)","\"-1.2345600000000e+2\""); 156shouldBe("Number(-123.456).toExponential(14)","\"-1.23456000000000e+2\""); 157shouldBe("Number(-123.456).toExponential(15)","\"-1.234560000000000e+2\""); 158shouldBe("Number(-123.456).toExponential(16)","\"-1.2345600000000000e+2\""); 159shouldBe("Number(-123.456).toExponential(17)","\"-1.23456000000000003e+2\""); 160shouldBe("Number(-123.456).toExponential(18)","\"-1.234560000000000031e+2\""); 161shouldBe("Number(-123.456).toExponential(19)","\"-1.2345600000000000307e+2\""); 162shouldBe("Number(-123.456).toExponential(20)","\"-1.23456000000000003070e+2\""); 163shouldBeTrue("try { Number(-123.456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }"); 164shouldBe("Number(.000123456).toExponential()","\"1.23456e-4\""); 165shouldBeTrue("try { Number(.000123456).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }"); 166shouldBe("Number(.000123456).toExponential(0)","\"1e-4\""); 167shouldBe("Number(.000123456).toExponential(1)","\"1.2e-4\""); 168shouldBe("Number(.000123456).toExponential(2)","\"1.23e-4\""); 169shouldBe("Number(.000123456).toExponential(3)","\"1.235e-4\""); 170shouldBe("Number(.000123456).toExponential(4)","\"1.2346e-4\""); 171shouldBe("Number(.000123456).toExponential(5)","\"1.23456e-4\""); 172shouldBe("Number(.000123456).toExponential(6)","\"1.234560e-4\""); 173shouldBe("Number(.000123456).toExponential(7)","\"1.2345600e-4\""); 174shouldBe("Number(.000123456).toExponential(8)","\"1.23456000e-4\""); 175shouldBe("Number(.000123456).toExponential(9)","\"1.234560000e-4\""); 176shouldBe("Number(.000123456).toExponential(10)","\"1.2345600000e-4\""); 177shouldBe("Number(.000123456).toExponential(11)","\"1.23456000000e-4\""); 178shouldBe("Number(.000123456).toExponential(12)","\"1.234560000000e-4\""); 179shouldBe("Number(.000123456).toExponential(13)","\"1.2345600000000e-4\""); 180shouldBe("Number(.000123456).toExponential(14)","\"1.23456000000000e-4\""); 181shouldBe("Number(.000123456).toExponential(15)","\"1.234560000000000e-4\""); 182shouldBe("Number(.000123456).toExponential(16)","\"1.2345600000000001e-4\""); 183shouldBe("Number(.000123456).toExponential(17)","\"1.23456000000000005e-4\""); 184shouldBe("Number(.000123456).toExponential(18)","\"1.234560000000000052e-4\""); 185shouldBe("Number(.000123456).toExponential(19)","\"1.2345600000000000519e-4\""); 186shouldBe("Number(.000123456).toExponential(20)","\"1.23456000000000005188e-4\""); 187shouldBeTrue("try { Number(.000123456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }"); 188shouldBe("Number(-.000123456).toExponential()","\"-1.23456e-4\""); 189shouldBeTrue("try { Number(-.000123456).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }"); 190shouldBe("Number(-.000123456).toExponential(0)","\"-1e-4\""); 191shouldBe("Number(-.000123456).toExponential(1)","\"-1.2e-4\""); 192shouldBe("Number(-.000123456).toExponential(2)","\"-1.23e-4\""); 193shouldBe("Number(-.000123456).toExponential(3)","\"-1.235e-4\""); 194shouldBe("Number(-.000123456).toExponential(4)","\"-1.2346e-4\""); 195shouldBe("Number(-.000123456).toExponential(5)","\"-1.23456e-4\""); 196shouldBe("Number(-.000123456).toExponential(6)","\"-1.234560e-4\""); 197shouldBe("Number(-.000123456).toExponential(7)","\"-1.2345600e-4\""); 198shouldBe("Number(-.000123456).toExponential(8)","\"-1.23456000e-4\""); 199shouldBe("Number(-.000123456).toExponential(9)","\"-1.234560000e-4\""); 200shouldBe("Number(-.000123456).toExponential(10)","\"-1.2345600000e-4\""); 201shouldBe("Number(-.000123456).toExponential(11)","\"-1.23456000000e-4\""); 202shouldBe("Number(-.000123456).toExponential(12)","\"-1.234560000000e-4\""); 203shouldBe("Number(-.000123456).toExponential(13)","\"-1.2345600000000e-4\""); 204shouldBe("Number(-.000123456).toExponential(14)","\"-1.23456000000000e-4\""); 205shouldBe("Number(-.000123456).toExponential(15)","\"-1.234560000000000e-4\""); 206shouldBe("Number(-.000123456).toExponential(16)","\"-1.2345600000000001e-4\""); 207shouldBe("Number(-.000123456).toExponential(17)","\"-1.23456000000000005e-4\""); 208shouldBe("Number(-.000123456).toExponential(18)","\"-1.234560000000000052e-4\""); 209shouldBe("Number(-.000123456).toExponential(19)","\"-1.2345600000000000519e-4\""); 210shouldBe("Number(-.000123456).toExponential(20)","\"-1.23456000000000005188e-4\""); 211shouldBeTrue("try { Number(-.000123456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }"); 212shouldBe("Number(123.4567890123456789012).toExponential()","\"1.2345678901234568e+2\""); 213shouldBeTrue("try { Number(123.4567890123456789012).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }"); 214shouldBe("Number(123.4567890123456789012).toExponential(0)","\"1e+2\""); 215shouldBe("Number(123.4567890123456789012).toExponential(1)","\"1.2e+2\""); 216shouldBe("Number(123.4567890123456789012).toExponential(2)","\"1.23e+2\""); 217shouldBe("Number(123.4567890123456789012).toExponential(3)","\"1.235e+2\""); 218shouldBe("Number(123.4567890123456789012).toExponential(4)","\"1.2346e+2\""); 219shouldBe("Number(123.4567890123456789012).toExponential(5)","\"1.23457e+2\""); 220shouldBe("Number(123.4567890123456789012).toExponential(6)","\"1.234568e+2\""); 221shouldBe("Number(123.4567890123456789012).toExponential(7)","\"1.2345679e+2\""); 222shouldBe("Number(123.4567890123456789012).toExponential(8)","\"1.23456789e+2\""); 223shouldBe("Number(123.4567890123456789012).toExponential(9)","\"1.234567890e+2\""); 224shouldBe("Number(123.4567890123456789012).toExponential(10)","\"1.2345678901e+2\""); 225shouldBe("Number(123.4567890123456789012).toExponential(11)","\"1.23456789012e+2\""); 226shouldBe("Number(123.4567890123456789012).toExponential(12)","\"1.234567890123e+2\""); 227shouldBe("Number(123.4567890123456789012).toExponential(13)","\"1.2345678901235e+2\""); 228shouldBe("Number(123.4567890123456789012).toExponential(14)","\"1.23456789012346e+2\""); 229shouldBe("Number(123.4567890123456789012).toExponential(15)","\"1.234567890123457e+2\""); 230shouldBe("Number(123.4567890123456789012).toExponential(16)","\"1.2345678901234568e+2\""); 231shouldBe("Number(123.4567890123456789012).toExponential(17)","\"1.23456789012345681e+2\""); 232shouldBe("Number(123.4567890123456789012).toExponential(18)","\"1.234567890123456806e+2\""); 233shouldBe("Number(123.4567890123456789012).toExponential(19)","\"1.2345678901234568059e+2\""); 234shouldBe("Number(123.4567890123456789012).toExponential(20)","\"1.23456789012345680590e+2\""); 235shouldBeTrue("try { Number(123.4567890123456789012).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }"); 236shouldBe("Number(-123.4567890123456789012).toExponential()","\"-1.2345678901234568e+2\""); 237shouldBeTrue("try { Number(-123.4567890123456789012).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }"); 238shouldBe("Number(-123.4567890123456789012).toExponential(0)","\"-1e+2\""); 239shouldBe("Number(-123.4567890123456789012).toExponential(1)","\"-1.2e+2\""); 240shouldBe("Number(-123.4567890123456789012).toExponential(2)","\"-1.23e+2\""); 241shouldBe("Number(-123.4567890123456789012).toExponential(3)","\"-1.235e+2\""); 242shouldBe("Number(-123.4567890123456789012).toExponential(4)","\"-1.2346e+2\""); 243shouldBe("Number(-123.4567890123456789012).toExponential(5)","\"-1.23457e+2\""); 244shouldBe("Number(-123.4567890123456789012).toExponential(6)","\"-1.234568e+2\""); 245shouldBe("Number(-123.4567890123456789012).toExponential(7)","\"-1.2345679e+2\""); 246shouldBe("Number(-123.4567890123456789012).toExponential(8)","\"-1.23456789e+2\""); 247shouldBe("Number(-123.4567890123456789012).toExponential(9)","\"-1.234567890e+2\""); 248shouldBe("Number(-123.4567890123456789012).toExponential(10)","\"-1.2345678901e+2\""); 249shouldBe("Number(-123.4567890123456789012).toExponential(11)","\"-1.23456789012e+2\""); 250shouldBe("Number(-123.4567890123456789012).toExponential(12)","\"-1.234567890123e+2\""); 251shouldBe("Number(-123.4567890123456789012).toExponential(13)","\"-1.2345678901235e+2\""); 252shouldBe("Number(-123.4567890123456789012).toExponential(14)","\"-1.23456789012346e+2\""); 253shouldBe("Number(-123.4567890123456789012).toExponential(15)","\"-1.234567890123457e+2\""); 254shouldBe("Number(-123.4567890123456789012).toExponential(16)","\"-1.2345678901234568e+2\""); 255shouldBe("Number(-123.4567890123456789012).toExponential(17)","\"-1.23456789012345681e+2\""); 256shouldBe("Number(-123.4567890123456789012).toExponential(18)","\"-1.234567890123456806e+2\""); 257shouldBe("Number(-123.4567890123456789012).toExponential(19)","\"-1.2345678901234568059e+2\""); 258shouldBe("Number(-123.4567890123456789012).toExponential(20)","\"-1.23456789012345680590e+2\""); 259shouldBeTrue("try { Number(-123.4567890123456789012).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }"); 260shouldBe("Number(.0000000000000000000001).toExponential()","\"1e-22\""); 261shouldBe("Number(.0000000000000000000012).toExponential()","\"1.2e-21\""); 262shouldBe("Number(.0000000000000000000123).toExponential()","\"1.23e-20\""); 263shouldBe("Number(.0000000000000000000123).toExponential()","\"1.23e-20\""); 264shouldBe("Number(.0000000000000000001234).toExponential()","\"1.234e-19\""); 265shouldBe("Number(.0000000000000000012345).toExponential()","\"1.2345e-18\""); 266shouldBe("Number(.0000000000000000123456).toExponential()","\"1.23456e-17\""); 267shouldBe("Number(.0000000000000001234567).toExponential()","\"1.234567e-16\""); 268shouldBe("Number(.0000000000000012345678).toExponential()","\"1.2345678e-15\""); 269shouldBe("Number(.0000000000000123456789).toExponential()","\"1.23456789e-14\""); 270shouldBe("Number(.0000000000001234567890).toExponential()","\"1.23456789e-13\""); 271shouldBe("Number(.0000000000012345678901).toExponential()","\"1.2345678901e-12\""); 272shouldBe("Number(.0000000000123456789012).toExponential()","\"1.23456789012e-11\""); 273shouldBe("Number(.0000000001234567890123).toExponential()","\"1.234567890123e-10\""); 274shouldBe("Number(.0000000012345678901234).toExponential()","\"1.2345678901234e-9\""); 275shouldBe("Number(.0000000123456789012345).toExponential()","\"1.23456789012345e-8\""); 276shouldBe("Number(.0000001234567890123456).toExponential()","\"1.234567890123456e-7\""); 277shouldBe("Number(.0000012345678901234567).toExponential()","\"1.2345678901234567e-6\""); 278shouldBe("Number(.0000123456789012345678).toExponential()","\"1.2345678901234568e-5\""); 279shouldBe("Number(.0001234567890123456789).toExponential()","\"1.2345678901234567e-4\""); 280shouldBe("Number(.0012345678901234567890).toExponential()","\"1.2345678901234567e-3\""); 281shouldBe("Number(.0123456789012345678901).toExponential()","\"1.2345678901234568e-2\""); 282shouldBe("Number(1.234567890123456789012).toExponential()","\"1.2345678901234567e+0\""); 283shouldBe("Number(12.34567890123456789012).toExponential()","\"1.2345678901234567e+1\""); 284shouldBe("Number(123.4567890123456789012).toExponential()","\"1.2345678901234568e+2\""); 285shouldBe("Number(1234.567890123456789012).toExponential()","\"1.234567890123457e+3\""); 286shouldBe("Number(12345.67890123456789012).toExponential()","\"1.2345678901234567e+4\""); 287shouldBe("Number(123456.7890123456789012).toExponential()","\"1.2345678901234567e+5\""); 288shouldBe("Number(1234567.890123456789012).toExponential()","\"1.2345678901234567e+6\""); 289shouldBe("Number(12345678.90123456789012).toExponential()","\"1.2345678901234567e+7\""); 290shouldBe("Number(123456789.0123456789012).toExponential()","\"1.2345678901234567e+8\""); 291shouldBe("Number(1234567890.123456789012).toExponential()","\"1.2345678901234567e+9\""); 292shouldBe("Number(12345678901.23456789012).toExponential()","\"1.2345678901234568e+10\""); 293shouldBe("Number(123456789012.3456789012).toExponential()","\"1.2345678901234567e+11\""); 294shouldBe("Number(1234567890123.456789012).toExponential()","\"1.2345678901234568e+12\""); 295shouldBe("Number(12345678901234.56789012).toExponential()","\"1.2345678901234568e+13\""); 296shouldBe("Number(123456789012345.6789012).toExponential()","\"1.2345678901234567e+14\""); 297shouldBe("Number(1234567890123456.789012).toExponential()","\"1.2345678901234568e+15\""); 298shouldBe("Number(12345678901234567.89012).toExponential()","\"1.2345678901234568e+16\""); 299shouldBe("Number(123456789012345678.9012).toExponential()","\"1.2345678901234568e+17\""); 300shouldBe("Number(1234567890123456789.012).toExponential()","\"1.2345678901234568e+18\""); 301shouldBe("Number(12345678901234567890.12).toExponential()","\"1.2345678901234567e+19\""); 302shouldBe("Number(123456789012345678901.2).toExponential()","\"1.2345678901234568e+20\""); 303shouldBe("Number(-.0000000000000000000001).toExponential()","\"-1e-22\""); 304shouldBe("Number(-.0000000000000000000012).toExponential()","\"-1.2e-21\""); 305shouldBe("Number(-.0000000000000000000123).toExponential()","\"-1.23e-20\""); 306shouldBe("Number(-.0000000000000000000123).toExponential()","\"-1.23e-20\""); 307shouldBe("Number(-.0000000000000000001234).toExponential()","\"-1.234e-19\""); 308shouldBe("Number(-.0000000000000000012345).toExponential()","\"-1.2345e-18\""); 309shouldBe("Number(-.0000000000000000123456).toExponential()","\"-1.23456e-17\""); 310shouldBe("Number(-.0000000000000001234567).toExponential()","\"-1.234567e-16\""); 311shouldBe("Number(-.0000000000000012345678).toExponential()","\"-1.2345678e-15\""); 312shouldBe("Number(-.0000000000000123456789).toExponential()","\"-1.23456789e-14\""); 313shouldBe("Number(-.0000000000001234567890).toExponential()","\"-1.23456789e-13\""); 314shouldBe("Number(-.0000000000012345678901).toExponential()","\"-1.2345678901e-12\""); 315shouldBe("Number(-.0000000000123456789012).toExponential()","\"-1.23456789012e-11\""); 316shouldBe("Number(-.0000000001234567890123).toExponential()","\"-1.234567890123e-10\""); 317shouldBe("Number(-.0000000012345678901234).toExponential()","\"-1.2345678901234e-9\""); 318shouldBe("Number(-.0000000123456789012345).toExponential()","\"-1.23456789012345e-8\""); 319shouldBe("Number(-.0000001234567890123456).toExponential()","\"-1.234567890123456e-7\""); 320shouldBe("Number(-.0000012345678901234567).toExponential()","\"-1.2345678901234567e-6\""); 321shouldBe("Number(-.0000123456789012345678).toExponential()","\"-1.2345678901234568e-5\""); 322shouldBe("Number(-.0001234567890123456789).toExponential()","\"-1.2345678901234567e-4\""); 323shouldBe("Number(-.0012345678901234567890).toExponential()","\"-1.2345678901234567e-3\""); 324shouldBe("Number(-.0123456789012345678901).toExponential()","\"-1.2345678901234568e-2\""); 325shouldBe("Number(-1.234567890123456789012).toExponential()","\"-1.2345678901234567e+0\""); 326shouldBe("Number(-12.34567890123456789012).toExponential()","\"-1.2345678901234567e+1\""); 327shouldBe("Number(-123.4567890123456789012).toExponential()","\"-1.2345678901234568e+2\""); 328shouldBe("Number(-1234.567890123456789012).toExponential()","\"-1.234567890123457e+3\""); 329shouldBe("Number(-12345.67890123456789012).toExponential()","\"-1.2345678901234567e+4\""); 330shouldBe("Number(-123456.7890123456789012).toExponential()","\"-1.2345678901234567e+5\""); 331shouldBe("Number(-1234567.890123456789012).toExponential()","\"-1.2345678901234567e+6\""); 332shouldBe("Number(-12345678.90123456789012).toExponential()","\"-1.2345678901234567e+7\""); 333shouldBe("Number(-123456789.0123456789012).toExponential()","\"-1.2345678901234567e+8\""); 334shouldBe("Number(-1234567890.123456789012).toExponential()","\"-1.2345678901234567e+9\""); 335shouldBe("Number(-12345678901.23456789012).toExponential()","\"-1.2345678901234568e+10\""); 336shouldBe("Number(-123456789012.3456789012).toExponential()","\"-1.2345678901234567e+11\""); 337shouldBe("Number(-1234567890123.456789012).toExponential()","\"-1.2345678901234568e+12\""); 338shouldBe("Number(-12345678901234.56789012).toExponential()","\"-1.2345678901234568e+13\""); 339shouldBe("Number(-123456789012345.6789012).toExponential()","\"-1.2345678901234567e+14\""); 340shouldBe("Number(-1234567890123456.789012).toExponential()","\"-1.2345678901234568e+15\""); 341shouldBe("Number(-12345678901234567.89012).toExponential()","\"-1.2345678901234568e+16\""); 342shouldBe("Number(-123456789012345678.9012).toExponential()","\"-1.2345678901234568e+17\""); 343shouldBe("Number(-1234567890123456789.012).toExponential()","\"-1.2345678901234568e+18\""); 344shouldBe("Number(-12345678901234567890.12).toExponential()","\"-1.2345678901234567e+19\""); 345shouldBe("Number(-123456789012345678901.2).toExponential()","\"-1.2345678901234568e+20\""); 346 347shouldBeTrue("try { Number(1).toPrecision(-1); } catch (e) { String(e).indexOf('Range') >= 0; }"); 348shouldBeTrue("try { Number(1).toPrecision(0); } catch (e) { String(e).indexOf('Range') >= 0; }"); 349shouldBe("try { Number(1).toPrecision(1); } catch (e) { String(e); }","\"1\""); 350shouldBe("try { Number(1).toPrecision(21); } catch (e) { String(e); }","\"1.00000000000000000000\""); 351shouldBeTrue("try { Number(1).toPrecision(22); } catch (e) { String(e).indexOf('Range') >= 0; }"); 352shouldBe("Number(NaN).toPrecision()","\"NaN\""); 353shouldBe("Number(NaN).toPrecision(1)","\"NaN\""); 354shouldBe("Number(Infinity).toPrecision()","\"Infinity\""); 355shouldBe("Number(Infinity).toPrecision(1)","\"Infinity\""); 356shouldBe("Number(-Infinity).toPrecision()","\"-Infinity\""); 357shouldBe("Number(-Infinity).toPrecision(1)","\"-Infinity\""); 358shouldBe("Number(.0000000012345).toPrecision(2)","\"1.2e-9\""); 359shouldBe("Number(.000000012345).toPrecision(2)","\"1.2e-8\""); 360shouldBe("Number(.00000012345).toPrecision(2)","\"1.2e-7\""); 361shouldBe("Number(.0000012345).toPrecision(2)","\"0.0000012\""); 362shouldBe("Number(.000012345).toPrecision(2)","\"0.000012\""); 363shouldBe("Number(.00012345).toPrecision(2)","\"0.00012\""); 364shouldBe("Number(.0012345).toPrecision(2)","\"0.0012\""); 365shouldBe("Number(.012345).toPrecision(2)","\"0.012\""); 366shouldBe("Number(.12345).toPrecision(2)","\"0.12\""); 367shouldBe("Number(1.2345).toPrecision(2)","\"1.2\""); 368shouldBe("Number(12.345).toPrecision(2)","\"12\""); 369shouldBe("Number(123.45).toPrecision(2)","\"1.2e+2\""); 370shouldBe("Number(1234.5).toPrecision(2)","\"1.2e+3\""); 371shouldBe("Number(12345).toPrecision(2)","\"1.2e+4\""); 372shouldBe("Number(12345.67).toPrecision(4)","\"1.235e+4\""); 373shouldBe("Number(12344.67).toPrecision(4)","\"1.234e+4\""); 374shouldBe("Number(0.0001234567890123456789012345).toPrecision()","\"0.00012345678901234567\""); 375shouldBe("Number(0.0001234567890123456789012345).toPrecision(1)","\"0.0001\""); 376shouldBe("Number(0.0001234567890123456789012345).toPrecision(2)","\"0.00012\""); 377shouldBe("Number(0.0001234567890123456789012345).toPrecision(3)","\"0.000123\""); 378shouldBe("Number(0.0001234567890123456789012345).toPrecision(4)","\"0.0001235\""); 379shouldBe("Number(0.0001234567890123456789012345).toPrecision(5)","\"0.00012346\""); 380shouldBe("Number(0.0001234567890123456789012345).toPrecision(6)","\"0.000123457\""); 381shouldBe("Number(0.0001234567890123456789012345).toPrecision(7)","\"0.0001234568\""); 382shouldBe("Number(0.0001234567890123456789012345).toPrecision(8)","\"0.00012345679\""); 383shouldBe("Number(0.0001234567890123456789012345).toPrecision(9)","\"0.000123456789\""); 384shouldBe("Number(0.0001234567890123456789012345).toPrecision(10)","\"0.0001234567890\""); 385shouldBe("Number(0.0001234567890123456789012345).toPrecision(11)","\"0.00012345678901\""); 386shouldBe("Number(0.0001234567890123456789012345).toPrecision(12)","\"0.000123456789012\""); 387shouldBe("Number(0.0001234567890123456789012345).toPrecision(13)","\"0.0001234567890123\""); 388shouldBe("Number(0.0001234567890123456789012345).toPrecision(14)","\"0.00012345678901235\""); 389shouldBe("Number(0.0001234567890123456789012345).toPrecision(15)","\"0.000123456789012346\""); 390shouldBe("Number(0.0001234567890123456789012345).toPrecision(16)","\"0.0001234567890123457\""); 391shouldBe("Number(0.0001234567890123456789012345).toPrecision(17)","\"0.00012345678901234567\""); 392shouldBe("Number(0.0001234567890123456789012345).toPrecision(18)","\"0.000123456789012345671\""); 393shouldBe("Number(0.0001234567890123456789012345).toPrecision(19)","\"0.0001234567890123456713\""); 394shouldBe("Number(0.0001234567890123456789012345).toPrecision(20)","\"0.00012345678901234567130\""); 395shouldBe("Number(0.0001234567890123456789012345).toPrecision(21)","\"0.000123456789012345671298\""); 396shouldBe("Number(12345.67890123456789012345).toPrecision()","\"12345.678901234567\""); 397shouldBe("Number(12345.67890123456789012345).toPrecision(1)","\"1e+4\""); 398shouldBe("Number(12345.67890123456789012345).toPrecision(2)","\"1.2e+4\""); 399shouldBe("Number(12345.67890123456789012345).toPrecision(3)","\"1.23e+4\""); 400shouldBe("Number(12345.67890123456789012345).toPrecision(4)","\"1.235e+4\""); 401shouldBe("Number(12345.67890123456789012345).toPrecision(5)","\"12346\""); 402shouldBe("Number(12345.67890123456789012345).toPrecision(6)","\"12345.7\""); 403shouldBe("Number(12345.67890123456789012345).toPrecision(7)","\"12345.68\""); 404shouldBe("Number(12345.67890123456789012345).toPrecision(8)","\"12345.679\""); 405shouldBe("Number(12345.67890123456789012345).toPrecision(9)","\"12345.6789\""); 406shouldBe("Number(12345.67890123456789012345).toPrecision(10)","\"12345.67890\""); 407shouldBe("Number(12345.67890123456789012345).toPrecision(11)","\"12345.678901\""); 408shouldBe("Number(12345.67890123456789012345).toPrecision(12)","\"12345.6789012\""); 409shouldBe("Number(12345.67890123456789012345).toPrecision(13)","\"12345.67890123\""); 410shouldBe("Number(12345.67890123456789012345).toPrecision(14)","\"12345.678901235\""); 411shouldBe("Number(12345.67890123456789012345).toPrecision(15)","\"12345.6789012346\""); 412shouldBe("Number(12345.67890123456789012345).toPrecision(16)","\"12345.67890123457\""); 413shouldBe("Number(12345.67890123456789012345).toPrecision(17)","\"12345.678901234567\""); 414shouldBe("Number(12345.67890123456789012345).toPrecision(18)","\"12345.6789012345671\""); 415shouldBe("Number(12345.67890123456789012345).toPrecision(19)","\"12345.67890123456709\""); 416shouldBe("Number(12345.67890123456789012345).toPrecision(20)","\"12345.678901234567093\""); 417shouldBe("Number(12345.67890123456789012345).toPrecision(21)","\"12345.6789012345670926\""); 418shouldBe("Number(-.0000000012345).toPrecision(2)","\"-1.2e-9\""); 419shouldBe("Number(-.000000012345).toPrecision(2)","\"-1.2e-8\""); 420shouldBe("Number(-.00000012345).toPrecision(2)","\"-1.2e-7\""); 421shouldBe("Number(-.0000012345).toPrecision(2)","\"-0.0000012\""); 422shouldBe("Number(-.000012345).toPrecision(2)","\"-0.000012\""); 423shouldBe("Number(-.00012345).toPrecision(2)","\"-0.00012\""); 424shouldBe("Number(-.0012345).toPrecision(2)","\"-0.0012\""); 425shouldBe("Number(-.012345).toPrecision(2)","\"-0.012\""); 426shouldBe("Number(-.12345).toPrecision(2)","\"-0.12\""); 427shouldBe("Number(-1.2345).toPrecision(2)","\"-1.2\""); 428shouldBe("Number(-12.345).toPrecision(2)","\"-12\""); 429shouldBe("Number(-123.45).toPrecision(2)","\"-1.2e+2\""); 430shouldBe("Number(-1234.5).toPrecision(2)","\"-1.2e+3\""); 431shouldBe("Number(-12345).toPrecision(2)","\"-1.2e+4\""); 432shouldBe("Number(-12345.67).toPrecision(4)","\"-1.235e+4\""); 433shouldBe("Number(-12344.67).toPrecision(4)","\"-1.234e+4\""); 434shouldBe("Number(-0.0001234567890123456789012345).toPrecision()","\"-0.00012345678901234567\""); 435shouldBe("Number(-0.0001234567890123456789012345).toPrecision(1)","\"-0.0001\""); 436shouldBe("Number(-0.0001234567890123456789012345).toPrecision(2)","\"-0.00012\""); 437shouldBe("Number(-0.0001234567890123456789012345).toPrecision(3)","\"-0.000123\""); 438shouldBe("Number(-0.0001234567890123456789012345).toPrecision(4)","\"-0.0001235\""); 439shouldBe("Number(-0.0001234567890123456789012345).toPrecision(5)","\"-0.00012346\""); 440shouldBe("Number(-0.0001234567890123456789012345).toPrecision(6)","\"-0.000123457\""); 441shouldBe("Number(-0.0001234567890123456789012345).toPrecision(7)","\"-0.0001234568\""); 442shouldBe("Number(-0.0001234567890123456789012345).toPrecision(8)","\"-0.00012345679\""); 443shouldBe("Number(-0.0001234567890123456789012345).toPrecision(9)","\"-0.000123456789\""); 444shouldBe("Number(-0.0001234567890123456789012345).toPrecision(10)","\"-0.0001234567890\""); 445shouldBe("Number(-0.0001234567890123456789012345).toPrecision(11)","\"-0.00012345678901\""); 446shouldBe("Number(-0.0001234567890123456789012345).toPrecision(12)","\"-0.000123456789012\""); 447shouldBe("Number(-0.0001234567890123456789012345).toPrecision(13)","\"-0.0001234567890123\""); 448shouldBe("Number(-0.0001234567890123456789012345).toPrecision(14)","\"-0.00012345678901235\""); 449shouldBe("Number(-0.0001234567890123456789012345).toPrecision(15)","\"-0.000123456789012346\""); 450shouldBe("Number(-0.0001234567890123456789012345).toPrecision(16)","\"-0.0001234567890123457\""); 451shouldBe("Number(-0.0001234567890123456789012345).toPrecision(17)","\"-0.00012345678901234567\""); 452shouldBe("Number(-0.0001234567890123456789012345).toPrecision(18)","\"-0.000123456789012345671\""); 453shouldBe("Number(-0.0001234567890123456789012345).toPrecision(19)","\"-0.0001234567890123456713\""); 454shouldBe("Number(-0.0001234567890123456789012345).toPrecision(20)","\"-0.00012345678901234567130\""); 455shouldBe("Number(-0.0001234567890123456789012345).toPrecision(21)","\"-0.000123456789012345671298\""); 456shouldBe("Number(-12345.67890123456789012345).toPrecision()","\"-12345.678901234567\""); 457shouldBe("Number(-12345.67890123456789012345).toPrecision(1)","\"-1e+4\""); 458shouldBe("Number(-12345.67890123456789012345).toPrecision(2)","\"-1.2e+4\""); 459shouldBe("Number(-12345.67890123456789012345).toPrecision(3)","\"-1.23e+4\""); 460shouldBe("Number(-12345.67890123456789012345).toPrecision(4)","\"-1.235e+4\""); 461shouldBe("Number(-12345.67890123456789012345).toPrecision(5)","\"-12346\""); 462shouldBe("Number(-12345.67890123456789012345).toPrecision(6)","\"-12345.7\""); 463shouldBe("Number(-12345.67890123456789012345).toPrecision(7)","\"-12345.68\""); 464shouldBe("Number(-12345.67890123456789012345).toPrecision(8)","\"-12345.679\""); 465shouldBe("Number(-12345.67890123456789012345).toPrecision(9)","\"-12345.6789\""); 466shouldBe("Number(-12345.67890123456789012345).toPrecision(10)","\"-12345.67890\""); 467shouldBe("Number(-12345.67890123456789012345).toPrecision(11)","\"-12345.678901\""); 468shouldBe("Number(-12345.67890123456789012345).toPrecision(12)","\"-12345.6789012\""); 469shouldBe("Number(-12345.67890123456789012345).toPrecision(13)","\"-12345.67890123\""); 470shouldBe("Number(-12345.67890123456789012345).toPrecision(14)","\"-12345.678901235\""); 471shouldBe("Number(-12345.67890123456789012345).toPrecision(15)","\"-12345.6789012346\""); 472shouldBe("Number(-12345.67890123456789012345).toPrecision(16)","\"-12345.67890123457\""); 473shouldBe("Number(-12345.67890123456789012345).toPrecision(17)","\"-12345.678901234567\""); 474shouldBe("Number(-12345.67890123456789012345).toPrecision(18)","\"-12345.6789012345671\""); 475shouldBe("Number(-12345.67890123456789012345).toPrecision(19)","\"-12345.67890123456709\""); 476shouldBe("Number(-12345.67890123456789012345).toPrecision(20)","\"-12345.678901234567093\""); 477shouldBe("Number(-12345.67890123456789012345).toPrecision(21)","\"-12345.6789012345670926\""); 478shouldBe("Number(0).toPrecision()","\"0\""); 479shouldBe("Number(0).toPrecision(1)","\"0\""); 480shouldBe("Number(0).toPrecision(2)","\"0.0\""); 481shouldBe("Number(0).toPrecision(3)","\"0.00\""); 482shouldBe("Number(0).toPrecision(4)","\"0.000\""); 483shouldBe("Number(0).toPrecision(5)","\"0.0000\""); 484shouldBe("Number(0).toPrecision(6)","\"0.00000\""); 485shouldBe("Number(0).toPrecision(7)","\"0.000000\""); 486shouldBe("Number(0).toPrecision(8)","\"0.0000000\""); 487shouldBe("Number(0).toPrecision(9)","\"0.00000000\""); 488shouldBe("Number(0).toPrecision(10)","\"0.000000000\""); 489shouldBe("Number(0).toPrecision(11)","\"0.0000000000\""); 490shouldBe("Number(0).toPrecision(12)","\"0.00000000000\""); 491shouldBe("Number(0).toPrecision(13)","\"0.000000000000\""); 492shouldBe("Number(0).toPrecision(14)","\"0.0000000000000\""); 493shouldBe("Number(0).toPrecision(15)","\"0.00000000000000\""); 494shouldBe("Number(0).toPrecision(16)","\"0.000000000000000\""); 495shouldBe("Number(0).toPrecision(17)","\"0.0000000000000000\""); 496shouldBe("Number(0).toPrecision(18)","\"0.00000000000000000\""); 497shouldBe("Number(0).toPrecision(19)","\"0.000000000000000000\""); 498shouldBe("Number(0).toPrecision(20)","\"0.0000000000000000000\""); 499shouldBe("Number(0).toPrecision(21)","\"0.00000000000000000000\""); 500