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 ShouldModel.prototype.beResolved = function () { |
| 641 return this.target.then(function () { |
| 642 this._testPassed('resolved correctly'); |
| 643 }.bind(this), function (err) { |
| 644 this._testFailed('resolved incorrectly. (with ' + err + ')'); |
| 645 }.bind(this)); |
| 646 }; |
| 647 |
| 648 // Check if the target promise is rejected correctly. |
| 649 // |
| 650 // Example: |
| 651 // Should('My promise', promise).beRejected().then(nextStuff); |
| 652 // Result: |
| 653 // "PASS My promise rejected correctly." |
| 654 ShouldModel.prototype.beRejected = function () { |
| 655 return this.target.then(function () { |
| 656 this._testFailed('resolved incorrectly.'); |
| 657 }.bind(this), function (err) { |
| 658 this._testPassed('rejected correctly. (with ' + err + ')'); |
| 659 }.bind(this)); |
| 660 }; |
| 661 |
634 // Should() method. | 662 // Should() method. |
635 // | 663 // |
636 // |desc| is the description of the task or check and |target| is a value | 664 // |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 | 665 // needs to be checked or a task to be performed. |opt| contains options for |
638 // printing out log messages: options are |opt.numberOfErrorLog| and | 666 // printing out log messages: options are |opt.numberOfErrorLog| and |
639 // |opts.numberOfArrayLog|. | 667 // |opts.numberOfArrayLog|. |
640 return function (desc, target, opts) { | 668 return function (desc, target, opts) { |
641 var _opts = { | 669 var _opts = { |
642 numberOfErrorLog: 8, | 670 numberOfErrorLog: 8, |
643 numberOfArrayLog: 16 | 671 numberOfArrayLog: 16 |
644 }; | 672 }; |
645 | 673 |
646 if (opts instanceof Object) { | 674 if (opts instanceof Object) { |
647 if (opts.hasOwnProperty('numberOfErrorLog')) | 675 if (opts.hasOwnProperty('numberOfErrorLog')) |
648 _opts.numberOfErrorLog = opts.numberOfErrorLog; | 676 _opts.numberOfErrorLog = opts.numberOfErrorLog; |
649 if (opts.hasOwnProperty('numberOfArrayLog')) | 677 if (opts.hasOwnProperty('numberOfArrayLog')) |
650 _opts.numberOfArrayLog = opts.numberOfArrayLog; | 678 _opts.numberOfArrayLog = opts.numberOfArrayLog; |
651 } | 679 } |
652 | 680 |
653 return new ShouldModel(desc, target, _opts); | 681 return new ShouldModel(desc, target, _opts); |
654 }; | 682 }; |
655 | 683 })(); |
656 })(); | |
OLD | NEW |