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 | |
664 // Should() method. | 634 // Should() method. |
665 // | 635 // |
666 // |desc| is the description of the task or check and |target| is a value | 636 // |desc| is the description of the task or check and |target| is a value |
667 // needs to be checked or a task to be performed. |opt| contains options for | 637 // needs to be checked or a task to be performed. |opt| contains options for |
668 // printing out log messages: options are |opt.numberOfErrorLog| and | 638 // printing out log messages: options are |opt.numberOfErrorLog| and |
669 // |opts.numberOfArrayLog|. | 639 // |opts.numberOfArrayLog|. |
670 return function (desc, target, opts) { | 640 return function (desc, target, opts) { |
671 var _opts = { | 641 var _opts = { |
672 numberOfErrorLog: 8, | 642 numberOfErrorLog: 8, |
673 numberOfArrayLog: 16 | 643 numberOfArrayLog: 16 |
674 }; | 644 }; |
675 | 645 |
676 if (opts instanceof Object) { | 646 if (opts instanceof Object) { |
677 if (opts.hasOwnProperty('numberOfErrorLog')) | 647 if (opts.hasOwnProperty('numberOfErrorLog')) |
678 _opts.numberOfErrorLog = opts.numberOfErrorLog; | 648 _opts.numberOfErrorLog = opts.numberOfErrorLog; |
679 if (opts.hasOwnProperty('numberOfArrayLog')) | 649 if (opts.hasOwnProperty('numberOfArrayLog')) |
680 _opts.numberOfArrayLog = opts.numberOfArrayLog; | 650 _opts.numberOfArrayLog = opts.numberOfArrayLog; |
681 } | 651 } |
682 | 652 |
683 return new ShouldModel(desc, target, _opts); | 653 return new ShouldModel(desc, target, _opts); |
684 }; | 654 }; |
685 })(); | 655 |
| 656 })(); |
OLD | NEW |