js/src/tests/ecma/Math/15.8.2.17.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /**
michael@0 8 File Name: 15.8.2.17.js
michael@0 9 ECMA Section: 15.8.2.17 Math.sqrt(x)
michael@0 10 Description: return an approximation to the squareroot of the argument.
michael@0 11 special cases:
michael@0 12 - if x is NaN return NaN
michael@0 13 - if x < 0 return NaN
michael@0 14 - if x == 0 return 0
michael@0 15 - if x == -0 return -0
michael@0 16 - if x == Infinity return Infinity
michael@0 17 Author: christine@netscape.com
michael@0 18 Date: 7 july 1997
michael@0 19 */
michael@0 20
michael@0 21 var SECTION = "15.8.2.17";
michael@0 22 var VERSION = "ECMA_1";
michael@0 23 startTest();
michael@0 24 var TITLE = "Math.sqrt(x)";
michael@0 25
michael@0 26 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 27
michael@0 28 new TestCase( SECTION,
michael@0 29 "Math.sqrt.length",
michael@0 30 1,
michael@0 31 Math.sqrt.length );
michael@0 32
michael@0 33 new TestCase( SECTION,
michael@0 34 "Math.sqrt()",
michael@0 35 Number.NaN,
michael@0 36 Math.sqrt() );
michael@0 37
michael@0 38 new TestCase( SECTION,
michael@0 39 "Math.sqrt(void 0)",
michael@0 40 Number.NaN,
michael@0 41 Math.sqrt(void 0) );
michael@0 42
michael@0 43 new TestCase( SECTION,
michael@0 44 "Math.sqrt(null)",
michael@0 45 0,
michael@0 46 Math.sqrt(null) );
michael@0 47
michael@0 48 new TestCase( SECTION,
michael@0 49 "Math.sqrt(true)",
michael@0 50 1,
michael@0 51 Math.sqrt(1) );
michael@0 52
michael@0 53 new TestCase( SECTION,
michael@0 54 "Math.sqrt(false)",
michael@0 55 0,
michael@0 56 Math.sqrt(false) );
michael@0 57
michael@0 58 new TestCase( SECTION,
michael@0 59 "Math.sqrt('225')",
michael@0 60 15,
michael@0 61 Math.sqrt('225') );
michael@0 62
michael@0 63 new TestCase( SECTION,
michael@0 64 "Math.sqrt(NaN)",
michael@0 65 Number.NaN,
michael@0 66 Math.sqrt(Number.NaN) );
michael@0 67
michael@0 68 new TestCase( SECTION,
michael@0 69 "Math.sqrt(-Infinity)",
michael@0 70 Number.NaN,
michael@0 71 Math.sqrt(Number.NEGATIVE_INFINITY));
michael@0 72
michael@0 73 new TestCase( SECTION,
michael@0 74 "Math.sqrt(-1)",
michael@0 75 Number.NaN,
michael@0 76 Math.sqrt(-1));
michael@0 77
michael@0 78 new TestCase( SECTION,
michael@0 79 "Math.sqrt(-0.5)",
michael@0 80 Number.NaN,
michael@0 81 Math.sqrt(-0.5));
michael@0 82
michael@0 83 new TestCase( SECTION,
michael@0 84 "Math.sqrt(0)",
michael@0 85 0,
michael@0 86 Math.sqrt(0));
michael@0 87
michael@0 88 new TestCase( SECTION,
michael@0 89 "Math.sqrt(-0)",
michael@0 90 -0,
michael@0 91 Math.sqrt(-0));
michael@0 92
michael@0 93 new TestCase( SECTION,
michael@0 94 "Infinity/Math.sqrt(-0)",
michael@0 95 -Infinity,
michael@0 96 Infinity/Math.sqrt(-0) );
michael@0 97
michael@0 98 new TestCase( SECTION,
michael@0 99 "Math.sqrt(Infinity)",
michael@0 100 Number.POSITIVE_INFINITY,
michael@0 101 Math.sqrt(Number.POSITIVE_INFINITY));
michael@0 102
michael@0 103 new TestCase( SECTION,
michael@0 104 "Math.sqrt(1)",
michael@0 105 1,
michael@0 106 Math.sqrt(1));
michael@0 107
michael@0 108 new TestCase( SECTION,
michael@0 109 "Math.sqrt(2)",
michael@0 110 Math.SQRT2,
michael@0 111 Math.sqrt(2));
michael@0 112
michael@0 113 new TestCase( SECTION,
michael@0 114 "Math.sqrt(0.5)",
michael@0 115 Math.SQRT1_2,
michael@0 116 Math.sqrt(0.5));
michael@0 117
michael@0 118 new TestCase( SECTION,
michael@0 119 "Math.sqrt(4)",
michael@0 120 2,
michael@0 121 Math.sqrt(4));
michael@0 122
michael@0 123 new TestCase( SECTION,
michael@0 124 "Math.sqrt(9)",
michael@0 125 3,
michael@0 126 Math.sqrt(9));
michael@0 127
michael@0 128 new TestCase( SECTION,
michael@0 129 "Math.sqrt(16)",
michael@0 130 4,
michael@0 131 Math.sqrt(16));
michael@0 132
michael@0 133 new TestCase( SECTION,
michael@0 134 "Math.sqrt(25)",
michael@0 135 5,
michael@0 136 Math.sqrt(25));
michael@0 137
michael@0 138 new TestCase( SECTION,
michael@0 139 "Math.sqrt(36)",
michael@0 140 6,
michael@0 141 Math.sqrt(36));
michael@0 142
michael@0 143 new TestCase( SECTION,
michael@0 144 "Math.sqrt(49)",
michael@0 145 7,
michael@0 146 Math.sqrt(49));
michael@0 147
michael@0 148 new TestCase( SECTION,
michael@0 149 "Math.sqrt(64)",
michael@0 150 8,
michael@0 151 Math.sqrt(64));
michael@0 152
michael@0 153 new TestCase( SECTION,
michael@0 154 "Math.sqrt(256)",
michael@0 155 16,
michael@0 156 Math.sqrt(256));
michael@0 157
michael@0 158 new TestCase( SECTION,
michael@0 159 "Math.sqrt(10000)",
michael@0 160 100,
michael@0 161 Math.sqrt(10000));
michael@0 162
michael@0 163 new TestCase( SECTION,
michael@0 164 "Math.sqrt(65536)",
michael@0 165 256,
michael@0 166 Math.sqrt(65536));
michael@0 167
michael@0 168 new TestCase( SECTION,
michael@0 169 "Math.sqrt(0.09)",
michael@0 170 0.3,
michael@0 171 Math.sqrt(0.09));
michael@0 172
michael@0 173 new TestCase( SECTION,
michael@0 174 "Math.sqrt(0.01)",
michael@0 175 0.1,
michael@0 176 Math.sqrt(0.01));
michael@0 177
michael@0 178 new TestCase( SECTION,
michael@0 179 "Math.sqrt(0.00000001)",
michael@0 180 0.0001,
michael@0 181 Math.sqrt(0.00000001));
michael@0 182
michael@0 183 test();

mercurial