Commit a9818a74 authored by Aaron Krajeski's avatar Aaron Krajeski Committed by Commit Bot

Add epislon to matrix tests to fix 0 = -0 problem

This test has a pretty brittle expectation of failure for 0 != -0/
This is of course nonsense. (The astute reader will no doubt notice
that 0 does indeed exactly equal -0).

Fortunately there was already the idea of epsilon differences in the
test that were unused. Turning them on fixes the problem and allows up
to delete the expectation.

Also, in testharness assert_approx_equals(Infinity, Infinity, epsilon)
and assert_approx_equals(NaN, NaN, epsilon) were both returning false.
Considering assert_equals(Infinity, Infinity) and assert_equals(NaN, NaN)
are both true, this seems silly.

Bug: 1140535
Change-Id: Ie8a3977b3d97b920903a08a6301705c8c14fc6e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2498791Reviewed-by: default avatarAaron Krajeski <aaronhk@chromium.org>
Reviewed-by: default avatarJuanmi Huertas <juanmihd@chromium.org>
Commit-Queue: Aaron Krajeski <aaronhk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821249}
parent b5515f39
This is a testharness.js-based test.
Found 184 tests; 178 PASS, 6 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS setTransform({a: 1, m11: 2}) (invalid)
PASS addPath({a: 1, m11: 2}) (invalid)
PASS setTransform({b: 0, m12: -1}) (invalid)
PASS addPath({b: 0, m12: -1}) (invalid)
PASS setTransform({c: Infinity, m21: -Infinity}) (invalid)
PASS addPath({c: Infinity, m21: -Infinity}) (invalid)
PASS setTransform({d: 0, m22: NaN}) (invalid)
PASS addPath({d: 0, m22: NaN}) (invalid)
PASS setTransform({e: 1, m41: 1.00000001}) (invalid)
PASS addPath({e: 1, m41: 1.00000001}) (invalid)
PASS setTransform({f: 0, m42: 5e-324}) (invalid)
PASS addPath({f: 0, m42: 5e-324}) (invalid)
PASS setTransform (Sanity check without dictionary)
PASS addPath (Sanity check without second parameter)
PASS setTransform({m13: 1, is2D: true})
PASS addPath({m13: 1, is2D: true})
PASS setTransform({m14: 1, is2D: true})
PASS addPath({m14: 1, is2D: true})
PASS setTransform({m23: 1, is2D: true})
PASS addPath({m23: 1, is2D: true})
PASS setTransform({m24: 1, is2D: true})
PASS addPath({m24: 1, is2D: true})
PASS setTransform({m31: 1, is2D: true})
PASS addPath({m31: 1, is2D: true})
PASS setTransform({m32: 1, is2D: true})
PASS addPath({m32: 1, is2D: true})
PASS setTransform({m33: 0, is2D: true})
PASS addPath({m33: 0, is2D: true})
PASS setTransform({m33: -0, is2D: true})
PASS addPath({m33: -0, is2D: true})
PASS setTransform({m33: -1, is2D: true})
PASS addPath({m33: -1, is2D: true})
PASS setTransform({m34: 1, is2D: true})
PASS addPath({m34: 1, is2D: true})
PASS setTransform({m43: 1, is2D: true})
PASS addPath({m43: 1, is2D: true})
PASS setTransform({m44: 0, is2D: true})
PASS addPath({m44: 0, is2D: true})
PASS setTransform({})
PASS addPath({})
PASS setTransform({is2D: undefined})
PASS addPath({is2D: undefined})
PASS setTransform({a: 1, m11: 1})
PASS addPath({a: 1, m11: 1})
PASS setTransform({b: 0, m12: undefined})
PASS addPath({b: 0, m12: undefined})
PASS setTransform({c: 0, m21: 0})
PASS addPath({c: 0, m21: 0})
FAIL setTransform({c: 0, m21: -0}) assert_equals: m21 expected -0 but got 0
PASS addPath({c: 0, m21: -0})
PASS setTransform({c: -0, m21: 0})
PASS addPath({c: -0, m21: 0})
FAIL setTransform({c: -0, m21: -0}) assert_equals: m21 expected -0 but got 0
PASS addPath({c: -0, m21: -0})
PASS setTransform({d: Infinity, m22: Infinity})
PASS addPath({d: Infinity, m22: Infinity})
PASS setTransform({e: -Infinity, m41: -Infinity})
PASS addPath({e: -Infinity, m41: -Infinity})
PASS setTransform({f: NaN, m42: NaN})
PASS addPath({f: NaN, m42: NaN})
PASS setTransform({f: NaN, m42: NaN, is2D: true})
PASS addPath({f: NaN, m42: NaN, is2D: true})
PASS setTransform({f: 0, m42: null})
PASS addPath({f: 0, m42: null})
PASS setTransform({f: -0, m42: null})
PASS addPath({f: -0, m42: null})
PASS setTransform({a: 2})
PASS addPath({a: 2})
PASS setTransform({b: 2})
PASS addPath({b: 2})
PASS setTransform({c: 2})
PASS addPath({c: 2})
PASS setTransform({d: 2})
PASS addPath({d: 2})
PASS setTransform({e: 2})
PASS addPath({e: 2})
PASS setTransform({f: 2})
PASS addPath({f: 2})
FAIL setTransform({a: -0, b: -0, c: -0, d: -0, e: -0, f: -0}) assert_equals: m41 expected -0 but got 0
PASS addPath({a: -0, b: -0, c: -0, d: -0, e: -0, f: -0})
FAIL setTransform({a: -0, b: -0, c: -0, d: -0, e: -0, f: -0, is2D: true}) assert_equals: m41 expected -0 but got 0
PASS addPath({a: -0, b: -0, c: -0, d: -0, e: -0, f: -0, is2D: true})
PASS setTransform({m11: 2})
PASS addPath({m11: 2})
PASS setTransform({m12: 2})
PASS addPath({m12: 2})
PASS setTransform({m21: 2})
PASS addPath({m21: 2})
PASS setTransform({m22: 2})
PASS addPath({m22: 2})
PASS setTransform({m41: 2})
PASS addPath({m41: 2})
PASS setTransform({m42: 2})
PASS addPath({m42: 2})
FAIL setTransform({m11: -0, m12: -0, m21: -0, m22: -0, m41: -0, m42: -0}) assert_equals: m41 expected -0 but got 0
PASS addPath({m11: -0, m12: -0, m21: -0, m22: -0, m41: -0, m42: -0})
FAIL setTransform({m11: -0, m12: -0, m21: -0, m22: -0, m41: -0, m42: -0, is2D: true}) assert_equals: m41 expected -0 but got 0
PASS addPath({m11: -0, m12: -0, m21: -0, m22: -0, m41: -0, m42: -0, is2D: true})
PASS setTransform({m13: 0, is2D: true})
PASS addPath({m13: 0, is2D: true})
PASS setTransform({m13: -0, is2D: true})
PASS addPath({m13: -0, is2D: true})
PASS setTransform({m14: 0, is2D: true})
PASS addPath({m14: 0, is2D: true})
PASS setTransform({m14: -0, is2D: true})
PASS addPath({m14: -0, is2D: true})
PASS setTransform({m23: 0, is2D: true})
PASS addPath({m23: 0, is2D: true})
PASS setTransform({m23: -0, is2D: true})
PASS addPath({m23: -0, is2D: true})
PASS setTransform({m24: 0, is2D: true})
PASS addPath({m24: 0, is2D: true})
PASS setTransform({m24: -0, is2D: true})
PASS addPath({m24: -0, is2D: true})
PASS setTransform({m31: 0, is2D: true})
PASS addPath({m31: 0, is2D: true})
PASS setTransform({m31: -0, is2D: true})
PASS addPath({m31: -0, is2D: true})
PASS setTransform({m32: 0, is2D: true})
PASS addPath({m32: 0, is2D: true})
PASS setTransform({m32: -0, is2D: true})
PASS addPath({m32: -0, is2D: true})
PASS setTransform({m33: 1, is2D: true})
PASS addPath({m33: 1, is2D: true})
PASS setTransform({m34: 0, is2D: true})
PASS addPath({m34: 0, is2D: true})
PASS setTransform({m34: -0, is2D: true})
PASS addPath({m34: -0, is2D: true})
PASS setTransform({m43: 0, is2D: true})
PASS addPath({m43: 0, is2D: true})
PASS setTransform({m43: -0, is2D: true})
PASS addPath({m43: -0, is2D: true})
PASS setTransform({m44: 1, is2D: true})
PASS addPath({m44: 1, is2D: true})
PASS setTransform({is2D: true})
PASS addPath({is2D: true})
PASS setTransform({m13: 1, is2D: false})
PASS addPath({m13: 1, is2D: false})
PASS setTransform({m14: 1, is2D: false})
PASS addPath({m14: 1, is2D: false})
PASS setTransform({m23: 1, is2D: false})
PASS addPath({m23: 1, is2D: false})
PASS setTransform({m24: 1, is2D: false})
PASS addPath({m24: 1, is2D: false})
PASS setTransform({m31: 1, is2D: false})
PASS addPath({m31: 1, is2D: false})
PASS setTransform({m32: 1, is2D: false})
PASS addPath({m32: 1, is2D: false})
PASS setTransform({m33: 0, is2D: false})
PASS addPath({m33: 0, is2D: false})
PASS setTransform({m33: -0, is2D: false})
PASS addPath({m33: -0, is2D: false})
PASS setTransform({m33: -1, is2D: false})
PASS addPath({m33: -1, is2D: false})
PASS setTransform({m34: 1, is2D: false})
PASS addPath({m34: 1, is2D: false})
PASS setTransform({m43: 1, is2D: false})
PASS addPath({m43: 1, is2D: false})
PASS setTransform({m44: 0, is2D: false})
PASS addPath({m44: 0, is2D: false})
PASS setTransform({m13: 1})
PASS addPath({m13: 1})
PASS setTransform({m14: 1})
PASS addPath({m14: 1})
PASS setTransform({m23: 1})
PASS addPath({m23: 1})
PASS setTransform({m24: 1})
PASS addPath({m24: 1})
PASS setTransform({m31: 1})
PASS addPath({m31: 1})
PASS setTransform({m32: 1})
PASS addPath({m32: 1})
PASS setTransform({m33: 0})
PASS addPath({m33: 0})
PASS setTransform({m34: 1})
PASS addPath({m34: 1})
PASS setTransform({m43: 1})
PASS addPath({m43: 1})
PASS setTransform({m44: 0})
PASS addPath({m44: 0})
PASS setTransform({is2D: false})
PASS addPath({is2D: false})
PASS setTransform({is2D: null})
PASS addPath({is2D: null})
Harness: the test ran to completion.
...@@ -35,7 +35,7 @@ function matrix2D(dict) { ...@@ -35,7 +35,7 @@ function matrix2D(dict) {
return matrix; return matrix;
} }
function checkMatrix(actual, expected, { epsilon = 0 } = {}) { function checkMatrix(actual, expected, { epsilon = Number.MIN_VALUE } = {}) {
for (let member in expected) { for (let member in expected) {
if (epsilon && typeof expected[member] === "number") { if (epsilon && typeof expected[member] === "number") {
assert_approx_equals(actual[member], expected[member], epsilon, member); assert_approx_equals(actual[member], expected[member], epsilon, member);
......
...@@ -7,7 +7,7 @@ PASS JS-engine-created TypeError (worker) ...@@ -7,7 +7,7 @@ PASS JS-engine-created TypeError (worker)
PASS JS-engine-created TypeError (cross-site iframe) PASS JS-engine-created TypeError (cross-site iframe)
PASS web API-created TypeError (worker) PASS web API-created TypeError (worker)
PASS web API-created TypeError (cross-site iframe) PASS web API-created TypeError (cross-site iframe)
FAIL web API-created DOMException (worker) assert_equals: expected (string) "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:14\n at Test.<anonymous> (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:41:19)\n at Test.step (http://web-platform.test:8001/resources/testharness.js:2038:25)\n at async_test (http://web-platform.test:8001/resources/testharness.js:609:34)\n at stackTests (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:40:3)\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:1" but got (undefined) undefined FAIL web API-created DOMException (worker) assert_equals: expected (string) "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:14\n at Test.<anonymous> (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:41:19)\n at Test.step (http://web-platform.test:8001/resources/testharness.js:2044:25)\n at async_test (http://web-platform.test:8001/resources/testharness.js:609:34)\n at stackTests (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:40:3)\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:1" but got (undefined) undefined
FAIL web API-created DOMException (cross-site iframe) assert_equals: expected (string) "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:14\n at Test.<anonymous> (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:60:19)\n at Test.step (http://web-platform.test:8001/resources/testharness.js:2038:25)\n at async_test (http://web-platform.test:8001/resources/testharness.js:609:34)\n at stackTests (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:57:3)\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:1" but got (undefined) undefined FAIL web API-created DOMException (cross-site iframe) assert_equals: expected (string) "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:14\n at Test.<anonymous> (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:60:19)\n at Test.step (http://web-platform.test:8001/resources/testharness.js:2044:25)\n at async_test (http://web-platform.test:8001/resources/testharness.js:609:34)\n at stackTests (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:57:3)\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:1" but got (undefined) undefined
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -1384,10 +1384,16 @@ policies and contribution forms [3]. ...@@ -1384,10 +1384,16 @@ policies and contribution forms [3].
"expected a number but got a ${type_actual}", "expected a number but got a ${type_actual}",
{type_actual:typeof actual}); {type_actual:typeof actual});
assert(Math.abs(actual - expected) <= epsilon, // The epsilon math below does not place nice with NaN and Infinity
"assert_approx_equals", description, // But in this case Infinity = Infinity and NaN = NaN
"expected ${expected} +/- ${epsilon} but got ${actual}", if (isFinite(actual) || isFinite(expected)) {
{expected:expected, actual:actual, epsilon:epsilon}); assert(Math.abs(actual - expected) <= epsilon,
"assert_approx_equals", description,
"expected ${expected} +/- ${epsilon} but got ${actual}",
{expected:expected, actual:actual, epsilon:epsilon});
} else {
assert_equals(actual, expected);
}
} }
expose(assert_approx_equals, "assert_approx_equals"); expose(assert_approx_equals, "assert_approx_equals");
......
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL assertSelection(inputText, tester, expectedText, options) resources/testharness.js:2038:25) FAIL assertSelection(inputText, tester, expectedText, options) resources/testharness.js:2044:25)
expected <style>div, img { width: 200px; height: 100px; }</style><div contenteditable id="target">^<img id="image">|</div><img id="image">, expected <style>div, img { width: 200px; height: 100px; }</style><div contenteditable id="target">^<img id="image">|</div><img id="image">,
but got <style>div, img { width: 200px; height: 100px; }</style><div contenteditable id="target"></div>^<img id="image">|, but got <style>div, img { width: 200px; height: 100px; }</style><div contenteditable id="target"></div>^<img id="image">|,
sameupto <style>div, img { width: 200px; height: 100px; }</style><div contenteditable id="target"> sameupto <style>div, img { width: 200px; height: 100px; }</style><div contenteditable id="target">
......
...@@ -1384,10 +1384,16 @@ policies and contribution forms [3]. ...@@ -1384,10 +1384,16 @@ policies and contribution forms [3].
"expected a number but got a ${type_actual}", "expected a number but got a ${type_actual}",
{type_actual:typeof actual}); {type_actual:typeof actual});
assert(Math.abs(actual - expected) <= epsilon, // The epsilon math below does not place nice with NaN and Infinity
"assert_approx_equals", description, // But in this case Infinity = Infinity and NaN = NaN
"expected ${expected} +/- ${epsilon} but got ${actual}", if (!isFinite(actual) || !isFinite(expected)) {
{expected:expected, actual:actual, epsilon:epsilon}); assert_equals(actual, expected)
} else {
assert(Math.abs(actual - expected) <= epsilon,
"assert_approx_equals", description,
"expected ${expected} +/- ${epsilon} but got ${actual}",
{expected:expected, actual:actual, epsilon:epsilon});
}
} }
expose(assert_approx_equals, "assert_approx_equals"); expose(assert_approx_equals, "assert_approx_equals");
......
CONSOLE ERROR: line 3603: Uncaught Error: assert_equals: Normal script execution order comparison expected "Inline1;Sync1;EndOfBody;DOMContentLoaded;Async1;" but got "EndOfBody;Inline1;Sync1;DOMContentLoaded;Async1;" CONSOLE ERROR: line 3609: Uncaught Error: assert_equals: Normal script execution order comparison expected "Inline1;Sync1;EndOfBody;DOMContentLoaded;Async1;" but got "EndOfBody;Inline1;Sync1;DOMContentLoaded;Async1;"
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL Async Script Execution Order (wrt possibly deferred Synchronous Script) Uncaught Error: assert_equals: Normal script execution order comparison expected "Inline1;Sync1;EndOfBody;DOMContentLoaded;Async1;" but got "EndOfBody;Inline1;Sync1;DOMContentLoaded;Async1;" FAIL Async Script Execution Order (wrt possibly deferred Synchronous Script) Uncaught Error: assert_equals: Normal script execution order comparison expected "Inline1;Sync1;EndOfBody;DOMContentLoaded;Async1;" but got "EndOfBody;Inline1;Sync1;DOMContentLoaded;Async1;"
Harness: the test ran to completion. Harness: the test ran to completion.
......
CONSOLE ERROR: line 3603: Uncaught Error: assert_equals: Normal defer script execution order comparison expected "Inline1;Sync1;Inline2;Sync2;EndOfBody;Defer1;Defer2;DOMContentLoaded;" but got "EndOfBody;Inline1;Sync1;Inline2;Sync2;Defer1;Defer2;DOMContentLoaded;" CONSOLE ERROR: line 3609: Uncaught Error: assert_equals: Normal defer script execution order comparison expected "Inline1;Sync1;Inline2;Sync2;EndOfBody;Defer1;Defer2;DOMContentLoaded;" but got "EndOfBody;Inline1;Sync1;Inline2;Sync2;Defer1;Defer2;DOMContentLoaded;"
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL Defer Script Execution Order Uncaught Error: assert_equals: Normal defer script execution order comparison expected "Inline1;Sync1;Inline2;Sync2;EndOfBody;Defer1;Defer2;DOMContentLoaded;" but got "EndOfBody;Inline1;Sync1;Inline2;Sync2;Defer1;Defer2;DOMContentLoaded;" FAIL Defer Script Execution Order Uncaught Error: assert_equals: Normal defer script execution order comparison expected "Inline1;Sync1;Inline2;Sync2;EndOfBody;Defer1;Defer2;DOMContentLoaded;" but got "EndOfBody;Inline1;Sync1;Inline2;Sync2;Defer1;Defer2;DOMContentLoaded;"
Harness: the test ran to completion. Harness: the test ran to completion.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment