summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js
diff options
context:
space:
mode:
authorcommit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2012-02-24 20:07:12 +0000
committercommit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2012-02-24 20:07:12 +0000
commita6c02a4245e3e3079f2c9f23c72d898fc6702481 (patch)
tree0b6a5b0cb0a5b2c799bd0b5960e663cf549521e5 /third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js
parent8fe4e3bb71629852b32c4d3b27afed5d189c5b0c (diff)
downloadchromium_src-a6c02a4245e3e3079f2c9f23c72d898fc6702481.zip
chromium_src-a6c02a4245e3e3079f2c9f23c72d898fc6702481.tar.gz
chromium_src-a6c02a4245e3e3079f2c9f23c72d898fc6702481.tar.bz2
Make fast/canvas/canvas-strokePath-shadow.html allow for pixel tolerance
https://bugs.webkit.org/show_bug.cgi?id=79488 Patch by Elliot Poger <epoger@google.com> on 2012-02-24 Reviewed by Adam Barth. * fast/canvas/script-tests/canvas-strokePath-shadow.js: (shouldBeAlmost): * fast/js/resources/js-test-pre.js: (shouldBeCloseTo): git-svn-id: svn://svn.chromium.org/blink/trunk@108835 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js')
-rw-r--r--third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js b/third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js
index cad0057..492ff8c 100644
--- a/third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js
+++ b/third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js
@@ -187,6 +187,45 @@ function shouldBe(_a, _b, quiet)
testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
}
+// Variant of shouldBe()--confirms that result of eval(_to_eval) is within
+// numeric _tolerance of numeric _target.
+function shouldBeCloseTo(_to_eval, _target, _tolerance, quiet)
+{
+ if (typeof _to_eval != "string") {
+ testFailed("shouldBeCloseTo() requires string argument _to_eval. was type " + typeof _to_eval);
+ return;
+ }
+ if (typeof _target != "number") {
+ testFailed("shouldBeCloseTo() requires numeric argument _target. was type " + typeof _target);
+ return;
+ }
+ if (typeof _tolerance != "number") {
+ testFailed("shouldBeCloseTo() requires numeric argument _tolerance. was type " + typeof _tolerance);
+ return;
+ }
+
+ var _result;
+ try {
+ _result = eval(_to_eval);
+ } catch (e) {
+ testFailed(_to_eval + " should be within " + _tolerance + " of "
+ + _target + ". Threw exception " + e);
+ return;
+ }
+
+ if (typeof(_result) != typeof(_target)) {
+ testFailed(_to_eval + " should be of type " + typeof _target
+ + " but was of type " + typeof _result);
+ } else if (Math.abs(_result - _target) <= _tolerance) {
+ if (!quiet) {
+ testPassed(_to_eval + " is within " + _tolerance + " of " + _target);
+ }
+ } else {
+ testFailed(_to_eval + " should be within " + _tolerance + " of " + _target
+ + ". Was " + _result + ".");
+ }
+}
+
function shouldNotBe(_a, _b, quiet)
{
if (typeof _a != "string" || typeof _b != "string")