about summary refs log blame commit diff stats
path: root/test/js/asserts.js
blob: 4d8fd62c6f57c4073fd94be6f46ca3f06a232efc (plain) (tree)


















                                                                
function assert(x, msg) {
	const mymsg = msg ? ": " + msg : "";
	if (!x)
		throw new TypeError("Assertion failed" + mymsg);
}

function assert_throws(expr, error) {
	try {
		eval(expr);
	} catch (e) {
		if (e instanceof error)
			return;
	}
	throw new TypeError("Assertion failed");
}

function assert_equals(a, b) {
	assert(a === b, "Expected " + b + " but got " + a);
}