| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // values. | 47 // values. |
| 48 // For known primitive values, please use assertEquals. | 48 // For known primitive values, please use assertEquals. |
| 49 var assertSame; | 49 var assertSame; |
| 50 | 50 |
| 51 // Expected and found values are identical primitive values or functions | 51 // Expected and found values are identical primitive values or functions |
| 52 // or similarly structured objects (checking internal properties | 52 // or similarly structured objects (checking internal properties |
| 53 // of, e.g., Number and Date objects, the elements of arrays | 53 // of, e.g., Number and Date objects, the elements of arrays |
| 54 // and the properties of non-Array objects). | 54 // and the properties of non-Array objects). |
| 55 var assertEquals; | 55 var assertEquals; |
| 56 | 56 |
| 57 |
| 58 // The difference between expected and found value is within certain tolerance. |
| 59 var assertEqualsDelta; |
| 60 |
| 57 // The found object is an Array with the same length and elements | 61 // The found object is an Array with the same length and elements |
| 58 // as the expected object. The expected object doesn't need to be an Array, | 62 // as the expected object. The expected object doesn't need to be an Array, |
| 59 // as long as it's "array-ish". | 63 // as long as it's "array-ish". |
| 60 var assertArrayEquals; | 64 var assertArrayEquals; |
| 61 | 65 |
| 62 // The found object must have the same enumerable properties as the | 66 // The found object must have the same enumerable properties as the |
| 63 // expected object. The type of object isn't checked. | 67 // expected object. The type of object isn't checked. |
| 64 var assertPropertiesEqual; | 68 var assertPropertiesEqual; |
| 65 | 69 |
| 66 // Assert that the string conversion of the found value is equal to | 70 // Assert that the string conversion of the found value is equal to |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 }; | 244 }; |
| 241 | 245 |
| 242 | 246 |
| 243 assertEquals = function assertEquals(expected, found, name_opt) { | 247 assertEquals = function assertEquals(expected, found, name_opt) { |
| 244 if (!deepEquals(found, expected)) { | 248 if (!deepEquals(found, expected)) { |
| 245 fail(PrettyPrint(expected), found, name_opt); | 249 fail(PrettyPrint(expected), found, name_opt); |
| 246 } | 250 } |
| 247 }; | 251 }; |
| 248 | 252 |
| 249 | 253 |
| 254 assertEqualsDelta = |
| 255 function assertEqualsDelta(expected, found, delta, name_opt) { |
| 256 assertTrue(Math.abs(expected - found) <= delta, name_opt); |
| 257 }; |
| 258 |
| 259 |
| 250 assertArrayEquals = function assertArrayEquals(expected, found, name_opt) { | 260 assertArrayEquals = function assertArrayEquals(expected, found, name_opt) { |
| 251 var start = ""; | 261 var start = ""; |
| 252 if (name_opt) { | 262 if (name_opt) { |
| 253 start = name_opt + " - "; | 263 start = name_opt + " - "; |
| 254 } | 264 } |
| 255 assertEquals(expected.length, found.length, start + "array length"); | 265 assertEquals(expected.length, found.length, start + "array length"); |
| 256 if (expected.length == found.length) { | 266 if (expected.length == found.length) { |
| 257 for (var i = 0; i < expected.length; ++i) { | 267 for (var i = 0; i < expected.length; ++i) { |
| 258 assertEquals(expected[i], found[i], | 268 assertEquals(expected[i], found[i], |
| 259 start + "array element at index " + i); | 269 start + "array element at index " + i); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt); | 387 assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt); |
| 378 } | 388 } |
| 379 | 389 |
| 380 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { | 390 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { |
| 381 if (sync_opt === undefined) sync_opt = ""; | 391 if (sync_opt === undefined) sync_opt = ""; |
| 382 assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt); | 392 assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt); |
| 383 } | 393 } |
| 384 | 394 |
| 385 })(); | 395 })(); |
| 386 | 396 |
| OLD | NEW |