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

Unified Diff: test/cctest/test-code-stub-assembler.cc

Issue 2604273003: [csa] Refactor promises API (Closed)
Patch Set: comments Created 3 years, 12 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 | « src/code-stub-assembler.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-code-stub-assembler.cc
diff --git a/test/cctest/test-code-stub-assembler.cc b/test/cctest/test-code-stub-assembler.cc
index ca96b8420e12114056c4ce022d344c23758bd391..8bd5d099cc2e3f384c2b3e417ba5eb322c12fa74 100644
--- a/test/cctest/test-code-stub-assembler.cc
+++ b/test/cctest/test-code-stub-assembler.cc
@@ -1789,37 +1789,15 @@ TEST(IsPromiseHookEnabled) {
CHECK_EQ(isolate->heap()->false_value(), *result);
}
-TEST(AllocateJSPromise) {
+TEST(AllocateAndInitJSPromise) {
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 1;
CodeAssemblerTester data(isolate, kNumParams);
- CodeStubAssembler m(data.state());
-
- Node* const context = m.Parameter(kNumParams + 2);
- Node* const promise = m.AllocateJSPromise(context);
- m.PromiseInit(promise);
- m.Return(promise);
-
- Handle<Code> code = data.GenerateCode();
- CHECK(!code.is_null());
-
- FunctionTester ft(code, kNumParams);
- Handle<Object> result =
- ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
- CHECK(result->IsJSPromise());
-}
-
-TEST(PromiseInit) {
- Isolate* isolate(CcTest::InitIsolateOnce());
-
- const int kNumParams = 1;
- CodeAssemblerTester data(isolate, kNumParams);
- CodeStubAssembler m(data.state());
+ PromiseBuiltinsAssembler m(data.state());
Node* const context = m.Parameter(kNumParams + 2);
- Node* const promise = m.AllocateJSPromise(context);
- m.PromiseInit(promise);
+ Node* const promise = m.AllocateAndInitJSPromise(context);
m.Return(promise);
Handle<Code> code = data.GenerateCode();
@@ -1829,22 +1807,18 @@ TEST(PromiseInit) {
Handle<Object> result =
ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
CHECK(result->IsJSPromise());
- Handle<JSPromise> js_promise = Handle<JSPromise>::cast(result);
- CHECK_EQ(v8::Promise::kPending, js_promise->status());
- CHECK_EQ(isolate->heap()->undefined_value(), js_promise->result());
- CHECK(!js_promise->has_handler());
}
-TEST(PromiseSet) {
+TEST(AllocateAndSetJSPromise) {
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 1;
CodeAssemblerTester data(isolate, kNumParams);
- CodeStubAssembler m(data.state());
+ PromiseBuiltinsAssembler m(data.state());
Node* const context = m.Parameter(kNumParams + 2);
- Node* const promise = m.AllocateJSPromise(context);
- m.PromiseSet(promise, m.SmiConstant(v8::Promise::kPending), m.SmiConstant(1));
+ Node* const promise = m.AllocateAndSetJSPromise(
+ context, m.SmiConstant(v8::Promise::kPending), m.SmiConstant(1));
m.Return(promise);
Handle<Code> code = data.GenerateCode();
@@ -1866,10 +1840,10 @@ TEST(AllocatePromiseReactionJobInfo) {
const int kNumParams = 1;
CodeAssemblerTester data(isolate, kNumParams);
CodeStubAssembler m(data.state());
+ PromiseBuiltinsAssembler p(data.state());
Node* const context = m.Parameter(kNumParams + 2);
- Node* const promise = m.AllocateJSPromise(context);
- m.PromiseInit(promise);
+ Node* const promise = p.AllocateAndInitJSPromise(context);
Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1));
m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant());
Node* const deferred_promise =
@@ -1955,8 +1929,8 @@ TEST(PromiseHasHandler) {
PromiseBuiltinsAssembler m(data.state());
Node* const context = m.Parameter(kNumParams + 2);
- Node* const promise = m.AllocateJSPromise(context);
- m.PromiseInit(promise);
+ Node* const promise =
+ m.AllocateAndInitJSPromise(context, m.UndefinedConstant());
m.Return(m.SelectBooleanConstant(m.PromiseHasHandler(promise)));
Handle<Code> code = data.GenerateCode();
@@ -1977,8 +1951,8 @@ TEST(CreatePromiseResolvingFunctionsContext) {
Node* const context = m.Parameter(kNumParams + 2);
Node* const native_context = m.LoadNativeContext(context);
- Node* const promise = m.AllocateJSPromise(context);
- m.PromiseSet(promise, m.SmiConstant(v8::Promise::kPending), m.SmiConstant(1));
+ Node* const promise =
+ m.AllocateAndInitJSPromise(context, m.UndefinedConstant());
Node* const promise_context = m.CreatePromiseResolvingFunctionsContext(
promise, m.BooleanConstant(false), native_context);
m.Return(promise_context);
@@ -2009,8 +1983,8 @@ TEST(CreatePromiseResolvingFunctions) {
Node* const context = m.Parameter(kNumParams + 2);
Node* const native_context = m.LoadNativeContext(context);
- Node* const promise = m.AllocateJSPromise(context);
- m.PromiseSet(promise, m.SmiConstant(v8::Promise::kPending), m.SmiConstant(1));
+ Node* const promise =
+ m.AllocateAndInitJSPromise(context, m.UndefinedConstant());
Node *resolve, *reject;
std::tie(resolve, reject) = m.CreatePromiseResolvingFunctions(
promise, m.BooleanConstant(false), native_context);
@@ -2041,8 +2015,8 @@ TEST(AllocateFunctionWithMapAndContext) {
Node* const context = m.Parameter(kNumParams + 2);
Node* const native_context = m.LoadNativeContext(context);
- Node* const promise = m.AllocateJSPromise(context);
- m.PromiseSet(promise, m.SmiConstant(v8::Promise::kPending), m.SmiConstant(1));
+ Node* const promise =
+ m.AllocateAndInitJSPromise(context, m.UndefinedConstant());
Node* promise_context = m.CreatePromiseResolvingFunctionsContext(
promise, m.BooleanConstant(false), native_context);
Node* resolve_info =
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698