js/src/tests/ecma_2/Exceptions/exception-006.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 /**
     8  *  File Name:          exception-006
     9  *  ECMA Section:
    10  *  Description:        Tests for JavaScript Standard Exceptions
    11  *
    12  *  ToPrimitive error.
    13  *
    14  *  Author:             christine@netscape.com
    15  *  Date:               31 August 1998
    16  */
    17 var SECTION = "exception-006";
    18 var VERSION = "js1_4";
    19 var TITLE   = "Tests for JavaScript Standard Exceptions: TypeError";
    21 startTest();
    22 writeHeaderToLog( SECTION + " "+ TITLE);
    24 ToPrimitive_1();
    26 test();
    29 /**
    30  * Getting the [[DefaultValue]] of any instances of MyObject
    31  * should result in a runtime error in ToPrimitive.
    32  */
    34 function MyObject() {
    35   this.toString = void 0;
    36   this.valueOf = void 0;
    37 }
    39 function ToPrimitive_1() {
    40   result = "failed: no exception thrown";
    41   exception = null;
    43   try {
    44     result = new MyObject() + new MyObject();
    45   } catch ( e ) {
    46     result = "passed:  threw exception",
    47       exception = e.toString();
    48   } finally {
    49     new TestCase(
    50       SECTION,
    51       "new MyObject() + new MyObject() [ exception is " + exception +" ]",
    52       "passed:  threw exception",
    53       result );
    54   }
    55 }

mercurial