michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: load(libdir + "../../tests/ecma_6/shell.js"); michael@0: michael@0: if (typeof assertWarning === 'undefined') { michael@0: var assertWarning = function assertWarning(f, errorClass, msg) { michael@0: var hadWerror = options().split(",").indexOf("werror") !== -1; michael@0: michael@0: // Ensure the "werror" option is disabled. michael@0: if (hadWerror) michael@0: options("werror"); michael@0: michael@0: try { michael@0: f(); michael@0: } catch (exc) { michael@0: if (hadWerror) michael@0: options("werror"); michael@0: michael@0: // print() rather than throw a different exception value, in case michael@0: // the caller wants exc.stack. michael@0: if (msg) michael@0: print("assertWarning: " + msg); michael@0: print("assertWarning: Unexpected exception calling " + f + michael@0: " with warnings-as-errors disabled"); michael@0: throw exc; michael@0: } michael@0: michael@0: // Enable the "werror" option. michael@0: options("werror"); michael@0: michael@0: try { michael@0: assertThrowsInstanceOf(f, errorClass, msg); michael@0: } catch (exc) { michael@0: if (msg) michael@0: print("assertWarning: " + msg); michael@0: throw exc; michael@0: } finally { michael@0: if (!hadWerror) michael@0: options("werror"); michael@0: } michael@0: }; michael@0: } michael@0: michael@0: if (typeof assertNoWarning === 'undefined') { michael@0: var assertNoWarning = function assertWarning(f, msg) { michael@0: // Ensure the "werror" option is enabled. michael@0: var hadWerror = options().split(",").indexOf("werror") !== -1; michael@0: if (!hadWerror) michael@0: options("werror"); michael@0: michael@0: try { michael@0: f(); michael@0: } catch (exc) { michael@0: if (msg) michael@0: print("assertNoWarning: " + msg); michael@0: print("assertNoWarning: Unexpected exception calling " + f + michael@0: "with warnings-as-errors enabled"); michael@0: throw exc; michael@0: } finally { michael@0: if (!hadWerror) michael@0: options("werror"); michael@0: } michael@0: }; michael@0: }