diff options
Diffstat (limited to 'js/src/tests/ecma/Math')
40 files changed, 3651 insertions, 0 deletions
diff --git a/js/src/tests/ecma/Math/15.8-2-n.js b/js/src/tests/ecma/Math/15.8-2-n.js new file mode 100644 index 000000000..9915f64e1 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8-2-n.js @@ -0,0 +1,48 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8-2.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + +var SECTION = "15.8-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Math Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "MYMATH = new Math()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "MYMATH = new Math()", + "error", + eval("MYMATH = new Math()") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8-3-n.js b/js/src/tests/ecma/Math/15.8-3-n.js new file mode 100644 index 000000000..eb238069b --- /dev/null +++ b/js/src/tests/ecma/Math/15.8-3-n.js @@ -0,0 +1,47 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8-3.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.8-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Math Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "MYMATH = Math()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "MYMATH = Math()", + "error", + eval("MYMATH = Math()") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.1-1.js b/js/src/tests/ecma/Math/15.8.1.1-1.js new file mode 100644 index 000000000..9b21b00a4 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.1-1.js @@ -0,0 +1,30 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.1-1.js + ECMA Section: 15.8.1.1.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.E = 0; Math.E", + 2.7182818284590452354, + eval("Math.E=0;Math.E") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.1-2.js b/js/src/tests/ecma/Math/15.8.1.1-2.js new file mode 100644 index 000000000..6efa56bd5 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.1-2.js @@ -0,0 +1,35 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.1-2.js + ECMA Section: 15.8.1.1.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MATH_E = 2.7182818284590452354 + new TestCase( SECTION, + "delete(Math.E)", + false, + eval("delete Math.E") ); +new TestCase( SECTION, + "delete(Math.E); Math.E", + MATH_E, + eval("delete Math.E; Math.E") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.2-1.js b/js/src/tests/ecma/Math/15.8.1.2-1.js new file mode 100644 index 000000000..558914e2c --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.2-1.js @@ -0,0 +1,30 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.2-1.js + ECMA Section: 15.8.2.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LN10 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN10"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.LN10=0; Math.LN10", + 2.302585092994046, + eval("Math.LN10=0; Math.LN10") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.2-2.js b/js/src/tests/ecma/Math/15.8.1.2-2.js new file mode 100644 index 000000000..0f161492f --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.2-2.js @@ -0,0 +1,36 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.2-1.js + ECMA Section: 15.8.2.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LN10 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN10"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete( Math.LN10 ); Math.LN10", + 2.302585092994046, + eval("delete(Math.LN10); Math.LN10") ); + +new TestCase( SECTION, + "delete( Math.LN10 ); ", + false, + eval("delete(Math.LN10)") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.3-1.js b/js/src/tests/ecma/Math/15.8.1.3-1.js new file mode 100644 index 000000000..63dbea87d --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.3-1.js @@ -0,0 +1,31 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.3-1.js + ECMA Section: 15.8.1.3.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LN2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.LN2=0; Math.LN2", + 0.6931471805599453, + eval("Math.LN2=0; Math.LN2") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.3-2.js b/js/src/tests/ecma/Math/15.8.1.3-2.js new file mode 100644 index 000000000..d9c71bfa4 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.3-2.js @@ -0,0 +1,38 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.3-3.js + ECMA Section: 15.8.1.3.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LN2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MATH_LN2 = 0.6931471805599453; + +new TestCase( SECTION, + "delete(Math.LN2)", + false, + eval("delete(Math.LN2)") ); + +new TestCase( SECTION, + "delete(Math.LN2); Math.LN2", + MATH_LN2, + eval("delete(Math.LN2); Math.LN2") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.4-1.js b/js/src/tests/ecma/Math/15.8.1.4-1.js new file mode 100644 index 000000000..d29d114e9 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.4-1.js @@ -0,0 +1,31 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.4-1.js + ECMA Section: 15.8.1.4.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LOG2E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LOG2E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.L0G2E=0; Math.LOG2E", + 1.4426950408889634, + eval("Math.LOG2E=0; Math.LOG2E") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.4-2.js b/js/src/tests/ecma/Math/15.8.1.4-2.js new file mode 100644 index 000000000..ff4620867 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.4-2.js @@ -0,0 +1,35 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.4-2.js + ECMA Section: 15.8.1.4.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LOG2E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.4-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LOG2E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete(Math.L0G2E);Math.LOG2E", + 1.4426950408889634, + eval("delete(Math.LOG2E);Math.LOG2E") ); +new TestCase( SECTION, + "delete(Math.L0G2E)", + false, + eval("delete(Math.LOG2E)") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.5-1.js b/js/src/tests/ecma/Math/15.8.1.5-1.js new file mode 100644 index 000000000..4f83a1ad4 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.5-1.js @@ -0,0 +1,32 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.5-1.js + ECMA Section: 15.8.1.5.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LOG10E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.8.1.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LOG10E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.LOG10E=0; Math.LOG10E", + 0.4342944819032518, + eval("Math.LOG10E=0; Math.LOG10E") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.5-2.js b/js/src/tests/ecma/Math/15.8.1.5-2.js new file mode 100644 index 000000000..3203f0bcf --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.5-2.js @@ -0,0 +1,36 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.5-2.js + ECMA Section: 15.8.1.5.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LOG10E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LOG10E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete Math.LOG10E; Math.LOG10E", + 0.4342944819032518, + eval("delete Math.LOG10E; Math.LOG10E") ); + +new TestCase( SECTION, + "delete Math.LOG10E", + false, + eval("delete Math.LOG10E") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.6-1.js b/js/src/tests/ecma/Math/15.8.1.6-1.js new file mode 100644 index 000000000..4a3fa1b19 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.6-1.js @@ -0,0 +1,31 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.6-1.js + ECMA Section: 15.8.1.6.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.PI + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.PI"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.PI=0; Math.PI", + 3.1415926535897923846, + eval("Math.PI=0; Math.PI") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.6-2.js b/js/src/tests/ecma/Math/15.8.1.6-2.js new file mode 100644 index 000000000..ad5fe3dfd --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.6-2.js @@ -0,0 +1,36 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.6-2.js + ECMA Section: 15.8.1.6.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.PI + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.6-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.PI"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete Math.PI; Math.PI", + 3.1415926535897923846, + eval("delete Math.PI; Math.PI") ); + +new TestCase( SECTION, + "delete Math.PI; Math.PI", + false, + eval("delete Math.PI") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.7-1.js b/js/src/tests/ecma/Math/15.8.1.7-1.js new file mode 100644 index 000000000..bb41c1d1a --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.7-1.js @@ -0,0 +1,31 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.7-1.js + ECMA Section: 15.8.1.7.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.SQRT1_2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.7-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT1_2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.SQRT1_2=0; Math.SQRT1_2", + 0.7071067811865476, + eval("Math.SQRT1_2=0; Math.SQRT1_2") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.7-2.js b/js/src/tests/ecma/Math/15.8.1.7-2.js new file mode 100644 index 000000000..0c931e734 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.7-2.js @@ -0,0 +1,36 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.7-2.js + ECMA Section: 15.8.1.7.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT1_2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.7-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT1_2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete Math.SQRT1_2; Math.SQRT1_2", + 0.7071067811865476, + eval("delete Math.SQRT1_2; Math.SQRT1_2") ); + +new TestCase( SECTION, + "delete Math.SQRT1_2", + false, + eval("delete Math.SQRT1_2") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.8-1.js b/js/src/tests/ecma/Math/15.8.1.8-1.js new file mode 100644 index 000000000..6f9b4b982 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.8-1.js @@ -0,0 +1,31 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.8-1.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.8-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.SQRT2=0; Math.SQRT2", + 1.4142135623730951, + eval("Math.SQRT2=0; Math.SQRT2") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.8-2.js b/js/src/tests/ecma/Math/15.8.1.8-2.js new file mode 100644 index 000000000..c276ab9bf --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.8-2.js @@ -0,0 +1,35 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.8-2.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.8-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete Math.SQRT2; Math.SQRT2", + 1.4142135623730951, + eval("delete Math.SQRT2; Math.SQRT2") ); + +new TestCase( SECTION, + "delete Math.SQRT2", + false, + eval("delete Math.SQRT2") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.8-3.js b/js/src/tests/ecma/Math/15.8.1.8-3.js new file mode 100644 index 000000000..eae3d9455 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.8-3.js @@ -0,0 +1,29 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.8-3.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.8-3"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Math.SQRT2: DontDelete"); + +new TestCase( SECTION, + "delete Math.SQRT2", + false, + eval("delete Math.SQRT2") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.1.js b/js/src/tests/ecma/Math/15.8.1.js new file mode 100644 index 000000000..3105fefb3 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.1.js @@ -0,0 +1,115 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.1.js + ECMA Section: 15.8.1.js Value Properties of the Math Object + 15.8.1.1 E + 15.8.1.2 LN10 + 15.8.1.3 LN2 + 15.8.1.4 LOG2E + 15.8.1.5 LOG10E + 15.8.1.6 PI + 15.8.1.7 SQRT1_2 + 15.8.1.8 SQRT2 + Description: verify the values of some math constants + Author: christine@netscape.com + Date: 7 july 1997 + +*/ +var SECTION = "15.8.1" + var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Value Properties of the Math Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( "15.8.1.1", "Math.E", + 2.7182818284590452354, + Math.E ); + +new TestCase( "15.8.1.1", + "typeof Math.E", + "number", + typeof Math.E ); + +new TestCase( "15.8.1.2", + "Math.LN10", + 2.302585092994046, + Math.LN10 ); + +new TestCase( "15.8.1.2", + "typeof Math.LN10", + "number", + typeof Math.LN10 ); + +new TestCase( "15.8.1.3", + "Math.LN2", + 0.6931471805599453, + Math.LN2 ); + +new TestCase( "15.8.1.3", + "typeof Math.LN2", + "number", + typeof Math.LN2 ); + +new TestCase( "15.8.1.4", + "Math.LOG2E", + 1.4426950408889634, + Math.LOG2E ); + +new TestCase( "15.8.1.4", + "typeof Math.LOG2E", + "number", + typeof Math.LOG2E ); + +new TestCase( "15.8.1.5", + "Math.LOG10E", + 0.4342944819032518, + Math.LOG10E); + +new TestCase( "15.8.1.5", + "typeof Math.LOG10E", + "number", + typeof Math.LOG10E); + +new TestCase( "15.8.1.6", + "Math.PI", + 3.14159265358979323846, + Math.PI ); + +new TestCase( "15.8.1.6", + "typeof Math.PI", + "number", + typeof Math.PI ); + +new TestCase( "15.8.1.7", + "Math.SQRT1_2", + 0.7071067811865476, + Math.SQRT1_2); + +new TestCase( "15.8.1.7", + "typeof Math.SQRT1_2", + "number", + typeof Math.SQRT1_2); + +new TestCase( "15.8.1.8", + "Math.SQRT2", + 1.4142135623730951, + Math.SQRT2 ); + +new TestCase( "15.8.1.8", + "typeof Math.SQRT2", + "number", + typeof Math.SQRT2 ); + +new TestCase( SECTION, + "var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS", + "", + eval("var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS") ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.1.js b/js/src/tests/ecma/Math/15.8.2.1.js new file mode 100644 index 000000000..d5ea49470 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.1.js @@ -0,0 +1,192 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.1.js + ECMA Section: 15.8.2.1 abs( x ) + Description: return the absolute value of the argument, + which should be the magnitude of the argument + with a positive sign. + - if x is NaN, return NaN + - if x is -0, result is +0 + - if x is -Infinity, result is +Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ +var SECTION = "15.8.2.1"; +var VERSION = "ECMA_1"; +var TITLE = "Math.abs()"; +var BUGNUMBER = "77391"; +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.abs.length", + 1, + Math.abs.length ); + +new TestCase( SECTION, + "Math.abs()", + Number.NaN, + Math.abs() ); + +new TestCase( SECTION, + "Math.abs( void 0 )", + Number.NaN, + Math.abs(void 0) ); + +new TestCase( SECTION, + "Math.abs( null )", + 0, + Math.abs(null) ); + +new TestCase( SECTION, + "Math.abs( true )", + 1, + Math.abs(true) ); + +new TestCase( SECTION, + "Math.abs( false )", + 0, + Math.abs(false) ); + +new TestCase( SECTION, + "Math.abs( string primitive)", + Number.NaN, + Math.abs("a string primitive") ); + +new TestCase( SECTION, + "Math.abs( string object )", + Number.NaN, + Math.abs(new String( 'a String object' )) ); + +new TestCase( SECTION, + "Math.abs( Number.NaN )", + Number.NaN, + Math.abs(Number.NaN) ); + +new TestCase( SECTION, + "Math.abs(0)", + 0, + Math.abs( 0 ) ); + +new TestCase( SECTION, + "Math.abs( -0 )", + 0, + Math.abs(-0) ); + +new TestCase( SECTION, + "Infinity/Math.abs(-0)", + Infinity, + Infinity/Math.abs(-0) ); + +new TestCase( SECTION, + "Math.abs( -Infinity )", + Number.POSITIVE_INFINITY, + Math.abs( Number.NEGATIVE_INFINITY ) ); + +new TestCase( SECTION, + "Math.abs( Infinity )", + Number.POSITIVE_INFINITY, + Math.abs( Number.POSITIVE_INFINITY ) ); + +new TestCase( SECTION, + "Math.abs( - MAX_VALUE )", + Number.MAX_VALUE, + Math.abs( - Number.MAX_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( - MIN_VALUE )", + Number.MIN_VALUE, + Math.abs( -Number.MIN_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( MAX_VALUE )", + Number.MAX_VALUE, + Math.abs( Number.MAX_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( MIN_VALUE )", + Number.MIN_VALUE, + Math.abs( Number.MIN_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( -1 )", + 1, + Math.abs( -1 ) ); + +new TestCase( SECTION, + "Math.abs( new Number( -1 ) )", + 1, + Math.abs( new Number(-1) ) ); + +new TestCase( SECTION, + "Math.abs( 1 )", + 1, + Math.abs( 1 ) ); + +new TestCase( SECTION, + "Math.abs( Math.PI )", + Math.PI, + Math.abs( Math.PI ) ); + +new TestCase( SECTION, + "Math.abs( -Math.PI )", + Math.PI, + Math.abs( -Math.PI ) ); + +new TestCase( SECTION, + "Math.abs(-1/100000000)", + 1/100000000, + Math.abs(-1/100000000) ); + +new TestCase( SECTION, + "Math.abs(-Math.pow(2,32))", + Math.pow(2,32), + Math.abs(-Math.pow(2,32)) ); + +new TestCase( SECTION, + "Math.abs(Math.pow(2,32))", + Math.pow(2,32), + Math.abs(Math.pow(2,32)) ); + +new TestCase( SECTION, + "Math.abs( -0xfff )", + 4095, + Math.abs( -0xfff ) ); + +new TestCase( SECTION, + "Math.abs( -0777 )", + 511, + Math.abs(-0777 ) ); + +new TestCase( SECTION, + "Math.abs('-1e-1')", + 0.1, + Math.abs('-1e-1') ); + +new TestCase( SECTION, + "Math.abs('0xff')", + 255, + Math.abs('0xff') ); + +new TestCase( SECTION, + "Math.abs('077')", + 77, + Math.abs('077') ); + +new TestCase( SECTION, + "Math.abs( 'Infinity' )", + Infinity, + Math.abs('Infinity') ); + +new TestCase( SECTION, + "Math.abs( '-Infinity' )", + Infinity, + Math.abs('-Infinity') ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.10.js b/js/src/tests/ecma/Math/15.8.2.10.js new file mode 100644 index 000000000..6b53a1323 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.10.js @@ -0,0 +1,119 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.10.js + ECMA Section: 15.8.2.10 Math.log(x) + Description: return an approximiation to the natural logarithm of + the argument. + special cases: + - if arg is NaN result is NaN + - if arg is <0 result is NaN + - if arg is 0 or -0 result is -Infinity + - if arg is 1 result is 0 + - if arg is Infinity result is Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.10"; +var VERSION = "ECMA_1"; +var TITLE = "Math.log(x)"; +var BUGNUMBER = "77391"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, + "Math.log.length", + 1, + Math.log.length ); + + +new TestCase( SECTION, + "Math.log()", + Number.NaN, + Math.log() ); + +new TestCase( SECTION, + "Math.log(void 0)", + Number.NaN, + Math.log(void 0) ); + +new TestCase( SECTION, + "Math.log(null)", + Number.NEGATIVE_INFINITY, + Math.log(null) ); + +new TestCase( SECTION, + "Math.log(true)", + 0, + Math.log(true) ); + +new TestCase( SECTION, + "Math.log(false)", + -Infinity, + Math.log(false) ); + +new TestCase( SECTION, + "Math.log('0')", + -Infinity, + Math.log('0') ); + +new TestCase( SECTION, + "Math.log('1')", + 0, + Math.log('1') ); + +new TestCase( SECTION, + "Math.log('Infinity')", + Infinity, + Math.log("Infinity") ); + + +new TestCase( SECTION, + "Math.log(NaN)", + Number.NaN, + Math.log(Number.NaN) ); + +new TestCase( SECTION, + "Math.log(-0.0000001)", + Number.NaN, + Math.log(-0.000001) ); + +new TestCase( SECTION, + "Math.log(-1)", + Number.NaN, + Math.log(-1) ); + +new TestCase( SECTION, + "Math.log(0)", + Number.NEGATIVE_INFINITY, + Math.log(0) ); + +new TestCase( SECTION, + "Math.log(-0)", + Number.NEGATIVE_INFINITY, + Math.log(-0)); + +new TestCase( SECTION, + "Math.log(1)", + 0, + Math.log(1) ); + +new TestCase( SECTION, + "Math.log(Infinity)", + Number.POSITIVE_INFINITY, + Math.log(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.log(-Infinity)", + Number.NaN, + Math.log(Number.NEGATIVE_INFINITY) ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.11.js b/js/src/tests/ecma/Math/15.8.2.11.js new file mode 100644 index 000000000..5b3bbfe83 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.11.js @@ -0,0 +1,166 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.11.js + ECMA Section: 15.8.2.11 Math.max(x, y) + Description: return the smaller of the two arguments. + special cases: + - if x is NaN or y is NaN return NaN + - if x < y return x + - if y > x return y + - if x is +0 and y is +0 return +0 + - if x is +0 and y is -0 return -0 + - if x is -0 and y is +0 return -0 + - if x is -0 and y is -0 return -0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.11"; +var VERSION = "ECMA_1"; +var TITLE = "Math.max(x, y)"; +var BUGNUMBER="76439"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.max.length", + 2, + Math.max.length ); + +new TestCase( SECTION, + "Math.max()", + -Infinity, + Math.max() ); + +new TestCase( SECTION, + "Math.max(void 0, 1)", + Number.NaN, + Math.max( void 0, 1 ) ); + +new TestCase( SECTION, + "Math.max(void 0, void 0)", + Number.NaN, + Math.max( void 0, void 0 ) ); + +new TestCase( SECTION, + "Math.max(null, 1)", + 1, + Math.max( null, 1 ) ); + +new TestCase( SECTION, + "Math.max(-1, null)", + 0, + Math.max( -1, null ) ); + +new TestCase( SECTION, + "Math.max(true, false)", + 1, + Math.max(true,false) ); + +new TestCase( SECTION, + "Math.max('-99','99')", + 99, + Math.max( "-99","99") ); + +new TestCase( SECTION, + "Math.max(NaN, Infinity)", + Number.NaN, + Math.max(Number.NaN,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(NaN, 0)", + Number.NaN, + Math.max(Number.NaN, 0) ); + +new TestCase( SECTION, + "Math.max('a string', 0)", + Number.NaN, + Math.max("a string", 0) ); + +new TestCase( SECTION, + "Math.max(NaN, 1)", + Number.NaN, + Math.max(Number.NaN,1) ); + +new TestCase( SECTION, + "Math.max('a string',Infinity)", + Number.NaN, + Math.max("a string", Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(Infinity, NaN)", + Number.NaN, + Math.max( Number.POSITIVE_INFINITY, Number.NaN) ); + +new TestCase( SECTION, + "Math.max(NaN, NaN)", + Number.NaN, + Math.max(Number.NaN, Number.NaN) ); + +new TestCase( SECTION, + "Math.max(0,NaN)", + Number.NaN, + Math.max(0,Number.NaN) ); + +new TestCase( SECTION, + "Math.max(1, NaN)", + Number.NaN, + Math.max(1, Number.NaN) ); + +new TestCase( SECTION, + "Math.max(0,0)", + 0, + Math.max(0,0) ); + +new TestCase( SECTION, + "Math.max(0,-0)", + 0, + Math.max(0,-0) ); + +new TestCase( SECTION, + "Math.max(-0,0)", + 0, + Math.max(-0,0) ); + +new TestCase( SECTION, + "Math.max(-0,-0)", + -0, + Math.max(-0,-0) ); + +new TestCase( SECTION, + "Infinity/Math.max(-0,-0)", + -Infinity, + Infinity/Math.max(-0,-0) ); + +new TestCase( SECTION, + "Math.max(Infinity, Number.MAX_VALUE)", Number.POSITIVE_INFINITY, + Math.max(Number.POSITIVE_INFINITY, Number.MAX_VALUE) ); + +new TestCase( SECTION, + "Math.max(Infinity, Infinity)", + Number.POSITIVE_INFINITY, + Math.max(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(-Infinity,-Infinity)", + Number.NEGATIVE_INFINITY, + Math.max(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(1,.99999999999999)", + 1, + Math.max(1,.99999999999999) ); + +new TestCase( SECTION, + "Math.max(-1,-.99999999999999)", + -.99999999999999, + Math.max(-1,-.99999999999999) ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.12.js b/js/src/tests/ecma/Math/15.8.2.12.js new file mode 100644 index 000000000..9c67be1c9 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.12.js @@ -0,0 +1,143 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.12.js + ECMA Section: 15.8.2.12 Math.min(x, y) + Description: return the smaller of the two arguments. + special cases: + - if x is NaN or y is NaN return NaN + - if x < y return x + - if y > x return y + - if x is +0 and y is +0 return +0 + - if x is +0 and y is -0 return -0 + - if x is -0 and y is +0 return -0 + - if x is -0 and y is -0 return -0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + +var SECTION = "15.8.2.12"; +var VERSION = "ECMA_1"; +var TITLE = "Math.min(x, y)"; +var BUGNUMBER="76439"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.min.length", + 2, + Math.min.length ); + +new TestCase( SECTION, + "Math.min()", + Infinity, + Math.min() ); + +new TestCase( SECTION, + "Math.min(void 0, 1)", + Number.NaN, + Math.min( void 0, 1 ) ); + +new TestCase( SECTION, + "Math.min(void 0, void 0)", + Number.NaN, + Math.min( void 0, void 0 ) ); + +new TestCase( SECTION, + "Math.min(null, 1)", + 0, + Math.min( null, 1 ) ); + +new TestCase( SECTION, + "Math.min(-1, null)", + -1, + Math.min( -1, null ) ); + +new TestCase( SECTION, + "Math.min(true, false)", + 0, + Math.min(true,false) ); + +new TestCase( SECTION, + "Math.min('-99','99')", + -99, + Math.min( "-99","99") ); + +new TestCase( SECTION, + "Math.min(NaN,0)", + Number.NaN, + Math.min(Number.NaN,0) ); + +new TestCase( SECTION, + "Math.min(NaN,1)", + Number.NaN, + Math.min(Number.NaN,1) ); + +new TestCase( SECTION, + "Math.min(NaN,-1)", + Number.NaN, + Math.min(Number.NaN,-1) ); + +new TestCase( SECTION, + "Math.min(0,NaN)", + Number.NaN, + Math.min(0,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(1,NaN)", + Number.NaN, + Math.min(1,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(-1,NaN)", + Number.NaN, + Math.min(-1,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(NaN,NaN)", + Number.NaN, + Math.min(Number.NaN,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(1,1.0000000001)", + 1, + Math.min(1,1.0000000001) ); + +new TestCase( SECTION, + "Math.min(1.0000000001,1)", + 1, + Math.min(1.0000000001,1) ); + +new TestCase( SECTION, + "Math.min(0,0)", + 0, + Math.min(0,0) ); + +new TestCase( SECTION, + "Math.min(0,-0)", + -0, + Math.min(0,-0) ); + +new TestCase( SECTION, + "Math.min(-0,-0)", + -0, + Math.min(-0,-0) ); + +new TestCase( SECTION, + "Infinity/Math.min(0,-0)", + -Infinity, + Infinity/Math.min(0,-0) ); + +new TestCase( SECTION, + "Infinity/Math.min(-0,-0)", + -Infinity, + Infinity/Math.min(-0,-0) ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.13.js b/js/src/tests/ecma/Math/15.8.2.13.js new file mode 100644 index 000000000..c7d562217 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.13.js @@ -0,0 +1,351 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.13.js + ECMA Section: 15.8.2.13 Math.pow(x, y) + Description: return an approximation to the result of x + to the power of y. there are many special cases; + refer to the spec. + Author: christine@netscape.com + Date: 9 july 1997 +*/ + +var SECTION = "15.8.2.13"; +var VERSION = "ECMA_1"; +var TITLE = "Math.pow(x, y)"; +var BUGNUMBER="77141"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.pow.length", + 2, + Math.pow.length ); + +new TestCase( SECTION, + "Math.pow()", + Number.NaN, + Math.pow() ); + +new TestCase( SECTION, + "Math.pow(null, null)", + 1, + Math.pow(null,null) ); + +new TestCase( SECTION, + "Math.pow(void 0, void 0)", + Number.NaN, + Math.pow(void 0, void 0)); + +new TestCase( SECTION, + "Math.pow(true, false)", + 1, + Math.pow(true, false) ); + +new TestCase( SECTION, + "Math.pow(false,true)", + 0, + Math.pow(false,true) ); + +new TestCase( SECTION, + "Math.pow('2','32')", + 4294967296, + Math.pow('2','32') ); + +new TestCase( SECTION, + "Math.pow(1,NaN)", + Number.NaN, + Math.pow(1,Number.NaN) ); + +new TestCase( SECTION, + "Math.pow(0,NaN)", + Number.NaN, + Math.pow(0,Number.NaN) ); + +new TestCase( SECTION, + "Math.pow(NaN,0)", + 1, + Math.pow(Number.NaN,0) ); + +new TestCase( SECTION, + "Math.pow(NaN,-0)", + 1, + Math.pow(Number.NaN,-0) ); + +new TestCase( SECTION, + "Math.pow(NaN,1)", + Number.NaN, + Math.pow(Number.NaN, 1) ); + +new TestCase( SECTION, + "Math.pow(NaN,.5)", + Number.NaN, + Math.pow(Number.NaN, .5) ); + +new TestCase( SECTION, + "Math.pow(1.00000001, Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(1.00000001, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(1.00000001, -Infinity)", + 0, + Math.pow(1.00000001, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1.00000001, Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(-1.00000001,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1.00000001, -Infinity)", + 0, + Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(1, Infinity)", + Number.NaN, + Math.pow(1, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(1, -Infinity)", + Number.NaN, + Math.pow(1, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1, Infinity)", + Number.NaN, + Math.pow(-1, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1, -Infinity)", + Number.NaN, + Math.pow(-1, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(.0000000009, Infinity)", + 0, + Math.pow(.0000000009, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-.0000000009, Infinity)", + 0, + Math.pow(-.0000000009, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(.0000000009, -Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(Infinity, .00000000001)", + Number.POSITIVE_INFINITY, + Math.pow(Number.POSITIVE_INFINITY,.00000000001) ); + +new TestCase( SECTION, + "Math.pow(Infinity, 1)", + Number.POSITIVE_INFINITY, + Math.pow(Number.POSITIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.pow(Infinity, -.00000000001)", + 0, + Math.pow(Number.POSITIVE_INFINITY, -.00000000001) ); + +new TestCase( SECTION, + "Math.pow(Infinity, -1)", + 0, + Math.pow(Number.POSITIVE_INFINITY, -1) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 1)", + Number.NEGATIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 333)", + Number.NEGATIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 333) ); + +new TestCase( SECTION, + "Math.pow(Infinity, 2)", + Number.POSITIVE_INFINITY, + Math.pow(Number.POSITIVE_INFINITY, 2) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 666)", + Number.POSITIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 666) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 0.5)", + Number.POSITIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 0.5) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -1)", + -0, + Math.pow(Number.NEGATIVE_INFINITY, -1) ); + +new TestCase( SECTION, + "Infinity/Math.pow(-Infinity, -1)", + -Infinity, + Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -3)", + -0, + Math.pow(Number.NEGATIVE_INFINITY, -3) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -2)", + 0, + Math.pow(Number.NEGATIVE_INFINITY, -2) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -0.5)", + 0, + Math.pow(Number.NEGATIVE_INFINITY,-0.5) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -Infinity)", + 0, + Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(0, 1)", + 0, + Math.pow(0,1) ); + +new TestCase( SECTION, + "Math.pow(0, 0)", + 1, + Math.pow(0,0) ); + +new TestCase( SECTION, + "Math.pow(1, 0)", + 1, + Math.pow(1,0) ); + +new TestCase( SECTION, + "Math.pow(-1, 0)", + 1, + Math.pow(-1,0) ); + +new TestCase( SECTION, + "Math.pow(0, 0.5)", + 0, + Math.pow(0,0.5) ); + +new TestCase( SECTION, + "Math.pow(0, 1000)", + 0, + Math.pow(0,1000) ); + +new TestCase( SECTION, + "Math.pow(0, Infinity)", + 0, + Math.pow(0, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(0, -1)", + Number.POSITIVE_INFINITY, + Math.pow(0, -1) ); + +new TestCase( SECTION, + "Math.pow(0, -0.5)", + Number.POSITIVE_INFINITY, + Math.pow(0, -0.5) ); + +new TestCase( SECTION, + "Math.pow(0, -1000)", + Number.POSITIVE_INFINITY, + Math.pow(0, -1000) ); + +new TestCase( SECTION, + "Math.pow(0, -Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(0, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-0, 1)", + -0, + Math.pow(-0, 1) ); + +new TestCase( SECTION, + "Math.pow(-0, 3)", + -0, + Math.pow(-0,3) ); + +new TestCase( SECTION, + "Infinity/Math.pow(-0, 1)", + -Infinity, + Infinity/Math.pow(-0, 1) ); + +new TestCase( SECTION, + "Infinity/Math.pow(-0, 3)", + -Infinity, + Infinity/Math.pow(-0,3) ); + +new TestCase( SECTION, + "Math.pow(-0, 2)", + 0, + Math.pow(-0,2) ); + +new TestCase( SECTION, + "Math.pow(-0, Infinity)", + 0, + Math.pow(-0, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-0, -1)", + Number.NEGATIVE_INFINITY, + Math.pow(-0, -1) ); + +new TestCase( SECTION, + "Math.pow(-0, -10001)", + Number.NEGATIVE_INFINITY, + Math.pow(-0, -10001) ); + +new TestCase( SECTION, + "Math.pow(-0, -2)", + Number.POSITIVE_INFINITY, + Math.pow(-0, -2) ); + +new TestCase( SECTION, + "Math.pow(-0, 0.5)", + 0, + Math.pow(-0, 0.5) ); + +new TestCase( SECTION, + "Math.pow(-0, Infinity)", + 0, + Math.pow(-0, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1, 0.5)", + Number.NaN, + Math.pow(-1, 0.5) ); + +new TestCase( SECTION, + "Math.pow(-1, NaN)", + Number.NaN, + Math.pow(-1, Number.NaN) ); + +new TestCase( SECTION, + "Math.pow(-1, -0.5)", + Number.NaN, + Math.pow(-1, -0.5) ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.14.js b/js/src/tests/ecma/Math/15.8.2.14.js new file mode 100644 index 000000000..2c15a8481 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.14.js @@ -0,0 +1,45 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.14.js + ECMA Section: 15.8.2.14 Math.random() + returns a number value x with a positive sign + with 1 > x >= 0 with approximately uniform + distribution over that range, using an + implementation-dependent algorithm or strategy. + This function takes no arguments. + + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.2.14"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.random()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +for ( var item = 0; item < 100; item++ ) { + var testcase = new TestCase( SECTION, + "Math.random()", + "pass", + null ); + testcase.reason = Math.random(); + testcase.actual = "pass"; + + if ( ! ( testcase.reason >= 0) ) { + testcase.actual = "fail"; + } + + if ( ! (testcase.reason < 1) ) { + testcase.actual = "fail"; + } +} + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.15.js b/js/src/tests/ecma/Math/15.8.2.15.js new file mode 100644 index 000000000..4ef748211 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.15.js @@ -0,0 +1,168 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.15.js + ECMA Section: 15.8.2.15 Math.round(x) + Description: return the greatest number value that is closest to the + argument and is an integer. if two integers are equally + close to the argument. then the result is the number value + that is closer to Infinity. if the argument is an integer, + return the argument. + special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = -0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if 0 < x < 0.5 return 0 + - if -0.5 <= x < 0 return -0 + example: + Math.round( 3.5 ) == 4 + Math.round( -3.5 ) == 3 + also: + - Math.round(x) == Math.floor( x + 0.5 ) + except if x = -0. in that case, Math.round(x) = -0 + + and Math.floor( x+0.5 ) = +0 + + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.15"; +var VERSION = "ECMA_1"; +var TITLE = "Math.round(x)"; +var BUGNUMBER="331411"; + +var EXCLUDE = "true"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.round.length", + 1, + Math.round.length ); + +new TestCase( SECTION, + "Math.round()", + Number.NaN, + Math.round() ); + +new TestCase( SECTION, + "Math.round(null)", + 0, + Math.round(0) ); + +new TestCase( SECTION, + "Math.round(void 0)", + Number.NaN, + Math.round(void 0) ); + +new TestCase( SECTION, + "Math.round(true)", + 1, + Math.round(true) ); + +new TestCase( SECTION, + "Math.round(false)", + 0, + Math.round(false) ); + +new TestCase( SECTION, + "Math.round('.99999')", + 1, + Math.round('.99999') ); + +new TestCase( SECTION, + "Math.round('12345e-2')", + 123, + Math.round('12345e-2') ); + +new TestCase( SECTION, + "Math.round(NaN)", + Number.NaN, + Math.round(Number.NaN) ); + +new TestCase( SECTION, + "Math.round(0)", + 0, + Math.round(0) ); + +new TestCase( SECTION, + "Math.round(-0)", + -0, + Math.round(-0)); + +new TestCase( SECTION, + "Infinity/Math.round(-0)", + -Infinity, + Infinity/Math.round(-0) ); + +new TestCase( SECTION, + "Math.round(Infinity)", + Number.POSITIVE_INFINITY, + Math.round(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.round(-Infinity)", + Number.NEGATIVE_INFINITY, + Math.round(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.round(0.49)", + 0, + Math.round(0.49)); + +new TestCase( SECTION, + "Math.round(0.5)", + 1, + Math.round(0.5)); + +new TestCase( SECTION, + "Math.round(0.51)", + 1, + Math.round(0.51)); + +new TestCase( SECTION, + "Math.round(-0.49)", + -0, + Math.round(-0.49)); + +new TestCase( SECTION, + "Math.round(-0.5)", + -0, + Math.round(-0.5)); + +new TestCase( SECTION, + "Infinity/Math.round(-0.49)", + -Infinity, + Infinity/Math.round(-0.49)); + +new TestCase( SECTION, + "Infinity/Math.round(-0.5)", + -Infinity, + Infinity/Math.round(-0.5)); + +new TestCase( SECTION, + "Math.round(-0.51)", + -1, + Math.round(-0.51)); + +new TestCase( SECTION, + "Math.round(3.5)", + 4, + Math.round(3.5)); + +new TestCase( SECTION, + "Math.round(-3.5)", + -3, + Math.round(-3)); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.16.js b/js/src/tests/ecma/Math/15.8.2.16.js new file mode 100644 index 000000000..56a12ee09 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.16.js @@ -0,0 +1,98 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.16.js + ECMA Section: 15.8.2.16 sin( x ) + Description: return an approximation to the sine of the + argument. argument is expressed in radians + Author: christine@netscape.com + Date: 7 july 1997 + +*/ +var SECTION = "15.8.2.16"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.sin(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.sin.length", + 1, + Math.sin.length ); + +new TestCase( SECTION, + "Math.sin()", + Number.NaN, + Math.sin() ); + +new TestCase( SECTION, + "Math.sin(null)", + 0, + Math.sin(null) ); + +new TestCase( SECTION, + "Math.sin(void 0)", + Number.NaN, + Math.sin(void 0) ); + +new TestCase( SECTION, + "Math.sin(false)", + 0, + Math.sin(false) ); + +new TestCase( SECTION, + "Math.sin('2.356194490192')", + 0.7071067811865, + Math.sin('2.356194490192') ); + +new TestCase( SECTION, + "Math.sin(NaN)", + Number.NaN, + Math.sin(Number.NaN) ); + +new TestCase( SECTION, + "Math.sin(0)", + 0, + Math.sin(0) ); + +new TestCase( SECTION, + "Math.sin(-0)", + -0, + Math.sin(-0)); + +new TestCase( SECTION, + "Math.sin(Infinity)", + Number.NaN, + Math.sin(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sin(-Infinity)", + Number.NaN, + Math.sin(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sin(0.7853981633974)", + 0.7071067811865, + Math.sin(0.7853981633974)); + +new TestCase( SECTION, + "Math.sin(1.570796326795)", + 1, + Math.sin(1.570796326795)); + +new TestCase( SECTION, + "Math.sin(2.356194490192)", + 0.7071067811865, + Math.sin(2.356194490192)); + +new TestCase( SECTION, + "Math.sin(3.14159265359)", + 0, + Math.sin(3.14159265359)); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.17.js b/js/src/tests/ecma/Math/15.8.2.17.js new file mode 100644 index 000000000..10e176098 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.17.js @@ -0,0 +1,183 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.17.js + ECMA Section: 15.8.2.17 Math.sqrt(x) + Description: return an approximation to the squareroot of the argument. + special cases: + - if x is NaN return NaN + - if x < 0 return NaN + - if x == 0 return 0 + - if x == -0 return -0 + - if x == Infinity return Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.17"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.sqrt(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.sqrt.length", + 1, + Math.sqrt.length ); + +new TestCase( SECTION, + "Math.sqrt()", + Number.NaN, + Math.sqrt() ); + +new TestCase( SECTION, + "Math.sqrt(void 0)", + Number.NaN, + Math.sqrt(void 0) ); + +new TestCase( SECTION, + "Math.sqrt(null)", + 0, + Math.sqrt(null) ); + +new TestCase( SECTION, + "Math.sqrt(true)", + 1, + Math.sqrt(1) ); + +new TestCase( SECTION, + "Math.sqrt(false)", + 0, + Math.sqrt(false) ); + +new TestCase( SECTION, + "Math.sqrt('225')", + 15, + Math.sqrt('225') ); + +new TestCase( SECTION, + "Math.sqrt(NaN)", + Number.NaN, + Math.sqrt(Number.NaN) ); + +new TestCase( SECTION, + "Math.sqrt(-Infinity)", + Number.NaN, + Math.sqrt(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sqrt(-1)", + Number.NaN, + Math.sqrt(-1)); + +new TestCase( SECTION, + "Math.sqrt(-0.5)", + Number.NaN, + Math.sqrt(-0.5)); + +new TestCase( SECTION, + "Math.sqrt(0)", + 0, + Math.sqrt(0)); + +new TestCase( SECTION, + "Math.sqrt(-0)", + -0, + Math.sqrt(-0)); + +new TestCase( SECTION, + "Infinity/Math.sqrt(-0)", + -Infinity, + Infinity/Math.sqrt(-0) ); + +new TestCase( SECTION, + "Math.sqrt(Infinity)", + Number.POSITIVE_INFINITY, + Math.sqrt(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sqrt(1)", + 1, + Math.sqrt(1)); + +new TestCase( SECTION, + "Math.sqrt(2)", + Math.SQRT2, + Math.sqrt(2)); + +new TestCase( SECTION, + "Math.sqrt(0.5)", + Math.SQRT1_2, + Math.sqrt(0.5)); + +new TestCase( SECTION, + "Math.sqrt(4)", + 2, + Math.sqrt(4)); + +new TestCase( SECTION, + "Math.sqrt(9)", + 3, + Math.sqrt(9)); + +new TestCase( SECTION, + "Math.sqrt(16)", + 4, + Math.sqrt(16)); + +new TestCase( SECTION, + "Math.sqrt(25)", + 5, + Math.sqrt(25)); + +new TestCase( SECTION, + "Math.sqrt(36)", + 6, + Math.sqrt(36)); + +new TestCase( SECTION, + "Math.sqrt(49)", + 7, + Math.sqrt(49)); + +new TestCase( SECTION, + "Math.sqrt(64)", + 8, + Math.sqrt(64)); + +new TestCase( SECTION, + "Math.sqrt(256)", + 16, + Math.sqrt(256)); + +new TestCase( SECTION, + "Math.sqrt(10000)", + 100, + Math.sqrt(10000)); + +new TestCase( SECTION, + "Math.sqrt(65536)", + 256, + Math.sqrt(65536)); + +new TestCase( SECTION, + "Math.sqrt(0.09)", + 0.3, + Math.sqrt(0.09)); + +new TestCase( SECTION, + "Math.sqrt(0.01)", + 0.1, + Math.sqrt(0.01)); + +new TestCase( SECTION, + "Math.sqrt(0.00000001)", + 0.0001, + Math.sqrt(0.00000001)); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.18.js b/js/src/tests/ecma/Math/15.8.2.18.js new file mode 100644 index 000000000..d857599ef --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.18.js @@ -0,0 +1,131 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.18.js + ECMA Section: 15.8.2.18 tan( x ) + Description: return an approximation to the tan of the + argument. argument is expressed in radians + special cases: + - if x is NaN result is NaN + - if x is 0 result is 0 + - if x is -0 result is -0 + - if x is Infinity or -Infinity result is NaN + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.18"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.tan(x)"; +var EXCLUDE = "true"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.tan.length", + 1, + Math.tan.length ); + +new TestCase( SECTION, + "Math.tan()", + Number.NaN, + Math.tan() ); + +new TestCase( SECTION, + "Math.tan(void 0)", + Number.NaN, + Math.tan(void 0)); + +new TestCase( SECTION, + "Math.tan(null)", + 0, + Math.tan(null) ); + +new TestCase( SECTION, + "Math.tan(false)", + 0, + Math.tan(false) ); + +new TestCase( SECTION, + "Math.tan(NaN)", + Number.NaN, + Math.tan(Number.NaN) ); + +new TestCase( SECTION, + "Math.tan(0)", + 0, + Math.tan(0)); + +new TestCase( SECTION, + "Math.tan(-0)", + -0, + Math.tan(-0)); + +new TestCase( SECTION, + "Math.tan(Infinity)", + Number.NaN, + Math.tan(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.tan(-Infinity)", + Number.NaN, + Math.tan(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.tan(Math.PI/4)", + 1, + Math.tan(Math.PI/4)); + +new TestCase( SECTION, + "Math.tan(3*Math.PI/4)", + -1, + Math.tan(3*Math.PI/4)); + +new TestCase( SECTION, + "Math.tan(Math.PI)", + -0, + Math.tan(Math.PI)); + +new TestCase( SECTION, + "Math.tan(5*Math.PI/4)", + 1, + Math.tan(5*Math.PI/4)); + +new TestCase( SECTION, + "Math.tan(7*Math.PI/4)", + -1, + Math.tan(7*Math.PI/4)); + +new TestCase( SECTION, + "Infinity/Math.tan(-0)", + -Infinity, + Infinity/Math.tan(-0) ); + +/* + Arctan (x) ~ PI/2 - 1/x for large x. For x = 1.6x10^16, 1/x is about the last binary digit of double precision PI/2. + That is to say, perturbing PI/2 by this much is about the smallest rounding error possible. + + This suggests that the answer Christine is getting and a real Infinity are "adjacent" results from the tangent function. I + suspect that tan (PI/2 + one ulp) is a negative result about the same size as tan (PI/2) and that this pair are the closest + results to infinity that the algorithm can deliver. + + In any case, my call is that the answer we're seeing is "right". I suggest the test pass on any result this size or larger. + = C = +*/ + +new TestCase( SECTION, + "Math.tan(3*Math.PI/2) >= 5443000000000000", + true, + Math.tan(3*Math.PI/2) >= 5443000000000000 ); + +new TestCase( SECTION, + "Math.tan(Math.PI/2) >= 5443000000000000", + true, + Math.tan(Math.PI/2) >= 5443000000000000 ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.2.js b/js/src/tests/ecma/Math/15.8.2.2.js new file mode 100644 index 000000000..0f72734d2 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.2.js @@ -0,0 +1,122 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.2.js + ECMA Section: 15.8.2.2 acos( x ) + Description: return an approximation to the arc cosine of the + argument. the result is expressed in radians and + range is from +0 to +PI. special cases: + - if x is NaN, return NaN + - if x > 1, the result is NaN + - if x < -1, the result is NaN + - if x == 1, the result is +0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ +var SECTION = "15.8.2.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.acos()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.acos.length", + 1, + Math.acos.length ); + +new TestCase( SECTION, + "Math.acos(void 0)", + Number.NaN, + Math.acos(void 0) ); + +new TestCase( SECTION, + "Math.acos()", + Number.NaN, + Math.acos() ); + +new TestCase( SECTION, + "Math.acos(null)", + Math.PI/2, + Math.acos(null) ); + +new TestCase( SECTION, + "Math.acos(NaN)", + Number.NaN, + Math.acos(Number.NaN) ); + +new TestCase( SECTION, + "Math.acos(a string)", + Number.NaN, + Math.acos("a string") ); + +new TestCase( SECTION, + "Math.acos('0')", + Math.PI/2, + Math.acos('0') ); + +new TestCase( SECTION, + "Math.acos('1')", + 0, + Math.acos('1') ); + +new TestCase( SECTION, + "Math.acos('-1')", + Math.PI, + Math.acos('-1') ); + +new TestCase( SECTION, + "Math.acos(1.00000001)", + Number.NaN, + Math.acos(1.00000001) ); + +new TestCase( SECTION, + "Math.acos(11.00000001)", + Number.NaN, + Math.acos(-1.00000001) ); + +new TestCase( SECTION, + "Math.acos(1)", + 0, + Math.acos(1) ); + +new TestCase( SECTION, + "Math.acos(-1)", + Math.PI, + Math.acos(-1) ); + +new TestCase( SECTION, + "Math.acos(0)", + Math.PI/2, + Math.acos(0) ); + +new TestCase( SECTION, + "Math.acos(-0)", + Math.PI/2, + Math.acos(-0) ); + +new TestCase( SECTION, + "Math.acos(Math.SQRT1_2)", + Math.PI/4, + Math.acos(Math.SQRT1_2)); + +new TestCase( SECTION, + "Math.acos(-Math.SQRT1_2)", + Math.PI/4*3, + Math.acos(-Math.SQRT1_2)); + +new TestCase( SECTION, + "Math.acos(0.9999619230642)", + Math.PI/360, + Math.acos(0.9999619230642)); + +new TestCase( SECTION, + "Math.acos(-3.0)", + Number.NaN, + Math.acos(-3.0)); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.3.js b/js/src/tests/ecma/Math/15.8.2.3.js new file mode 100644 index 000000000..f4f61d5a3 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.3.js @@ -0,0 +1,124 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.3.js + ECMA Section: 15.8.2.3 asin( x ) + Description: return an approximation to the arc sine of the + argument. the result is expressed in radians and + range is from -PI/2 to +PI/2. special cases: + - if x is NaN, the result is NaN + - if x > 1, the result is NaN + - if x < -1, the result is NaN + - if x == +0, the result is +0 + - if x == -0, the result is -0 + Author: christine@netscape.com + Date: 7 july 1997 + +*/ +var SECTION = "15.8.2.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.asin()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.asin()", + Number.NaN, + Math.asin() ); + +new TestCase( SECTION, + "Math.asin(void 0)", + Number.NaN, + Math.asin(void 0) ); + +new TestCase( SECTION, + "Math.asin(null)", + 0, + Math.asin(null) ); + +new TestCase( SECTION, + "Math.asin(NaN)", + Number.NaN, + Math.asin(Number.NaN) ); + +new TestCase( SECTION, + "Math.asin('string')", + Number.NaN, + Math.asin("string") ); + +new TestCase( SECTION, + "Math.asin('0')", + 0, + Math.asin("0") ); + +new TestCase( SECTION, + "Math.asin('1')", + Math.PI/2, + Math.asin("1") ); + +new TestCase( SECTION, + "Math.asin('-1')", + -Math.PI/2, + Math.asin("-1") ); + +new TestCase( SECTION, + "Math.asin(Math.SQRT1_2+'')", + Math.PI/4, + Math.asin(Math.SQRT1_2+'') ); + +new TestCase( SECTION, + "Math.asin(-Math.SQRT1_2+'')", + -Math.PI/4, + Math.asin(-Math.SQRT1_2+'') ); + +new TestCase( SECTION, + "Math.asin(1.000001)", + Number.NaN, + Math.asin(1.000001) ); + +new TestCase( SECTION, + "Math.asin(-1.000001)", + Number.NaN, + Math.asin(-1.000001) ); + +new TestCase( SECTION, + "Math.asin(0)", + 0, + Math.asin(0) ); + +new TestCase( SECTION, + "Math.asin(-0)", + -0, + Math.asin(-0) ); + +new TestCase( SECTION, + "Infinity/Math.asin(-0)", + -Infinity, + Infinity/Math.asin(-0) ); + +new TestCase( SECTION, + "Math.asin(1)", + Math.PI/2, + Math.asin(1) ); + +new TestCase( SECTION, + "Math.asin(-1)", + -Math.PI/2, + Math.asin(-1) ); + +new TestCase( SECTION, + "Math.asin(Math.SQRT1_2))", + Math.PI/4, + Math.asin(Math.SQRT1_2) ); + +new TestCase( SECTION, + "Math.asin(-Math.SQRT1_2))", + -Math.PI/4, + Math.asin(-Math.SQRT1_2)); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.4.js b/js/src/tests/ecma/Math/15.8.2.4.js new file mode 100644 index 000000000..5d73424a8 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.4.js @@ -0,0 +1,122 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.4.js + ECMA Section: 15.8.2.4 atan( x ) + Description: return an approximation to the arc tangent of the + argument. the result is expressed in radians and + range is from -PI/2 to +PI/2. special cases: + - if x is NaN, the result is NaN + - if x == +0, the result is +0 + - if x == -0, the result is -0 + - if x == +Infinity, the result is approximately +PI/2 + - if x == -Infinity, the result is approximately -PI/2 + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + +var SECTION = "15.8.2.4"; +var VERSION = "ECMA_1"; +var TITLE = "Math.atan()"; +var BUGNUMBER="77391"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.atan.length", + 1, + Math.atan.length ); + +new TestCase( SECTION, + "Math.atan()", + Number.NaN, + Math.atan() ); + +new TestCase( SECTION, + "Math.atan(void 0)", + Number.NaN, + Math.atan(void 0) ); + +new TestCase( SECTION, + "Math.atan(null)", + 0, + Math.atan(null) ); + +new TestCase( SECTION, + "Math.atan(NaN)", + Number.NaN, + Math.atan(Number.NaN) ); + +new TestCase( SECTION, + "Math.atan('a string')", + Number.NaN, + Math.atan("a string") ); + +new TestCase( SECTION, + "Math.atan('0')", + 0, + Math.atan('0') ); + +new TestCase( SECTION, + "Math.atan('1')", + Math.PI/4, + Math.atan('1') ); + +new TestCase( SECTION, + "Math.atan('-1')", + -Math.PI/4, + Math.atan('-1') ); + +new TestCase( SECTION, + "Math.atan('Infinity)", + Math.PI/2, + Math.atan('Infinity') ); + +new TestCase( SECTION, + "Math.atan('-Infinity)", + -Math.PI/2, + Math.atan('-Infinity') ); + +new TestCase( SECTION, + "Math.atan(0)", + 0, + Math.atan(0) ); + +new TestCase( SECTION, + "Math.atan(-0)", + -0, + Math.atan(-0) ); + +new TestCase( SECTION, + "Infinity/Math.atan(-0)", + -Infinity, + Infinity/Math.atan(-0) ); + +new TestCase( SECTION, + "Math.atan(Infinity)", + Math.PI/2, + Math.atan(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan(-Infinity)", + -Math.PI/2, + Math.atan(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan(1)", + Math.PI/4, + Math.atan(1) ); + +new TestCase( SECTION, + "Math.atan(-1)", + -Math.PI/4, + Math.atan(-1) ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.5.js b/js/src/tests/ecma/Math/15.8.2.5.js new file mode 100644 index 000000000..bae8c688c --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.5.js @@ -0,0 +1,210 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.5.js + ECMA Section: 15.8.2.5 atan2( y, x ) + Description: + + Author: christine@netscape.com + Date: 7 july 1997 + +*/ +var SECTION = "15.8.2.5"; +var VERSION = "ECMA_1"; +var TITLE = "Math.atan2(x,y)"; +var BUGNUMBER="76111"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.atan2.length", + 2, + Math.atan2.length ); + +new TestCase( SECTION, + "Math.atan2(NaN, 0)", + Number.NaN, + Math.atan2(Number.NaN,0) ); + +new TestCase( SECTION, + "Math.atan2(null, null)", + 0, + Math.atan2(null, null) ); + +new TestCase( SECTION, + "Math.atan2(void 0, void 0)", + Number.NaN, + Math.atan2(void 0, void 0) ); + +new TestCase( SECTION, + "Math.atan2()", + Number.NaN, + Math.atan2() ); + +new TestCase( SECTION, + "Math.atan2(0, NaN)", + Number.NaN, + Math.atan2(0,Number.NaN) ); + +new TestCase( SECTION, + "Math.atan2(1, 0)", + Math.PI/2, + Math.atan2(1,0) ); + +new TestCase( SECTION, + "Math.atan2(1,-0)", + Math.PI/2, + Math.atan2(1,-0) ); + +new TestCase( SECTION, + "Math.atan2(0,0.001)", + 0, + Math.atan2(0,0.001) ); + +new TestCase( SECTION, + "Math.atan2(0,0)", + 0, + Math.atan2(0,0) ); + +new TestCase( SECTION, + "Math.atan2(0, -0)", + Math.PI, + Math.atan2(0,-0) ); + +new TestCase( SECTION, + "Math.atan2(0, -1)", + Math.PI, + Math.atan2(0, -1) ); + +new TestCase( SECTION, + "Math.atan2(-0, 1)", + -0, + Math.atan2(-0, 1) ); + +new TestCase( SECTION, + "Infinity/Math.atan2(-0, 1)", + -Infinity, + Infinity/Math.atan2(-0,1) ); + +new TestCase( SECTION, + "Math.atan2(-0, 0)", + -0, + Math.atan2(-0,0) ); + +new TestCase( SECTION, + "Math.atan2(-0, -0)", + -Math.PI, + Math.atan2(-0, -0) ); + +new TestCase( SECTION, + "Math.atan2(-0, -1)", + -Math.PI, + Math.atan2(-0, -1) ); + +new TestCase( SECTION, + "Math.atan2(-1, 0)", + -Math.PI/2, + Math.atan2(-1, 0) ); + +new TestCase( SECTION, + "Math.atan2(-1, -0)", + -Math.PI/2, + Math.atan2(-1, -0) ); + +new TestCase( SECTION, + "Math.atan2(1, Infinity)", + 0, + Math.atan2(1, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(1,-Infinity)", + Math.PI, + Math.atan2(1, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-1, Infinity)", + -0, + Math.atan2(-1,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Infinity/Math.atan2(-1, Infinity)", + -Infinity, + Infinity/Math.atan2(-1,Infinity) ); + +new TestCase( SECTION, + "Math.atan2(-1,-Infinity)", + -Math.PI, + Math.atan2(-1,Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, 0)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY, 0) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, 1)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.atan2(Infinity,-1)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY,-1) ); + +new TestCase( SECTION, + "Math.atan2(Infinity,-0)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY,-0) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, 0)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY, 0) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity,-0)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY,-0) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, 1)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, -1)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY,-1) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, Infinity)", + Math.PI/4, + Math.atan2(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, -Infinity)", + 3*Math.PI/4, + Math.atan2(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, Infinity)", + -Math.PI/4, + Math.atan2(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, -Infinity)", + -3*Math.PI/4, + Math.atan2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-1, 1)", + -Math.PI/4, + Math.atan2( -1, 1) ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.6.js b/js/src/tests/ecma/Math/15.8.2.6.js new file mode 100644 index 000000000..1385e63e5 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.6.js @@ -0,0 +1,198 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.6.js + ECMA Section: 15.8.2.6 Math.ceil(x) + Description: return the smallest number value that is not less than the + argument and is equal to a mathematical integer. if the + number is already an integer, return the number itself. + special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = 0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if ( -1 < x < 0 ) return -0 + also: + - the value of Math.ceil(x) == -Math.ceil(-x) + Author: christine@netscape.com + Date: 7 july 1997 +*/ +var SECTION = "15.8.2.6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.ceil(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.ceil.length", + 1, + Math.ceil.length ); + +new TestCase( SECTION, + "Math.ceil(NaN)", + Number.NaN, + Math.ceil(Number.NaN) ); + +new TestCase( SECTION, + "Math.ceil(null)", + 0, + Math.ceil(null) ); + +new TestCase( SECTION, + "Math.ceil()", + Number.NaN, + Math.ceil() ); + +new TestCase( SECTION, + "Math.ceil(void 0)", + Number.NaN, + Math.ceil(void 0) ); + +new TestCase( SECTION, + "Math.ceil('0')", + 0, + Math.ceil('0') ); + +new TestCase( SECTION, + "Math.ceil('-0')", + -0, + Math.ceil('-0') ); + +new TestCase( SECTION, + "Infinity/Math.ceil('0')", + Infinity, + Infinity/Math.ceil('0')); + +new TestCase( SECTION, + "Infinity/Math.ceil('-0')", + -Infinity, + Infinity/Math.ceil('-0')); + +new TestCase( SECTION, + "Math.ceil(0)", + 0, + Math.ceil(0) ); + +new TestCase( SECTION, + "Math.ceil(-0)", + -0, + Math.ceil(-0) ); + +new TestCase( SECTION, + "Infinity/Math.ceil(0)", + Infinity, + Infinity/Math.ceil(0)); + +new TestCase( SECTION, + "Infinity/Math.ceil(-0)", + -Infinity, + Infinity/Math.ceil(-0)); + + +new TestCase( SECTION, + "Math.ceil(Infinity)", + Number.POSITIVE_INFINITY, + Math.ceil(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Infinity)", + Number.NEGATIVE_INFINITY, + Math.ceil(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Number.MIN_VALUE)", + -0, + Math.ceil(-Number.MIN_VALUE) ); + +new TestCase( SECTION, + "Infinity/Math.ceil(-Number.MIN_VALUE)", + -Infinity, + Infinity/Math.ceil(-Number.MIN_VALUE) ); + +new TestCase( SECTION, + "Math.ceil(1)", + 1, + Math.ceil(1) ); + +new TestCase( SECTION, + "Math.ceil(-1)", + -1, + Math.ceil(-1) ); + +new TestCase( SECTION, + "Math.ceil(-0.9)", + -0, + Math.ceil(-0.9) ); + +new TestCase( SECTION, + "Infinity/Math.ceil(-0.9)", + -Infinity, + Infinity/Math.ceil(-0.9) ); + +new TestCase( SECTION, + "Math.ceil(0.9 )", + 1, + Math.ceil( 0.9) ); + +new TestCase( SECTION, + "Math.ceil(-1.1)", + -1, + Math.ceil( -1.1)); + +new TestCase( SECTION, + "Math.ceil( 1.1)", + 2, + Math.ceil( 1.1)); + +new TestCase( SECTION, + "Math.ceil(Infinity)", + -Math.floor(-Infinity), + Math.ceil(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Infinity)", + -Math.floor(Infinity), + Math.ceil(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Number.MIN_VALUE)", + -Math.floor(Number.MIN_VALUE), + Math.ceil(-Number.MIN_VALUE) ); + +new TestCase( SECTION, + "Math.ceil(1)", + -Math.floor(-1), + Math.ceil(1) ); + +new TestCase( SECTION, + "Math.ceil(-1)", + -Math.floor(1), + Math.ceil(-1) ); + +new TestCase( SECTION, + "Math.ceil(-0.9)", + -Math.floor(0.9), + Math.ceil(-0.9) ); + +new TestCase( SECTION, + "Math.ceil(0.9 )", + -Math.floor(-0.9), + Math.ceil( 0.9) ); + +new TestCase( SECTION, + "Math.ceil(-1.1)", + -Math.floor(1.1), + Math.ceil( -1.1)); + +new TestCase( SECTION, + "Math.ceil( 1.1)", + -Math.floor(-1.1), + Math.ceil( 1.1)); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.7.js b/js/src/tests/ecma/Math/15.8.2.7.js new file mode 100644 index 000000000..fd1e798c5 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.7.js @@ -0,0 +1,249 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.7.js + ECMA Section: 15.8.2.7 cos( x ) + Description: return an approximation to the cosine of the + argument. argument is expressed in radians + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + +var SECTION = "15.8.2.7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.cos(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.cos.length", + 1, + Math.cos.length ); + +new TestCase( SECTION, + "Math.cos()", + Number.NaN, + Math.cos() ); + +new TestCase( SECTION, + "Math.cos(void 0)", + Number.NaN, + Math.cos(void 0) ); + +new TestCase( SECTION, + "Math.cos(false)", + 1, + Math.cos(false) ); + +new TestCase( SECTION, + "Math.cos(null)", + 1, + Math.cos(null) ); + +new TestCase( SECTION, + "Math.cos('0')", + 1, + Math.cos('0') ); + +new TestCase( SECTION, + "Math.cos('Infinity')", + Number.NaN, + Math.cos("Infinity") ); + +new TestCase( SECTION, + "Math.cos('3.14159265359')", + -1, + Math.cos('3.14159265359') ); + +new TestCase( SECTION, + "Math.cos(NaN)", + Number.NaN, + Math.cos(Number.NaN) ); + +new TestCase( SECTION, + "Math.cos(0)", + 1, + Math.cos(0) ); + +new TestCase( SECTION, + "Math.cos(-0)", + 1, + Math.cos(-0) ); + +new TestCase( SECTION, + "Math.cos(Infinity)", + Number.NaN, + Math.cos(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.cos(-Infinity)", + Number.NaN, + Math.cos(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.cos(0.7853981633974)", + 0.7071067811865, + Math.cos(0.7853981633974) ); + +new TestCase( SECTION, + "Math.cos(1.570796326795)", + 0, + Math.cos(1.570796326795) ); + +new TestCase( SECTION, + "Math.cos(2.356194490192)", + -0.7071067811865, + Math.cos(2.356194490192) ); + +new TestCase( SECTION, + "Math.cos(3.14159265359)", + -1, + Math.cos(3.14159265359) ); + +new TestCase( SECTION, + "Math.cos(3.926990816987)", + -0.7071067811865, + Math.cos(3.926990816987) ); + +new TestCase( SECTION, + "Math.cos(4.712388980385)", + 0, + Math.cos(4.712388980385) ); + +new TestCase( SECTION, + "Math.cos(5.497787143782)", + 0.7071067811865, + Math.cos(5.497787143782) ); + +new TestCase( SECTION, + "Math.cos(Math.PI*2)", + 1, + Math.cos(Math.PI*2) ); + +new TestCase( SECTION, + "Math.cos(Math.PI/4)", + Math.SQRT2/2, + Math.cos(Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(Math.PI/2)", + 0, + Math.cos(Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(3*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(3*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(Math.PI)", + -1, + Math.cos(Math.PI) ); + +new TestCase( SECTION, + "Math.cos(5*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(5*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(3*Math.PI/2)", + 0, + Math.cos(3*Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(7*Math.PI/4)", + Math.SQRT2/2, + Math.cos(7*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(Math.PI*2)", + 1, + Math.cos(2*Math.PI) ); + +new TestCase( SECTION, + "Math.cos(-0.7853981633974)", + 0.7071067811865, + Math.cos(-0.7853981633974) ); + +new TestCase( SECTION, + "Math.cos(-1.570796326795)", + 0, + Math.cos(-1.570796326795) ); + +new TestCase( SECTION, + "Math.cos(-2.3561944901920)", + -.7071067811865, + Math.cos(2.3561944901920) ); + +new TestCase( SECTION, + "Math.cos(-3.14159265359)", + -1, + Math.cos(3.14159265359) ); + +new TestCase( SECTION, + "Math.cos(-3.926990816987)", + -0.7071067811865, + Math.cos(3.926990816987) ); + +new TestCase( SECTION, + "Math.cos(-4.712388980385)", + 0, + Math.cos(4.712388980385) ); + +new TestCase( SECTION, + "Math.cos(-5.497787143782)", + 0.7071067811865, + Math.cos(5.497787143782) ); + +new TestCase( SECTION, + "Math.cos(-6.28318530718)", + 1, + Math.cos(6.28318530718) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI/4)", + Math.SQRT2/2, + Math.cos(-Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI/2)", + 0, + Math.cos(-Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(-3*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(-3*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI)", + -1, + Math.cos(-Math.PI) ); + +new TestCase( SECTION, + "Math.cos(-5*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(-5*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-3*Math.PI/2)", + 0, + Math.cos(-3*Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(-7*Math.PI/4)", + Math.SQRT2/2, + Math.cos(-7*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI*2)", + 1, + Math.cos(-Math.PI*2) ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.8.js b/js/src/tests/ecma/Math/15.8.2.8.js new file mode 100644 index 000000000..54b68c7e1 --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.8.js @@ -0,0 +1,100 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.8.js + ECMA Section: 15.8.2.8 Math.exp(x) + Description: return an approximation to the exponential function of + the argument (e raised to the power of the argument) + special cases: + - if x is NaN return NaN + - if x is 0 return 1 + - if x is -0 return 1 + - if x is Infinity return Infinity + - if x is -Infinity return 0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + +var SECTION = "15.8.2.8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.exp(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.exp.length", + 1, + Math.exp.length ); + +new TestCase( SECTION, + "Math.exp()", + Number.NaN, + Math.exp() ); + +new TestCase( SECTION, + "Math.exp(null)", + 1, + Math.exp(null) ); + +new TestCase( SECTION, + "Math.exp(void 0)", + Number.NaN, + Math.exp(void 0) ); + +new TestCase( SECTION, + "Math.exp(1)", + Math.E, + Math.exp(1) ); + +new TestCase( SECTION, + "Math.exp(true)", + Math.E, + Math.exp(true) ); + +new TestCase( SECTION, + "Math.exp(false)", + 1, + Math.exp(false) ); + +new TestCase( SECTION, + "Math.exp('1')", + Math.E, + Math.exp('1') ); + +new TestCase( SECTION, + "Math.exp('0')", + 1, + Math.exp('0') ); + +new TestCase( SECTION, + "Math.exp(NaN)", + Number.NaN, + Math.exp(Number.NaN) ); + +new TestCase( SECTION, + "Math.exp(0)", + 1, + Math.exp(0) ); + +new TestCase( SECTION, + "Math.exp(-0)", + 1, + Math.exp(-0) ); + +new TestCase( SECTION, + "Math.exp(Infinity)", + Number.POSITIVE_INFINITY, + Math.exp(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.exp(-Infinity)", + 0, + Math.exp(Number.NEGATIVE_INFINITY) ); + +test(); diff --git a/js/src/tests/ecma/Math/15.8.2.9.js b/js/src/tests/ecma/Math/15.8.2.9.js new file mode 100644 index 000000000..9fe0ab1db --- /dev/null +++ b/js/src/tests/ecma/Math/15.8.2.9.js @@ -0,0 +1,157 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.8.2.9.js + ECMA Section: 15.8.2.9 Math.floor(x) + Description: return the greatest number value that is not greater + than the argument and is equal to a mathematical integer. + if the number is already an integer, return the number + itself. special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = -0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if ( -1 < x < 0 ) return -0 + also: + - the value of Math.floor(x) == -Math.ceil(-x) + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.9"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.floor(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.floor.length", + 1, + Math.floor.length ); + +new TestCase( SECTION, + "Math.floor()", + Number.NaN, + Math.floor() ); + +new TestCase( SECTION, + "Math.floor(void 0)", + Number.NaN, + Math.floor(void 0) ); + +new TestCase( SECTION, + "Math.floor(null)", + 0, + Math.floor(null) ); + +new TestCase( SECTION, + "Math.floor(true)", + 1, + Math.floor(true) ); + +new TestCase( SECTION, + "Math.floor(false)", + 0, + Math.floor(false) ); + +new TestCase( SECTION, + "Math.floor('1.1')", + 1, + Math.floor("1.1") ); + +new TestCase( SECTION, + "Math.floor('-1.1')", + -2, + Math.floor("-1.1") ); + +new TestCase( SECTION, + "Math.floor('0.1')", + 0, + Math.floor("0.1") ); + +new TestCase( SECTION, + "Math.floor('-0.1')", + -1, + Math.floor("-0.1") ); + +new TestCase( SECTION, + "Math.floor(NaN)", + Number.NaN, + Math.floor(Number.NaN) ); + +new TestCase( SECTION, + "Math.floor(NaN)==-Math.ceil(-NaN)", + false, + Math.floor(Number.NaN) == -Math.ceil(-Number.NaN) ); + +new TestCase( SECTION, + "Math.floor(0)", + 0, + Math.floor(0) ); + +new TestCase( SECTION, + "Math.floor(0)==-Math.ceil(-0)", + true, + Math.floor(0) == -Math.ceil(-0) ); + +new TestCase( SECTION, + "Math.floor(-0)", + -0, + Math.floor(-0) ); + +new TestCase( SECTION, + "Infinity/Math.floor(-0)", + -Infinity, + Infinity/Math.floor(-0) ); + +new TestCase( SECTION, + "Math.floor(-0)==-Math.ceil(0)", + true, + Math.floor(-0)== -Math.ceil(0) ); + +new TestCase( SECTION, + "Math.floor(Infinity)", + Number.POSITIVE_INFINITY, + Math.floor(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(Infinity)==-Math.ceil(-Infinity)", + true, + Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(-Infinity)", + Number.NEGATIVE_INFINITY, + Math.floor(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(-Infinity)==-Math.ceil(Infinity)", + true, + Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(0.0000001)", + 0, + Math.floor(0.0000001) ); + +new TestCase( SECTION, + "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true, + Math.floor(0.0000001)==-Math.ceil(-0.0000001) ); + +new TestCase( SECTION, + "Math.floor(-0.0000001)", + -1, + Math.floor(-0.0000001) ); + +new TestCase( SECTION, + "Math.floor(0.0000001)==-Math.ceil(0.0000001)", + true, + Math.floor(-0.0000001)==-Math.ceil(0.0000001) ); + +test(); diff --git a/js/src/tests/ecma/Math/browser.js b/js/src/tests/ecma/Math/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/Math/browser.js diff --git a/js/src/tests/ecma/Math/shell.js b/js/src/tests/ecma/Math/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/Math/shell.js |