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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 return true; | 225 return true; |
226 } | 226 } |
227 if (objectClass == "String" || objectClass == "Number" || | 227 if (objectClass == "String" || objectClass == "Number" || |
228 objectClass == "Boolean" || objectClass == "Date") { | 228 objectClass == "Boolean" || objectClass == "Date") { |
229 if (a.valueOf() !== b.valueOf()) return false; | 229 if (a.valueOf() !== b.valueOf()) return false; |
230 } | 230 } |
231 return deepObjectEquals(a, b); | 231 return deepObjectEquals(a, b); |
232 } | 232 } |
233 | 233 |
234 function checkArity(args, arity, name) { | |
235 if (args.length < arity) { | |
236 fail(PrettyPrint(arity), args.length, | |
237 name + " requires " + arity + " or more arguments"); | |
238 } | |
239 } | |
240 | |
241 assertSame = function assertSame(expected, found, name_opt) { | 234 assertSame = function assertSame(expected, found, name_opt) { |
242 checkArity(arguments, 2, "assertSame"); | |
243 | |
244 // TODO(mstarzinger): We should think about using Harmony's egal operator | 235 // TODO(mstarzinger): We should think about using Harmony's egal operator |
245 // or the function equivalent Object.is() here. | 236 // or the function equivalent Object.is() here. |
246 if (found === expected) { | 237 if (found === expected) { |
247 if (expected !== 0 || (1 / expected) == (1 / found)) return; | 238 if (expected !== 0 || (1 / expected) == (1 / found)) return; |
248 } else if ((expected !== expected) && (found !== found)) { | 239 } else if ((expected !== expected) && (found !== found)) { |
249 return; | 240 return; |
250 } | 241 } |
251 fail(PrettyPrint(expected), found, name_opt); | 242 fail(PrettyPrint(expected), found, name_opt); |
252 }; | 243 }; |
253 | 244 |
254 | 245 |
255 assertEquals = function assertEquals(expected, found, name_opt) { | 246 assertEquals = function assertEquals(expected, found, name_opt) { |
256 checkArity(arguments, 2, "assertEquals"); | |
257 | |
258 if (!deepEquals(found, expected)) { | 247 if (!deepEquals(found, expected)) { |
259 fail(PrettyPrint(expected), found, name_opt); | 248 fail(PrettyPrint(expected), found, name_opt); |
260 } | 249 } |
261 }; | 250 }; |
262 | 251 |
263 | 252 |
264 assertEqualsDelta = | 253 assertEqualsDelta = |
265 function assertEqualsDelta(expected, found, delta, name_opt) { | 254 function assertEqualsDelta(expected, found, delta, name_opt) { |
266 assertTrue(Math.abs(expected - found) <= delta, name_opt); | 255 assertTrue(Math.abs(expected - found) <= delta, name_opt); |
267 }; | 256 }; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 if (sync_opt === undefined) sync_opt = ""; | 388 if (sync_opt === undefined) sync_opt = ""; |
400 assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt); | 389 assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt); |
401 } | 390 } |
402 | 391 |
403 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { | 392 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { |
404 if (sync_opt === undefined) sync_opt = ""; | 393 if (sync_opt === undefined) sync_opt = ""; |
405 assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt); | 394 assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt); |
406 } | 395 } |
407 | 396 |
408 })(); | 397 })(); |
OLD | NEW |