MCPcopy Create free account
hub / github.com/nodejs/node / shouldBe

Function shouldBe

deps/v8/test/webkit/resources/standalone-pre.js:100–121  ·  view source on GitHub ↗
(_a, _b)

Source from the content-addressed store, hash-verified

98}
99
100function shouldBe(_a, _b)
101{
102 if (typeof _a != "string" || typeof _b != "string")
103 debug("WARN: shouldBe() expects string arguments");
104 var exception;
105 var _av;
106 try {
107 _av = eval(_a);
108 } catch (e) {
109 exception = e;
110 }
111 var _bv = eval(_b);
112
113 if (exception)
114 testFailed(_a + " should be " + _bv + ". Threw exception " + exception);
115 else if (isResultCorrect(_av, _bv))
116 testPassed(_a + " is " + _b);
117 else if (typeof(_av) == typeof(_bv))
118 testFailed(_a + " should be " + _bv + ". Was " + stringify(_av) + ".");
119 else
120 testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + stringify(_av) + " (of type " + typeof _av + ").");
121}
122
123function shouldBeTrue(_a) { shouldBe(_a, "true"); }
124function shouldBeFalse(_a) { shouldBe(_a, "false"); }

Calls 6

testFailedFunction · 0.85
isResultCorrectFunction · 0.85
testPassedFunction · 0.85
debugFunction · 0.70
stringifyFunction · 0.70
evalFunction · 0.50

Tested by 1

testFunction · 0.40