Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: test/cctest/test-extra.js

Issue 1343113003: Implement V8 extras utils object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment fix Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/prologue.js ('K') | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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) { 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
11 binding.testExtraShouldCallToRuntime = function() { 11 binding.testExtraShouldCallToRuntime = function() {
12 return binding.runtime(3); 12 return binding.runtime(3);
13 }; 13 };
14
15 // Exercise all of the extras utils:
16 // - v8.createPrivateSymbol
17 // - v8.call, v8.apply, v8.simpleBind, v8.uncurryThis
18 // - v8.InternalPackedArray
19 // - v8.createPromise, v8.resolvePromise, v8.rejectPromise
20
21 const Object = global.Object;
22 const hasOwn = v8.uncurryThis(Object.prototype.hasOwnProperty);
23
24 const Promise = global.Promise;
25 const Promise_resolve = v8.simpleBind(Promise.resolve, Promise);
26
27 binding.testExtraCanUseUtils = function() {
28 const fulfilledPromise = v8.createPromise();
29 v8.resolvePromise(
30 fulfilledPromise,
31 hasOwn({ test: 'test' }, 'test') ? 1 : -1
32 );
33
34 const fulfilledPromise2 = Promise_resolve(v8.call(function (arg1) {
35 return (this.prop === arg1 && arg1 === 'value') ? 2 : -1;
36 }, { prop: 'value' }, 'value'));
37
38 const rejectedPromise = v8.createPromise();
39 v8.rejectPromise(rejectedPromise, v8.apply(function (arg1, arg2) {
40 return (arg1 === arg2 && arg2 === 'x') ? 3 : -1;
41 }, null, new v8.InternalPackedArray('x', 'x')));
42
43 return {
44 privateSymbol: v8.createPrivateSymbol('sym'),
45 fulfilledPromise, // should be fulfilled with 1
46 fulfilledPromise2, // should be fulfilled with 2
47 rejectedPromise // should be rejected with 3
48 };
49 };
14 }) 50 })
OLDNEW
« src/prologue.js ('K') | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698