Skip to content

Commit

Permalink
Add epsilon to float comparison (#3635)
Browse files Browse the repository at this point in the history
Adds an epsilon when comparing float values in
conformance/extensions/webgl-depth-texture.html. As-is, it is possible
for tests to fail with output such as:

At 2,0, expected within [0.2,0.6], was 0.600
FAIL At 2,0, expected within [0.2,0.6], was 0.600

Removes the epsilon value added to certain parts of the expected min/max
values in conformance/extensions/webgl-depth-texture.html, instead using
only the epsilon applied when actually comparing values.
  • Loading branch information
bsheedy-work authored Apr 3, 2024
1 parent 097c03d commit bc3c8ba
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions sdk/tests/conformance/extensions/webgl-depth-texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -323,21 +323,18 @@
d01, d01, d11, d11
];
expectedMax = expectedMin.slice();

expectedMin = expectedMin.map(x => x - eps);
expectedMax = expectedMax.map(x => x + eps);
} else {
expectedMin = [
d00-eps, d00, d00, d10-eps,
d00, d00, d00, d10,
d00, d00, d00, d10,
d01-eps, d01, d01, d11-eps,
d00, d00, d00, d10,
d01, d01, d01, d11,
];
expectedMax = [
d00+eps, d10, d10, d10+eps,
d00, d10, d10, d10,
d01, d11, d11, d11,
d01, d11, d11, d11,
d01, d11, d11, d11,
d01+eps, d11, d11, d11+eps,
];
}

Expand All @@ -349,7 +346,7 @@
const eMax = expectedMax[t];
let func = testPassed;
const text = `At ${xx},${yy}, expected within [${eMin},${eMax}], was ${was.toFixed(3)}`
if (was <= eMin || was >= eMax) {
if (was <= eMin - eps || was >= eMax + eps) {
func = testFailed;
}
func(text);
Expand Down

0 comments on commit bc3c8ba

Please sign in to comment.