Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* global self */ | 1 /* global self */ |
| 2 | 2 |
| 3 // testharness.js has the higher priority. | 3 // testharness.js has the higher priority. |
| 4 var TESTHARNESS = true; | 4 var TESTHARNESS = true; |
| 5 var JSTEST = false; | 5 var JSTEST = false; |
| 6 | 6 |
| 7 (function () { | 7 (function () { |
| 8 // Selected properies from testharness.js | 8 // Selected properies from testharness.js |
| 9 var testharnessProperties = [ | 9 var testharnessProperties = [ |
| 10 'test', 'async_test', 'promise_test', 'promise_rejects', | 10 'test', 'async_test', 'promise_test', 'promise_rejects', |
| (...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1131 // "PASS My promise rejected correctly (with _ERROR_)." | 1131 // "PASS My promise rejected correctly (with _ERROR_)." |
| 1132 // "FAIL My promise resolved incorrectly." | 1132 // "FAIL My promise resolved incorrectly." |
| 1133 ShouldModel.prototype.beRejected = function () { | 1133 ShouldModel.prototype.beRejected = function () { |
| 1134 return this.target.then(function () { | 1134 return this.target.then(function () { |
| 1135 this._testFailed('resolved incorrectly'); | 1135 this._testFailed('resolved incorrectly'); |
| 1136 }.bind(this), function (err) { | 1136 }.bind(this), function (err) { |
| 1137 this._testPassed('rejected correctly (with ' + err + ')'); | 1137 this._testPassed('rejected correctly (with ' + err + ')'); |
| 1138 }.bind(this)); | 1138 }.bind(this)); |
| 1139 }; | 1139 }; |
| 1140 | 1140 |
| 1141 // Check if the target is null | |
| 1142 // | |
| 1143 // Example: | |
| 1144 // Should("Value", value).beNull(); | |
| 1145 // Result: | |
| 1146 // "PASS Value is null." | |
| 1147 // "FAIL value is not null." | |
| 1148 ShouldModel.prototype.beNull = function () { | |
|
Raymond Toy
2016/08/08 21:24:37
Maybe we don't want this and have the user use beE
| |
| 1149 if (this.target === null) | |
| 1150 this._testPassed("is null"); | |
| 1151 else | |
| 1152 this._testFailed("is not null"); | |
| 1153 | |
| 1154 return this._success; | |
| 1155 } | |
| 1156 | |
| 1157 // The opposite of beNull(). | |
| 1158 ShouldModel.prototype.notBeNull = function () { | |
| 1159 if (this.target === null) | |
| 1160 this._testFailed("is null"); | |
| 1161 else | |
| 1162 this._testPassed("is not null"); | |
| 1163 | |
| 1164 return this._success; | |
| 1165 } | |
| 1166 | |
| 1141 // Should() method. | 1167 // Should() method. |
| 1142 // | 1168 // |
| 1143 // |desc| is the description of the task or check and |target| is a value | 1169 // |desc| is the description of the task or check and |target| is a value |
| 1144 // needs to be checked or a task to be performed. |opt| contains options for | 1170 // needs to be checked or a task to be performed. |opt| contains options for |
| 1145 // printing out log messages: options are |opt.numberOfErrorLog| and | 1171 // printing out log messages: options are |opt.numberOfErrorLog| and |
| 1146 // |opts.numberOfArrayLog|. | 1172 // |opts.numberOfArrayLog|. |
| 1147 return function (desc, target, opts) { | 1173 return function (desc, target, opts) { |
| 1148 var _opts = { | 1174 var _opts = { |
| 1149 numberOfErrorLog: 8, | 1175 numberOfErrorLog: 8, |
| 1150 numberOfArrayLog: 16, | 1176 numberOfArrayLog: 16, |
| 1151 verbose: true | 1177 verbose: true |
| 1152 }; | 1178 }; |
| 1153 | 1179 |
| 1154 if (opts instanceof Object) { | 1180 if (opts instanceof Object) { |
| 1155 if (opts.hasOwnProperty('numberOfErrorLog')) | 1181 if (opts.hasOwnProperty('numberOfErrorLog')) |
| 1156 _opts.numberOfErrorLog = opts.numberOfErrorLog; | 1182 _opts.numberOfErrorLog = opts.numberOfErrorLog; |
| 1157 if (opts.hasOwnProperty('numberOfArrayLog')) | 1183 if (opts.hasOwnProperty('numberOfArrayLog')) |
| 1158 _opts.numberOfArrayLog = opts.numberOfArrayLog; | 1184 _opts.numberOfArrayLog = opts.numberOfArrayLog; |
| 1159 if (opts.hasOwnProperty('brief')) | 1185 if (opts.hasOwnProperty('brief')) |
| 1160 _opts.brief = opts.brief; | 1186 _opts.brief = opts.brief; |
| 1161 if (opts.hasOwnProperty('precision')) | 1187 if (opts.hasOwnProperty('precision')) |
| 1162 _opts.precision = opts.precision; | 1188 _opts.precision = opts.precision; |
| 1163 } | 1189 } |
| 1164 | 1190 |
| 1165 return new ShouldModel(desc, target, _opts); | 1191 return new ShouldModel(desc, target, _opts); |
| 1166 }; | 1192 }; |
| 1167 | 1193 |
| 1168 })(); | 1194 })(); |
| OLD | NEW |