js/src/jit-test/lib/asserts.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.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 load(libdir + "../../tests/ecma_6/shell.js");
     8 if (typeof assertWarning === 'undefined') {
     9     var assertWarning = function assertWarning(f, errorClass, msg) {
    10         var hadWerror = options().split(",").indexOf("werror") !== -1;
    12         // Ensure the "werror" option is disabled.
    13         if (hadWerror)
    14             options("werror");
    16         try {
    17             f();
    18         } catch (exc) {
    19             if (hadWerror)
    20                 options("werror");
    22             // print() rather than throw a different exception value, in case
    23             // the caller wants exc.stack.
    24             if (msg)
    25                 print("assertWarning: " + msg);
    26             print("assertWarning: Unexpected exception calling " + f +
    27                   " with warnings-as-errors disabled");
    28             throw exc;
    29         }
    31         // Enable the "werror" option.
    32         options("werror");
    34         try {
    35             assertThrowsInstanceOf(f, errorClass, msg);
    36         } catch (exc) {
    37             if (msg)
    38                 print("assertWarning: " + msg);
    39             throw exc;
    40         } finally {
    41             if (!hadWerror)
    42                 options("werror");
    43         }
    44     };
    45 }
    47 if (typeof assertNoWarning === 'undefined') {
    48     var assertNoWarning = function assertWarning(f, msg) {
    49         // Ensure the "werror" option is enabled.
    50         var hadWerror = options().split(",").indexOf("werror") !== -1;
    51         if (!hadWerror)
    52             options("werror");
    54         try {
    55             f();
    56         } catch (exc) {
    57             if (msg)
    58                 print("assertNoWarning: " + msg);
    59             print("assertNoWarning: Unexpected exception calling " + f +
    60                   "with warnings-as-errors enabled");
    61             throw exc;
    62         } finally {
    63             if (!hadWerror)
    64                 options("werror");
    65         }
    66     };
    67 }

mercurial