OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 (function (global, binding, v8) { | 5 (function (global, binding, v8) { |
6 'use strict'; | 6 'use strict'; |
7 binding.testExtraShouldReturnFive = function() { | 7 binding.testExtraShouldReturnFive = function() { |
8 return 5; | 8 return 5; |
9 }; | 9 }; |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 const Object = global.Object; | 21 const Object = global.Object; |
22 const hasOwn = v8.uncurryThis(Object.prototype.hasOwnProperty); | 22 const hasOwn = v8.uncurryThis(Object.prototype.hasOwnProperty); |
23 | 23 |
24 const Function = global.Function; | 24 const Function = global.Function; |
25 const call = v8.uncurryThis(Function.prototype.call); | 25 const call = v8.uncurryThis(Function.prototype.call); |
26 const apply = v8.uncurryThis(Function.prototype.apply); | 26 const apply = v8.uncurryThis(Function.prototype.apply); |
27 | 27 |
28 const Promise = global.Promise; | 28 const Promise = global.Promise; |
29 const Promise_resolve = v8.simpleBind(Promise.resolve, Promise); | 29 const Promise_resolve = v8.simpleBind(Promise.resolve, Promise); |
30 | 30 |
| 31 const arrayToTest = new v8.InternalPackedArray(); |
| 32 arrayToTest.push(1); |
| 33 arrayToTest.push(2); |
| 34 arrayToTest.pop(); |
| 35 arrayToTest.unshift("a", "b", "c"); |
| 36 arrayToTest.shift(); |
| 37 arrayToTest.splice(0, 1); |
| 38 const slicedArray = arrayToTest.slice(); |
| 39 const arraysOK = arrayToTest.length === 2 && arrayToTest[0] === "c" && |
| 40 arrayToTest[1] === 1 && slicedArray.length === 2 && |
| 41 slicedArray[0] === "c" && slicedArray[1] === 1; |
| 42 |
31 binding.testExtraCanUseUtils = function() { | 43 binding.testExtraCanUseUtils = function() { |
32 const fulfilledPromise = v8.createPromise(); | 44 const fulfilledPromise = v8.createPromise(); |
33 v8.resolvePromise( | 45 v8.resolvePromise( |
34 fulfilledPromise, | 46 fulfilledPromise, |
35 hasOwn({ test: 'test' }, 'test') ? 1 : -1 | 47 hasOwn({ test: 'test' }, 'test') ? 1 : -1 |
36 ); | 48 ); |
37 | 49 |
38 const fulfilledPromise2 = Promise_resolve(call(function (arg1) { | 50 const fulfilledPromise2 = Promise_resolve(call(function (arg1, arg2) { |
39 return (this.prop === arg1 && arg1 === 'value') ? 2 : -1; | 51 return (this.prop === arg1 && arg1 === 'value' && arg2) ? 2 : -1; |
40 }, { prop: 'value' }, 'value')); | 52 }, { prop: 'value' }, 'value', arraysOK)); |
41 | 53 |
42 const rejectedPromise = v8.createPromise(); | 54 const rejectedPromise = v8.createPromise(); |
43 v8.rejectPromise(rejectedPromise, apply(function (arg1, arg2) { | 55 v8.rejectPromise(rejectedPromise, apply(function (arg1, arg2) { |
44 return (arg1 === arg2 && arg2 === 'x') ? 3 : -1; | 56 return (arg1 === arg2 && arg2 === 'x') ? 3 : -1; |
45 }, null, new v8.InternalPackedArray('x', 'x'))); | 57 }, null, new v8.InternalPackedArray('x', 'x'))); |
46 | 58 |
47 return { | 59 return { |
48 privateSymbol: v8.createPrivateSymbol('sym'), | 60 privateSymbol: v8.createPrivateSymbol('sym'), |
49 fulfilledPromise, // should be fulfilled with 1 | 61 fulfilledPromise, // should be fulfilled with 1 |
50 fulfilledPromise2, // should be fulfilled with 2 | 62 fulfilledPromise2, // should be fulfilled with 2 |
51 rejectedPromise // should be rejected with 3 | 63 rejectedPromise // should be rejected with 3 |
52 }; | 64 }; |
53 }; | 65 }; |
54 }) | 66 }) |
OLD | NEW |