From a69aad2242a5be4ee21955d6132247b4781d410e Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 6 Feb 2007 11:55:44 +0000 Subject: Added equals helper for easier debugging of failed tests, soon to be used more often, see coreTest.js attr(String) for an example --- build/test/data/testrunner.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'build/test/data') 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 ] ); +} -- cgit v1.2.3