Commit 7a754c31 authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

Have containValues check array lengths

If the number of distinct elements in the input array does not match
the number of elements in the expected set, an error was thrown trying
to read a property from undefined.

Instead, check that the lengths match and if they don't fail the test
with an appropriate message.

Also remove the-convolvernode-interface/active-processing.https.html
that should have been removed in
https://chromium-review.googlesource.com/c/chromium/src/+/1653924 but
wasn't.

Bug: 974022, 978372
Test: audit-failures.html
Change-Id: Ifa2da978f3c0f67dc444c69ceddb862675908b05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1659492
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#677080}
parent a33c56d1
...@@ -788,21 +788,31 @@ window.Audit = (function() { ...@@ -788,21 +788,31 @@ window.Audit = (function() {
} }
// Compare against the expected sequence. // Compare against the expected sequence.
for (let j = 0; j < this._expected.length; j++) { let failMessage =
if (this._expected[j] !== indexedActual[j].value) { '${actual} expected to have the value sequence of ${expected} but ' +
firstErrorIndex = indexedActual[j].index; 'got ';
passed = false; if (this._expected.length === indexedActual.length) {
break; for (let j = 0; j < this._expected.length; j++) {
if (this._expected[j] !== indexedActual[j].value) {
firstErrorIndex = indexedActual[j].index;
passed = false;
failMessage += this._actual[firstErrorIndex] + ' at index ' +
firstErrorIndex + '.';
break;
}
} }
} else {
passed = false;
let indexedValues = indexedActual.map(x => x.value);
failMessage += `${indexedActual.length} values, [${
indexedValues}], instead of ${this._expected.length}.`;
} }
return this._assert( return this._assert(
passed, passed,
'${actual} contains all the expected values in the correct order: ' + '${actual} contains all the expected values in the correct order: ' +
'${expected}.', '${expected}.',
'${actual} expected to have the value sequence of ${expected} but ' + failMessage);
'got ' + this._actual[firstErrorIndex] + ' at index ' +
firstErrorIndex + '.');
} }
/** /**
......
This is a testharness.js-based test.
PASS # AUDIT TASK RUNNER STARTED.
PASS > [Test] Active processing for ConvolverNode
PASS Construction of graph with convolver did not throw an exception.
FAIL X Number of output channels of convolver expected to have the value sequence of [1,2,1] but got 2 at index 0. assert_true: expected true got false
FAIL < [Test] 1 out of 2 assertions were failed. assert_true: expected true got false
FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed. assert_true: expected true got false
Harness: the test ran to completion.
...@@ -780,21 +780,31 @@ window.Audit = (function() { ...@@ -780,21 +780,31 @@ window.Audit = (function() {
} }
// Compare against the expected sequence. // Compare against the expected sequence.
for (let j = 0; j < this._expected.length; j++) { let failMessage =
if (this._expected[j] !== indexedActual[j].value) { '${actual} expected to have the value sequence of ${expected} but ' +
firstErrorIndex = indexedActual[j].index; 'got ';
passed = false; if (this._expected.length === indexedActual.length) {
break; for (let j = 0; j < this._expected.length; j++) {
if (this._expected[j] !== indexedActual[j].value) {
firstErrorIndex = indexedActual[j].index;
passed = false;
failMessage += this._actual[firstErrorIndex] + ' at index ' +
firstErrorIndex + '.';
break;
}
} }
} else {
passed = false;
let indexedValues = indexedActual.map(x => x.value);
failMessage += `${indexedActual.length} values, [${
indexedValues}], instead of ${this._expected.length}.`;
} }
return this._assert( return this._assert(
passed, passed,
'${actual} contains all the expected values in the correct order: ' + '${actual} contains all the expected values in the correct order: ' +
'${expected}.', '${expected}.',
'${actual} expected to have the value sequence of ${expected} but ' + failMessage);
'got ' + this._actual[firstErrorIndex] + ' at index ' +
firstErrorIndex + '.');
} }
/** /**
......
...@@ -43,6 +43,8 @@ FAIL X [0,1,2,3,4,5,6,7,8,9] expected to be equal to the array [0,0,0,0,0,0,0,0, ...@@ -43,6 +43,8 @@ FAIL X [0,1,2,3,4,5,6,7,8,9] expected to be equal to the array [0,0,0,0,0,0,0,0,
[4] 4.0000000000000000e+0 0.0000000000000000e+0 [4] 4.0000000000000000e+0 0.0000000000000000e+0
...and 5 more errors. assert_true: expected true got false ...and 5 more errors. assert_true: expected true got false
FAIL X [1,1,1,1,2,2,3,3,3] expected to have the value sequence of [1,3,2] but got 2 at index 4. assert_true: expected true got false FAIL X [1,1,1,1,2,2,3,3,3] expected to have the value sequence of [1,3,2] but got 2 at index 4. assert_true: expected true got false
FAIL X [1,1,2,2] expected to have the value sequence of [1,2,3] but got 2 values, [1,2], instead of 3. assert_true: expected true got false
FAIL X [1,2,3,4,5] expected to have the value sequence of [1,2,3] but got 5 values, [1,2,3,4,5], instead of 3. assert_true: expected true got false
FAIL X [0.5,0.5,0.55,0.5,0.45,0.5] has a glitch at index 5 of size 0.04999999999999999. assert_true: expected true got false FAIL X [0.5,0.5,0.55,0.5,0.45,0.5] has a glitch at index 5 of size 0.04999999999999999. assert_true: expected true got false
FAIL X [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.9] does not equal [0.7,0.6,0.5,0.4,0.3,0.2,0.1] with an element-wise tolerance of {"absoluteThreshold":0.02,"relativeThreshold":0}. FAIL X [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.9] does not equal [0.7,0.6,0.5,0.4,0.3,0.2,0.1] with an element-wise tolerance of {"absoluteThreshold":0.02,"relativeThreshold":0}.
Index Actual Expected AbsError RelError Test threshold Index Actual Expected AbsError RelError Test threshold
...@@ -93,7 +95,7 @@ FAIL X [1,2,3,4,5,6,7,8,9,10,11] does not equal [2,3,4,5,6,7,800,900,1000,1100,1 ...@@ -93,7 +95,7 @@ FAIL X [1,2,3,4,5,6,7,8,9,10,11] does not equal [2,3,4,5,6,7,800,900,1000,1100,1
Max RelError of 9.9124999999999996e-1 at index of 6. Max RelError of 9.9124999999999996e-1 at index of 6.
[6] 7.0000000000000000e+0 8.0000000000000000e+2 7.9300000000000000e+2 9.9124999999999996e-1 0.0000000000000000e+0 [6] 7.0000000000000000e+0 8.0000000000000000e+2 7.9300000000000000e+2 9.9124999999999996e-1 0.0000000000000000e+0
assert_true: expected true got false assert_true: expected true got false
FAIL < [numerical-failures] 11 out of 11 assertions were failed. assert_true: expected true got false FAIL < [numerical-failures] 13 out of 13 assertions were failed. assert_true: expected true got false
PASS > [load-file-in-should] Testing the failure handling of Audit.loadFileFromUrl(). PASS > [load-file-in-should] Testing the failure handling of Audit.loadFileFromUrl().
FAIL X Loading non-existent file within should().beResolved() rejected incorrectly with loadFile: Network failure when loading non-existent-audio-file.wav.. Got Promise. assert_true: expected true got false FAIL X Loading non-existent file within should().beResolved() rejected incorrectly with loadFile: Network failure when loading non-existent-audio-file.wav.. Got Promise. assert_true: expected true got false
FAIL < [load-file-in-should] 1 out of 1 assertions were failed. assert_true: expected true got false FAIL < [load-file-in-should] 1 out of 1 assertions were failed. assert_true: expected true got false
......
...@@ -81,6 +81,8 @@ ...@@ -81,6 +81,8 @@
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]); ]);
should([1, 1, 1, 1, 2, 2, 3, 3, 3]).containValues([1, 3, 2]); should([1, 1, 1, 1, 2, 2, 3, 3, 3]).containValues([1, 3, 2]);
should([1,1,2,2]).containValues([1,2,3]);
should([1,2,3,4,5]).containValues([1,2,3]);
should([0.5, 0.5, 0.55, 0.5, 0.45, 0.5]).notGlitch(0.04); should([0.5, 0.5, 0.55, 0.5, 0.45, 0.5]).notGlitch(0.04);
should([ should([
0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9
......
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