OLD | NEW |
1 if (window.testRunner) | 1 if (window.testRunner) |
2 testRunner.overridePreference("WebKitWebAudioEnabled", "1"); | 2 testRunner.overridePreference("WebKitWebAudioEnabled", "1"); |
3 | 3 |
4 function writeString(s, a, offset) { | 4 function writeString(s, a, offset) { |
5 for (var i = 0; i < s.length; ++i) { | 5 for (var i = 0; i < s.length; ++i) { |
6 a[offset + i] = s.charCodeAt(i); | 6 a[offset + i] = s.charCodeAt(i); |
7 } | 7 } |
8 } | 8 } |
9 | 9 |
10 function writeInt16(n, a, offset) { | 10 function writeInt16(n, a, offset) { |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 for (var i = 1; i < this.target.length; i++) { | 624 for (var i = 1; i < this.target.length; i++) { |
625 var diff = Math.abs(this.target[i-1] - this.target[i]); | 625 var diff = Math.abs(this.target[i-1] - this.target[i]); |
626 if (diff >= threshold) { | 626 if (diff >= threshold) { |
627 this._testFailed('has a glitch at index ' + i + ' of size ' + di
ff); | 627 this._testFailed('has a glitch at index ' + i + ' of size ' + di
ff); |
628 return; | 628 return; |
629 } | 629 } |
630 } | 630 } |
631 this._testPassed('has no glitch above the threshold of ' + threshold); | 631 this._testPassed('has no glitch above the threshold of ' + threshold); |
632 }; | 632 }; |
633 | 633 |
| 634 // Check if the target promise is resolved correctly. |
| 635 // |
| 636 // Example: |
| 637 // Should('My promise', promise).beResolved().then(nextStuff); |
| 638 // Result: |
| 639 // "PASS My promise resolved correctly." |
| 640 // "FAIL My promise rejected incorrectly (with _ERROR_)." |
| 641 ShouldModel.prototype.beResolved = function () { |
| 642 return this.target.then(function () { |
| 643 this._testPassed('resolved correctly'); |
| 644 }.bind(this), function (err) { |
| 645 this._testFailed('rejected incorrectly (with ' + err + ')'); |
| 646 }.bind(this)); |
| 647 }; |
| 648 |
| 649 // Check if the target promise is rejected correctly. |
| 650 // |
| 651 // Example: |
| 652 // Should('My promise', promise).beRejected().then(nextStuff); |
| 653 // Result: |
| 654 // "PASS My promise rejected correctly (with _ERROR_)." |
| 655 // "FAIL My promise resolved incorrectly." |
| 656 ShouldModel.prototype.beRejected = function () { |
| 657 return this.target.then(function () { |
| 658 this._testFailed('resolved incorrectly'); |
| 659 }.bind(this), function (err) { |
| 660 this._testPassed('rejected correctly (with ' + err + ')'); |
| 661 }.bind(this)); |
| 662 }; |
| 663 |
634 // Should() method. | 664 // Should() method. |
635 // | 665 // |
636 // |desc| is the description of the task or check and |target| is a value | 666 // |desc| is the description of the task or check and |target| is a value |
637 // needs to be checked or a task to be performed. |opt| contains options for | 667 // needs to be checked or a task to be performed. |opt| contains options for |
638 // printing out log messages: options are |opt.numberOfErrorLog| and | 668 // printing out log messages: options are |opt.numberOfErrorLog| and |
639 // |opts.numberOfArrayLog|. | 669 // |opts.numberOfArrayLog|. |
640 return function (desc, target, opts) { | 670 return function (desc, target, opts) { |
641 var _opts = { | 671 var _opts = { |
642 numberOfErrorLog: 8, | 672 numberOfErrorLog: 8, |
643 numberOfArrayLog: 16 | 673 numberOfArrayLog: 16 |
644 }; | 674 }; |
645 | 675 |
646 if (opts instanceof Object) { | 676 if (opts instanceof Object) { |
647 if (opts.hasOwnProperty('numberOfErrorLog')) | 677 if (opts.hasOwnProperty('numberOfErrorLog')) |
648 _opts.numberOfErrorLog = opts.numberOfErrorLog; | 678 _opts.numberOfErrorLog = opts.numberOfErrorLog; |
649 if (opts.hasOwnProperty('numberOfArrayLog')) | 679 if (opts.hasOwnProperty('numberOfArrayLog')) |
650 _opts.numberOfArrayLog = opts.numberOfArrayLog; | 680 _opts.numberOfArrayLog = opts.numberOfArrayLog; |
651 } | 681 } |
652 | 682 |
653 return new ShouldModel(desc, target, _opts); | 683 return new ShouldModel(desc, target, _opts); |
654 }; | 684 }; |
655 | 685 })(); |
656 })(); | |
OLD | NEW |