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] is not constantly 1 (contains 1 different value)." | |
552 * "FAIL X [0,0,0] should have contain at least one value different | |
553 * from 0." | |
554 */ | |
555 notBeConstantValueOf () { | |
556 this._processArguments(arguments); | |
557 this._printActualForFailure = false; | |
558 | |
559 let passed = true; | |
560 let passDetail; | |
561 let failDetail; | |
562 let differences = {}; | |
563 | |
564 for (let index in this._actual) { | |
565 if (this._actual[index] !== this._expected) | |
566 differences[index] = this._actual[index]; | |
567 } | |
568 | |
569 let numberOfDifferences = Object.keys(differences).length; | |
570 passed = numberOfDifferences > 0; | |
571 | |
572 if (passed) { | |
573 let valueString = { | |
574 noun: numberOfDifferences > 1 ? 'values' : 'value', | |
Raymond Toy
2017/01/06 22:03:43
Nit: Since you have "values" and "differs", you pr
hongchan
2017/01/06 22:08:55
Done. Also removed the 'differs' part since it's n
| |
575 verb: numberOfDifferences > 1 ? 'differ' : 'differs' | |
576 }; | |
577 passDetail = '${actual} is not constantly ${expected} (contains ' + | |
578 numberOfDifferences + ' different ' + valueString.noun + ').'; | |
579 } else { | |
580 failDetail = '${actual} should have contain at least one value ' + | |
581 'different from ${expected}.'; | |
582 } | |
583 | |
584 return this._assert(passed, passDetail, failDetail); | |
585 } | |
586 | |
587 /** | |
544 * Check if |actual| array is identical to |expected| array element-wise. | 588 * Check if |actual| array is identical to |expected| array element-wise. |
545 * | 589 * |
546 * @example | 590 * @example |
547 * should([1, 2, 3]).beEqualToArray([1, 2, 3]); | 591 * should([1, 2, 3]).beEqualToArray([1, 2, 3]); |
548 * | 592 * |
549 * @result | 593 * @result |
550 * "[1,2,3] is identical to the array [1,2,3]." | 594 * "[1,2,3] is identical to the array [1,2,3]." |
551 */ | 595 */ |
552 beEqualToArray () { | 596 beEqualToArray () { |
553 this._processArguments(arguments); | 597 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 ' | 1074 _logError('this test requires the explicit comparison with the ' |
1031 + 'expected result when it runs with run-webkit-tests.'); | 1075 + 'expected result when it runs with run-webkit-tests.'); |
1032 } | 1076 } |
1033 | 1077 |
1034 return new TaskRunner(); | 1078 return new TaskRunner(); |
1035 } | 1079 } |
1036 | 1080 |
1037 }; | 1081 }; |
1038 | 1082 |
1039 })(); | 1083 })(); |
OLD | NEW |