mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-05-02 05:56:58 +00:00
Move the editions into a subfolder
This commit is contained in:
35
editions/tw2/source/tiddlywiki/test/qunit/raiseAssertion.js
Executable file
35
editions/tw2/source/tiddlywiki/test/qunit/raiseAssertion.js
Executable file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* extension of the QUnit framework to support exception handling
|
||||
* cf. http://dev.jquery.com/ticket/4318
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
$.extend(window, {
|
||||
raises: raises
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks that the given expression throws an exception of the expected type, with an optional message.
|
||||
*
|
||||
* @example raises( function() { return foo.bar; }, "TypeError", "invalid property access raises TypeError exception" );
|
||||
*
|
||||
* @param Function expression
|
||||
* @param String expected exception type
|
||||
* @param String message (optional)
|
||||
*/
|
||||
function raises(expression, expected, message) {
|
||||
try {
|
||||
push(false, expression(), expected, message);
|
||||
} catch(ex) {
|
||||
push(ex.name == expected, ex.name, expected, message);
|
||||
}
|
||||
}
|
||||
|
||||
// duplicated private function from testrunner.js
|
||||
function push(result, actual, expected, message) {
|
||||
message = message || (result ? "okay" : "failed");
|
||||
QUnit.ok( result, result ? message + ": " + expected : message + ", expected: " + jsDump.parse(expected) + " result: " + jsDump.parse(actual) );
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user