Skip to content

Commit fff0a7e

Browse files
dbaronchromium-wpt-export-bot
authored andcommitted
Fix test's perspective comparison to accept scientific notation.
This fixes the compareWithPerspective comparison function in transform-interpolation-001.html to accept values with scientific notation (such as numbers very close to zero). It also fixes the comparison function to handle errors better so that failures are reported more clearly. (I want to do this here because the following patch would otherwise add two more of these failures, for the CSS transitions at time 0 cases.) Bug: 897358 Change-Id: Id1ecde987eb0ba9d0d00b6da030d74a689c1e502 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3199697 Commit-Queue: David Baron <[email protected]> Reviewed-by: Kevin Ellis <[email protected]> Cr-Commit-Position: refs/heads/main@{#927399}
1 parent 46bb74d commit fff0a7e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

css/css-transforms/animation/transform-interpolation-001.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,27 @@
4545
// everything to two decimal places, which isn't OK for the matrices
4646
// that result from large perspective values.
4747
const compareWithPerspective = (actual, expected) => {
48-
const matrixRegExp = /^matrix3d\(((?:(?:[-0-9.]+), ){15}(?:[-0-9.]+))\)$/;
49-
const actualArray = actual.match(matrixRegExp)[1].split(", ").map(Number);
50-
const expectedArray = expected.match(matrixRegExp)[1].split(", ").map(Number);
48+
// TODO: This RegExp should be more precise to capture only what is a
49+
// valid float, and this code should be merged with other code doing
50+
// the same thing, e.g., RoundMatrix in
51+
// web-animations/animation-model/animation-types/property-list.js .
52+
const matrixRegExp = /^matrix3d\(((?:(?:[-0-9.e]+), ){15}(?:[-0-9.]+))\)$/;
53+
const actualMatch = actual.match(matrixRegExp);
54+
const expectedMatch = expected.match(matrixRegExp);
55+
assert_not_equals(actualMatch, null, `${actual} should be a matrix`);
56+
assert_not_equals(expectedMatch, null, `${expected} should be a matrix`);
57+
if (actualMatch === null || expectedMatch === null) {
58+
return;
59+
}
60+
const actualArray = actualMatch[1].split(", ").map(Number);
61+
const expectedArray = expectedMatch[1].split(", ").map(Number);
5162
assert_equals(actualArray.length, 16);
5263
assert_equals(expectedArray.length, 16);
5364

65+
if (actualArray.length != expectedArray.length) {
66+
return;
67+
}
68+
5469
for (let i in actualArray) {
5570
const error = Math.abs((actualArray[i] - expectedArray[i])) /
5671
Math.max(1e-6,

0 commit comments

Comments
 (0)