diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-16 13:41:37 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-16 13:41:37 -0700 |
commit | b0d268d121d8868be33d8633b09499b34a4db45f (patch) | |
tree | d67eaf4f5e200b5b5f57099c46a1413d43cbd287 /tools/node_modules/source-map/build/assert-shim.js | |
parent | 6b730836aa53f6b4896f24dd8a4b456669ae4f1a (diff) | |
parent | 475e72dc5539d9c59fc267927441a502c14a178f (diff) |
Merge branch 'incoming'
Diffstat (limited to 'tools/node_modules/source-map/build/assert-shim.js')
-rw-r--r-- | tools/node_modules/source-map/build/assert-shim.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tools/node_modules/source-map/build/assert-shim.js b/tools/node_modules/source-map/build/assert-shim.js new file mode 100644 index 00000000..daa1a623 --- /dev/null +++ b/tools/node_modules/source-map/build/assert-shim.js @@ -0,0 +1,56 @@ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +define('test/source-map/assert', ['exports'], function (exports) { + + let do_throw = function (msg) { + throw new Error(msg); + }; + + exports.init = function (throw_fn) { + do_throw = throw_fn; + }; + + exports.doesNotThrow = function (fn) { + try { + fn(); + } + catch (e) { + do_throw(e.message); + } + }; + + exports.equal = function (actual, expected, msg) { + msg = msg || String(actual) + ' != ' + String(expected); + if (actual != expected) { + do_throw(msg); + } + }; + + exports.ok = function (val, msg) { + msg = msg || String(val) + ' is falsey'; + if (!Boolean(val)) { + do_throw(msg); + } + }; + + exports.strictEqual = function (actual, expected, msg) { + msg = msg || String(actual) + ' !== ' + String(expected); + if (actual !== expected) { + do_throw(msg); + } + }; + + exports.throws = function (fn) { + try { + fn(); + do_throw('Expected an error to be thrown, but it wasn\'t.'); + } + catch (e) { + } + }; + +}); |