testRunner.dumpAsText();
}
+var isJsTest = true;
+
var description, debug, successfullyParsed;
var expectingError; // set by shouldHaveError()
return _av;
}
-function shouldBe(_a, _b, quiet)
+function shouldBe(_a, _b, quiet, opt_tolerance)
{
if (typeof _a != "string" || typeof _b != "string")
debug("WARN: shouldBe() expects string arguments");
if (_exception)
testFailed(_a + " should be " + _bv + ". Threw exception " + _exception);
- else if (isResultCorrect(_av, _bv)) {
+ else if (isResultCorrect(_av, _bv) || (typeof opt_tolerance == 'number' && typeof _av == 'number' && Math.abs(_av - _bv) <= opt_tolerance)) {
if (!quiet) {
testPassed(_a + " is " + _b);
}
function shouldBeEmptyString(a) { shouldBeEqualToString(a, ""); }
-function shouldEvaluateTo(actual, expected) {
+function shouldEvaluateTo(actual, expected, opt_tolerance) {
// A general-purpose comparator. 'actual' should be a string to be
// evaluated, as for shouldBe(). 'expected' may be any type and will be
// used without being eval'ed.
} else if (typeof expected == "object") {
shouldBeTrue(actual + " == '" + expected + "'");
} else if (typeof expected == "string") {
- shouldBe(actual, expected);
+ shouldBe(actual, expected, undefined, opt_tolerance);
} else if (typeof expected == "boolean") {
shouldBe("typeof " + actual, "'boolean'");
if (expected)
else
shouldBeFalse(actual);
} else if (typeof expected == "number") {
- shouldBe(actual, stringify(expected));
+ if (opt_tolerance)
+ shouldBeCloseTo(actual, expected, opt_tolerance);
+ else
+ shouldBe(actual, stringify(expected));
} else {
debug(expected + " is unknown type " + typeof expected);
shouldBeTrue(actual, "'" +expected.toString() + "'");
// function.
function asyncGC(callback) {
GCController.collectAll();
- setTimeout(callback, 0);
+ // FIXME: we need a better way of waiting for chromium events to happen
+ setTimeout(callback, 1);
}
function gc() {
GCController.minorCollect();
else
testFailed("Minor GC is available only when you enable the --expose-gc option in V8.");
- setTimeout(callback, 0);
+ // FIXME: we need a better way of waiting for chromium events to happen
+ setTimeout(callback, 1);
}
function isSuccessfullyParsed()
debug('<br /><span class="pass">TEST COMPLETE</span>');
}
+var wasPostTestScriptParsed, wasFinishJSTestCalled, jsTestIsAsync;
+
// It's possible for an async test to call finishJSTest() before js-test-post.js
// has been parsed.
function finishJSTest()