OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This is intended for permanent JS behavior changes for mocking out | 5 // This is intended for permanent JS behavior changes for mocking out |
6 // non-deterministic behavior. For temporary suppressions, please refer to | 6 // non-deterministic behavior. For temporary suppressions, please refer to |
7 // v8_suppressions.js. | 7 // v8_suppressions.js. |
8 // This file is loaded before each correctness test cases and won't get | 8 // This file is loaded before each correctness test cases and won't get |
9 // minimized. | 9 // minimized. |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 }, | 51 }, |
52 } | 52 } |
53 | 53 |
54 Date = new Proxy(Date, __magic_mock_date_handler); | 54 Date = new Proxy(Date, __magic_mock_date_handler); |
55 | 55 |
56 // Mock stack traces. | 56 // Mock stack traces. |
57 Error.prepareStackTrace = function (error, structuredStackTrace) { | 57 Error.prepareStackTrace = function (error, structuredStackTrace) { |
58 return ""; | 58 return ""; |
59 } | 59 } |
60 | 60 |
| 61 // Mock buffer access in float typed arrays because of varying NaN patterns. |
| 62 // Note, for now we just use noop forwarding proxies, because they already |
| 63 // turn off optimizations. |
| 64 function __MockTypedArray(arrayType) { |
| 65 array_creation_handler = { |
| 66 construct: function(target, args) { |
| 67 return new Proxy(new arrayType(args), {}); |
| 68 }, |
| 69 }; |
| 70 return new Proxy(arrayType, array_creation_handler); |
| 71 } |
| 72 |
| 73 Float32Array = __MockTypedArray(Float32Array); |
| 74 Float64Array = __MockTypedArray(Float64Array); |
| 75 |
61 // Mock Worker. | 76 // Mock Worker. |
62 var __magic_index_for_mocked_worker = 0 | 77 var __magic_index_for_mocked_worker = 0 |
63 // TODO(machenbach): Randomize this for each test case, but keep stable during | 78 // TODO(machenbach): Randomize this for each test case, but keep stable during |
64 // comparison. Also data and random above. | 79 // comparison. Also data and random above. |
65 var __magic_mocked_worker_messages = [ | 80 var __magic_mocked_worker_messages = [ |
66 undefined, 0, -1, "", "foo", 42, [], {}, [0], {"x": 0} | 81 undefined, 0, -1, "", "foo", 42, [], {}, [0], {"x": 0} |
67 ] | 82 ] |
68 Worker = function(code){ | 83 Worker = function(code){ |
69 try { | 84 try { |
70 __PrettyPrint(eval(code)); | 85 __PrettyPrint(eval(code)); |
71 } catch(e) { | 86 } catch(e) { |
72 __PrettyPrint(e); | 87 __PrettyPrint(e); |
73 } | 88 } |
74 this.getMessage = function(){ | 89 this.getMessage = function(){ |
75 __magic_index_for_mocked_worker = (__magic_index_for_mocked_worker + 1) % 10 | 90 __magic_index_for_mocked_worker = (__magic_index_for_mocked_worker + 1) % 10 |
76 return __magic_mocked_worker_messages[__magic_index_for_mocked_worker]; | 91 return __magic_mocked_worker_messages[__magic_index_for_mocked_worker]; |
77 } | 92 } |
78 this.postMessage = function(msg){ | 93 this.postMessage = function(msg){ |
79 __PrettyPrint(msg); | 94 __PrettyPrint(msg); |
80 } | 95 } |
81 } | 96 } |
OLD | NEW |