MCPcopy Create free account
hub / github.com/buke/quickjs-go / assert

Function assert

deps/quickjs/tests/assert.js:1–24  ·  view source on GitHub ↗
(actual, expected, message)

Source from the content-addressed store, hash-verified

1export function assert(actual, expected, message) {
2 if (arguments.length === 1)
3 expected = true;
4
5 if (typeof actual === typeof expected) {
6 if (actual === expected) {
7 if (actual !== 0 || (1 / actual) === (1 / expected))
8 return;
9 }
10 if (typeof actual === 'number') {
11 if (isNaN(actual) && isNaN(expected))
12 return;
13 }
14 if (typeof actual === 'object') {
15 if (actual !== null && expected !== null
16 && actual.constructor === expected.constructor
17 && actual.toString() === expected.toString())
18 return;
19 }
20 }
21 throw Error("assertion failed: got |" + actual + "|" +
22 ", expected |" + expected + "|" +
23 (message ? " (" + message + ")" : ""));
24}
25
26export function assertThrows(err, func)
27{

Callers 15

test_codeFunction · 0.90
test_propertiesFunction · 0.90
bug1301.jsFile · 0.90
bug1302.jsFile · 0.90
test_base64Function · 0.90
expectPadFunction · 0.90
expectInvalidOrCanonSameFunction · 0.90
test_resize_shrinkFunction · 0.90
test_detachFunction · 0.90
test_resize_zeroFunction · 0.90
test_resize_growFunction · 0.90

Calls 1

ErrorStruct · 0.85

Tested by 15

testFunction · 0.72
oob_save_indexFunction · 0.40
cfunctionsFunction · 0.40
sync_callFunction · 0.40
async_callFunction · 0.40
save_valueFunction · 0.40
raw_context_global_varFunction · 0.40
is_arrayFunction · 0.40
loaderFunction · 0.40
module_serdeFunction · 0.40
runtime_cstring_freeFunction · 0.40