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

Unified 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: Remove call/apply helpers 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-extra.js
diff --git a/test/cctest/test-extra.js b/test/cctest/test-extra.js
index f943ea6c4e5adedb79b2c44213cdcf6a8ba56c60..123c8920d04d18d35a628ca6209b05133af2fd03 100644
--- a/test/cctest/test-extra.js
+++ b/test/cctest/test-extra.js
@@ -2,13 +2,53 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function (global, binding) {
+(function (global, binding, v8) {
'use strict';
- binding.testExtraShouldReturnFive = function () {
+ binding.testExtraShouldReturnFive = function() {
return 5;
};
binding.testExtraShouldCallToRuntime = function() {
return binding.runtime(3);
};
+
+ // Exercise all of the extras utils:
+ // - v8.createPrivateSymbol
+ // - v8.simpleBind, v8.uncurryThis
+ // - v8.InternalPackedArray
+ // - v8.createPromise, v8.resolvePromise, v8.rejectPromise
+
+ const Object = global.Object;
+ const hasOwn = v8.uncurryThis(Object.prototype.hasOwnProperty);
+
+ const Function = global.Function;
+ const call = v8.uncurryThis(Function.prototype.call);
+ const apply = v8.uncurryThis(Function.prototype.apply);
+
+ const Promise = global.Promise;
+ const Promise_resolve = v8.simpleBind(Promise.resolve, Promise);
+
+ binding.testExtraCanUseUtils = function() {
+ const fulfilledPromise = v8.createPromise();
+ v8.resolvePromise(
+ fulfilledPromise,
+ hasOwn({ test: 'test' }, 'test') ? 1 : -1
+ );
+
+ const fulfilledPromise2 = Promise_resolve(call(function (arg1) {
+ return (this.prop === arg1 && arg1 === 'value') ? 2 : -1;
+ }, { prop: 'value' }, 'value'));
+
+ const rejectedPromise = v8.createPromise();
+ v8.rejectPromise(rejectedPromise, apply(function (arg1, arg2) {
+ return (arg1 === arg2 && arg2 === 'x') ? 3 : -1;
+ }, null, new v8.InternalPackedArray('x', 'x')));
+
+ return {
+ privateSymbol: v8.createPrivateSymbol('sym'),
+ fulfilledPromise, // should be fulfilled with 1
+ fulfilledPromise2, // should be fulfilled with 2
+ rejectedPromise // should be rejected with 3
+ };
+ };
})
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698