mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
js/LibJS: Move test functions to pure javascript.
The addition of assert functions to Userland/js was done before we had load(..) implemented. Now that it exists, it seems like the right move the test helper functions to pure javascript instead of poluting js with random global functions.
This commit is contained in:
parent
9477efe970
commit
d74ad81402
91 changed files with 193 additions and 19 deletions
16
Libraries/LibJS/Tests/test-common.js
Normal file
16
Libraries/LibJS/Tests/test-common.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
function AssertionError(message) {
|
||||
var instance = new Error(message);
|
||||
instance.name = 'AssertionError';
|
||||
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
|
||||
return instance;
|
||||
}
|
||||
|
||||
function assert(value) {
|
||||
if (!value)
|
||||
throw new AssertionError("The assertion failed!");
|
||||
}
|
||||
|
||||
function assertNotReached() {
|
||||
throw new AssertionError("assertNotReached() was reached!");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue