aboutsummaryrefslogtreecommitdiffstats
path: root/build/test/data/testrunner.js
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2007-02-06 11:55:44 +0000
committerJörn Zaefferer <joern.zaefferer@gmail.com>2007-02-06 11:55:44 +0000
commita69aad2242a5be4ee21955d6132247b4781d410e (patch)
tree0e37ca8157db6258d61d674674fe87810cc4de64 /build/test/data/testrunner.js
parent495ecb70b2b097e7d4a1ffe46d44562210cdc051 (diff)
downloadjquery-a69aad2242a5be4ee21955d6132247b4781d410e.tar.gz
jquery-a69aad2242a5be4ee21955d6132247b4781d410e.zip
Added equals helper for easier debugging of failed tests, soon to be used more often, see coreTest.js attr(String) for an example
Diffstat (limited to 'build/test/data/testrunner.js')
-rw-r--r--build/test/data/testrunner.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/build/test/data/testrunner.js b/build/test/data/testrunner.js
index e73fd671d..899d6700c 100644
--- a/build/test/data/testrunner.js
+++ b/build/test/data/testrunner.js
@@ -218,4 +218,22 @@ function t(a,b,c) {
*/
function url(value) {
return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
-} \ No newline at end of file
+}
+
+/**
+ * Checks that the first two arguments are equal, with an optional message.
+ * Prints out both expected and actual values on failure.
+ *
+ * Prefered to ok( expected == actual, message )
+ *
+ * @example equals( "Expected 2 characters.", v.formatMessage("Expected {0} characters.", 2) );
+ *
+ * @param Object expected
+ * @param Object actual
+ * @param String message (optional)
+ */
+function equals(expected, actual, message) {
+ var result = expected == actual;
+ message = message || result ? "okay" : "failed";
+ _config.Test.push( [ result, result ? message + ": " + expected : message + " expected: " + expected + " actual: " + actual ] );
+}