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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 return { | 164 return { |
165 createTaskRunner: function () { | 165 createTaskRunner: function () { |
166 return new Tasks(); | 166 return new Tasks(); |
167 } | 167 } |
168 }; | 168 }; |
169 | 169 |
170 })(); | 170 })(); |
171 | 171 |
172 | 172 |
| 173 // Compute the (linear) signal-to-noise ratio between |actual| and |expected|.
The result is NOT in |
| 174 // dB! If the |actual| and |expected| have different lengths, the shorter lengt
h is used. |
| 175 function computeSNR(actual, expected) |
| 176 { |
| 177 var signalPower = 0; |
| 178 var noisePower = 0; |
| 179 |
| 180 var length = Math.min(actual.length, expected.length); |
| 181 |
| 182 for (var k = 0; k < length; ++k) { |
| 183 var diff = actual[k] - expected[k]; |
| 184 signalPower += expected[k] * expected[k]; |
| 185 noisePower += diff * diff; |
| 186 } |
| 187 |
| 188 return signalPower / noisePower; |
| 189 } |
| 190 |
173 // |Should| JS layout test utility. | 191 // |Should| JS layout test utility. |
174 // Dependency: ../resources/js-test.js | 192 // Dependency: ../resources/js-test.js |
175 var Should = (function () { | 193 var Should = (function () { |
176 | 194 |
177 'use strict'; | 195 'use strict'; |
178 | 196 |
179 // ShouldModel internal class. For the exposed (factory) method, it is the | 197 // ShouldModel internal class. For the exposed (factory) method, it is the |
180 // return value of this closure. | 198 // return value of this closure. |
181 function ShouldModel(desc, target, opts) { | 199 function ShouldModel(desc, target, opts) { |
182 this.desc = desc; | 200 this.desc = desc; |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 if (opts.hasOwnProperty('brief')) | 930 if (opts.hasOwnProperty('brief')) |
913 _opts.brief = opts.brief; | 931 _opts.brief = opts.brief; |
914 if (opts.hasOwnProperty('precision')) | 932 if (opts.hasOwnProperty('precision')) |
915 _opts.precision = opts.precision; | 933 _opts.precision = opts.precision; |
916 } | 934 } |
917 | 935 |
918 return new ShouldModel(desc, target, _opts); | 936 return new ShouldModel(desc, target, _opts); |
919 }; | 937 }; |
920 | 938 |
921 })(); | 939 })(); |
OLD | NEW |