| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Assert that this code is never executed (i.e., always fails if executed). | 107 // Assert that this code is never executed (i.e., always fails if executed). |
| 108 var assertUnreachable; | 108 var assertUnreachable; |
| 109 | 109 |
| 110 // Assert that the function code is (not) optimized. If "no sync" is passed | 110 // Assert that the function code is (not) optimized. If "no sync" is passed |
| 111 // as second argument, we do not wait for the concurrent optimization thread to | 111 // as second argument, we do not wait for the concurrent optimization thread to |
| 112 // finish when polling for optimization status. | 112 // finish when polling for optimization status. |
| 113 // Only works with --allow-natives-syntax. | 113 // Only works with --allow-natives-syntax. |
| 114 var assertOptimized; | 114 var assertOptimized; |
| 115 var assertUnoptimized; | 115 var assertUnoptimized; |
| 116 | 116 |
| 117 // Assert that a string contains another expected substring. |
| 118 var assertContains; |
| 119 |
| 117 | 120 |
| 118 (function () { // Scope for utility functions. | 121 (function () { // Scope for utility functions. |
| 119 | 122 |
| 120 var ObjectPrototypeToString = Object.prototype.toString; | 123 var ObjectPrototypeToString = Object.prototype.toString; |
| 121 var NumberPrototypeValueOf = Number.prototype.valueOf; | 124 var NumberPrototypeValueOf = Number.prototype.valueOf; |
| 122 var BooleanPrototypeValueOf = Boolean.prototype.valueOf; | 125 var BooleanPrototypeValueOf = Boolean.prototype.valueOf; |
| 123 var StringPrototypeValueOf = String.prototype.valueOf; | 126 var StringPrototypeValueOf = String.prototype.valueOf; |
| 124 var DatePrototypeValueOf = Date.prototype.valueOf; | 127 var DatePrototypeValueOf = Date.prototype.valueOf; |
| 125 var RegExpPrototypeToString = RegExp.prototype.toString; | 128 var RegExpPrototypeToString = RegExp.prototype.toString; |
| 126 var ArrayPrototypeMap = Array.prototype.map; | 129 var ArrayPrototypeMap = Array.prototype.map; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 412 |
| 410 assertUnreachable = function assertUnreachable(name_opt) { | 413 assertUnreachable = function assertUnreachable(name_opt) { |
| 411 // Fix this when we ditch the old test runner. | 414 // Fix this when we ditch the old test runner. |
| 412 var message = "Fail" + "ure: unreachable"; | 415 var message = "Fail" + "ure: unreachable"; |
| 413 if (name_opt) { | 416 if (name_opt) { |
| 414 message += " - " + name_opt; | 417 message += " - " + name_opt; |
| 415 } | 418 } |
| 416 throw new MjsUnitAssertionError(message); | 419 throw new MjsUnitAssertionError(message); |
| 417 }; | 420 }; |
| 418 | 421 |
| 422 assertContains = function(value, sub, name_opt) { |
| 423 if (value == null ? (sub != null) : value.indexOf(sub) == -1) { |
| 424 fail("contains '" + String(sub) + "'", value, name_opt); |
| 425 } |
| 426 }; |
| 427 |
| 419 var OptimizationStatusImpl = undefined; | 428 var OptimizationStatusImpl = undefined; |
| 420 | 429 |
| 421 var OptimizationStatus = function(fun, sync_opt) { | 430 var OptimizationStatus = function(fun, sync_opt) { |
| 422 if (OptimizationStatusImpl === undefined) { | 431 if (OptimizationStatusImpl === undefined) { |
| 423 try { | 432 try { |
| 424 OptimizationStatusImpl = new Function( | 433 OptimizationStatusImpl = new Function( |
| 425 "fun", "sync", "return %GetOptimizationStatus(fun, sync);"); | 434 "fun", "sync", "return %GetOptimizationStatus(fun, sync);"); |
| 426 } catch (e) { | 435 } catch (e) { |
| 427 throw new Error("natives syntax not allowed"); | 436 throw new Error("natives syntax not allowed"); |
| 428 } | 437 } |
| 429 } | 438 } |
| 430 return OptimizationStatusImpl(fun, sync_opt); | 439 return OptimizationStatusImpl(fun, sync_opt); |
| 431 } | 440 } |
| 432 | 441 |
| 433 assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { | 442 assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { |
| 434 if (sync_opt === undefined) sync_opt = ""; | 443 if (sync_opt === undefined) sync_opt = ""; |
| 435 assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt); | 444 assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt); |
| 436 } | 445 } |
| 437 | 446 |
| 438 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { | 447 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { |
| 439 if (sync_opt === undefined) sync_opt = ""; | 448 if (sync_opt === undefined) sync_opt = ""; |
| 440 assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt); | 449 assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt); |
| 441 } | 450 } |
| 442 | 451 |
| 443 })(); | 452 })(); |
| OLD | NEW |