var result = "";
function $ERROR (msg) {
result += msg;
}
var assert = {
sameValue: function (a, b, msg) {
if (a !== b) {
$ERROR(msg);
}
},
throws: function (errorType, fn) {
var caughtError;
try {
fn();
} catch (err) {
caughtError = err;
} finally {
if (!caughtError) {
$ERROR("Expected an error but none thrown");
} else if (!(caughtError instanceof errorType)) {
$ERROR("Error of unexpected type");
}
}
}
}
result;