react / wstein / node_modules / jest-cli / node_modules / jsdom / node_modules / request / node_modules / har-validator / node_modules / bluebird / js / main / assert.js
81160 views"use strict";1module.exports = (function(){2var AssertionError = (function() {3function AssertionError(a) {4this.constructor$(a);5this.message = a;6this.name = "AssertionError";7}8AssertionError.prototype = new Error();9AssertionError.prototype.constructor = AssertionError;10AssertionError.prototype.constructor$ = Error;11return AssertionError;12})();1314function getParams(args) {15var params = [];16for (var i = 0; i < args.length; ++i) params.push("arg" + i);17return params;18}1920function nativeAssert(callName, args, expect) {21try {22var params = getParams(args);23var constructorArgs = params;24constructorArgs.push("return " +25callName + "("+ params.join(",") + ");");26var fn = Function.apply(null, constructorArgs);27return fn.apply(null, args);28} catch (e) {29if (!(e instanceof SyntaxError)) {30throw e;31} else {32return expect;33}34}35}3637return function assert(boolExpr, message) {38if (boolExpr === true) return;3940if (typeof boolExpr === "string" &&41boolExpr.charAt(0) === "%") {42var nativeCallName = boolExpr;43var $_len = arguments.length;var args = new Array($_len - 2); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];}44if (nativeAssert(nativeCallName, args, message) === message) return;45message = (nativeCallName + " !== " + message);46}4748var ret = new AssertionError(message);49if (Error.captureStackTrace) {50Error.captureStackTrace(ret, assert);51}52throw ret;53};54})();555657