OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 /** | 6 /** |
7 * @fileOverview WebAudio layout test utility library. Built around W3C's | 7 * @fileOverview WebAudio layout test utility library. Built around W3C's |
8 * testharness.js. Includes asynchronous test task manager, | 8 * testharness.js. Includes asynchronous test task manager, |
9 * assertion utilities. | 9 * assertion utilities. |
10 * @dependency testharness.js | 10 * @dependency testharness.js |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 + ' more errors.'; | 534 + ' more errors.'; |
535 break; | 535 break; |
536 } | 536 } |
537 } | 537 } |
538 } | 538 } |
539 | 539 |
540 return this._assert(passed, passDetail, failDetail); | 540 return this._assert(passed, passDetail, failDetail); |
541 } | 541 } |
542 | 542 |
543 /** | 543 /** |
544 * Check if |actual| array is not filled with a constant |expected| value. | |
545 * | |
546 * @example | |
547 * should([1, 0, 1]).notBeConstantValueOf(1); | |
548 * should([0, 0, 0]).notBeConstantValueOf(0); | |
549 * | |
550 * @result | |
551 * "PASS [1,0,1] contains values that differ from the constant 1." | |
Raymond Toy
2017/01/06 18:50:12
This doesn't seem to match what the code is produc
hongchan
2017/01/06 19:14:42
Done.
| |
552 * "FAIL [0,0,0] contains only the constant 0." | |
553 */ | |
554 notBeConstantValueOf () { | |
555 this._processArguments(arguments); | |
556 this._printActualForFailure = false; | |
557 | |
558 let passed = true; | |
559 let passDetail, failDetail; | |
Raymond Toy
2017/01/06 18:50:12
Should this be two separate lets? Couldn't find a
hongchan
2017/01/06 19:14:42
You are correct. Should I fix this instance only?
| |
560 let differences = {}; | |
Raymond Toy
2017/01/06 18:50:12
Would it be better if differences were an (empty)
hongchan
2017/01/06 19:14:42
Not sure. I thought you might want to print out th
| |
561 | |
562 for (let index in this._actual) { | |
563 if (this._actual[index] !== this._expected) | |
564 differences[index] = this._actual[index]; | |
565 } | |
566 | |
567 let numberOfDifferences = Object.keys(differences).length; | |
568 passed = numberOfDifferences > 0; | |
569 | |
570 if (passed) { | |
571 let valueString = { | |
572 noun: numberOfDifferences > 1 ? 'values' : 'value', | |
573 verb: numberOfDifferences > 1 ? 'differ' : 'differs' | |
574 }; | |
575 passDetail = '${actual} contains ' + numberOfDifferences + ' ' + | |
576 valueString.noun + ' that ' + valueString.verb + ' from the ' + | |
577 'constant ${expected}.'; | |
578 } else { | |
579 failDetail = '${actual} contains only the constant ${expected}.'; | |
Raymond Toy
2017/01/06 18:50:12
It might be better, maybe, to say "${actual} shoul
hongchan
2017/01/06 19:14:42
Thanks, your phrasing is much better. Done.
| |
580 } | |
581 | |
582 return this._assert(passed, passDetail, failDetail); | |
583 } | |
584 | |
585 /** | |
544 * Check if |actual| array is identical to |expected| array element-wise. | 586 * Check if |actual| array is identical to |expected| array element-wise. |
545 * | 587 * |
546 * @example | 588 * @example |
547 * should([1, 2, 3]).beEqualToArray([1, 2, 3]); | 589 * should([1, 2, 3]).beEqualToArray([1, 2, 3]); |
548 * | 590 * |
549 * @result | 591 * @result |
550 * "[1,2,3] is identical to the array [1,2,3]." | 592 * "[1,2,3] is identical to the array [1,2,3]." |
551 */ | 593 */ |
552 beEqualToArray () { | 594 beEqualToArray () { |
553 this._processArguments(arguments); | 595 this._processArguments(arguments); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1030 _logError('this test requires the explicit comparison with the ' | 1072 _logError('this test requires the explicit comparison with the ' |
1031 + 'expected result when it runs with run-webkit-tests.'); | 1073 + 'expected result when it runs with run-webkit-tests.'); |
1032 } | 1074 } |
1033 | 1075 |
1034 return new TaskRunner(); | 1076 return new TaskRunner(); |
1035 } | 1077 } |
1036 | 1078 |
1037 }; | 1079 }; |
1038 | 1080 |
1039 })(); | 1081 })(); |
OLD | NEW |