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

Side by Side Diff: test/cctest/test-code-stub-assembler.cc

Issue 2633443002: [promisehook] Pass deferred promise to Before/After callback (Closed)
Patch Set: Remove adaptor Created 3 years, 11 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
« no previous file with comments | « 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 #include "src/base/utils/random-number-generator.h" 5 #include "src/base/utils/random-number-generator.h"
6 #include "src/builtins/builtins-promise.h" 6 #include "src/builtins/builtins-promise.h"
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stub-assembler.h" 8 #include "src/code-stub-assembler.h"
9 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 1816
1817 TEST(AllocatePromiseReactionJobInfo) { 1817 TEST(AllocatePromiseReactionJobInfo) {
1818 Isolate* isolate(CcTest::InitIsolateOnce()); 1818 Isolate* isolate(CcTest::InitIsolateOnce());
1819 1819
1820 const int kNumParams = 1; 1820 const int kNumParams = 1;
1821 CodeAssemblerTester data(isolate, kNumParams); 1821 CodeAssemblerTester data(isolate, kNumParams);
1822 CodeStubAssembler m(data.state()); 1822 CodeStubAssembler m(data.state());
1823 PromiseBuiltinsAssembler p(data.state()); 1823 PromiseBuiltinsAssembler p(data.state());
1824 1824
1825 Node* const context = m.Parameter(kNumParams + 2); 1825 Node* const context = m.Parameter(kNumParams + 2);
1826 Node* const promise = p.AllocateAndInitJSPromise(context);
1827 Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); 1826 Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1));
1828 m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant()); 1827 m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant());
1829 Node* const deferred_promise = 1828 Node* const deferred_promise =
1830 m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); 1829 m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1));
1831 m.StoreFixedArrayElement(deferred_promise, 0, m.UndefinedConstant()); 1830 m.StoreFixedArrayElement(deferred_promise, 0, m.UndefinedConstant());
1832 Node* const info = m.AllocatePromiseReactionJobInfo( 1831 Node* const info = m.AllocatePromiseReactionJobInfo(
1833 promise, m.SmiConstant(1), tasks, deferred_promise, m.UndefinedConstant(), 1832 m.SmiConstant(1), tasks, deferred_promise, m.UndefinedConstant(),
1834 m.UndefinedConstant(), context); 1833 m.UndefinedConstant(), context);
1835 m.Return(info); 1834 m.Return(info);
1836 1835
1837 Handle<Code> code = data.GenerateCode(); 1836 Handle<Code> code = data.GenerateCode();
1838 CHECK(!code.is_null()); 1837 CHECK(!code.is_null());
1839 1838
1840 FunctionTester ft(code, kNumParams); 1839 FunctionTester ft(code, kNumParams);
1841 Handle<Object> result = 1840 Handle<Object> result =
1842 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 1841 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1843 CHECK(result->IsPromiseReactionJobInfo()); 1842 CHECK(result->IsPromiseReactionJobInfo());
1844 Handle<PromiseReactionJobInfo> promise_info = 1843 Handle<PromiseReactionJobInfo> promise_info =
1845 Handle<PromiseReactionJobInfo>::cast(result); 1844 Handle<PromiseReactionJobInfo>::cast(result);
1846 CHECK_EQ(Smi::FromInt(1), promise_info->value()); 1845 CHECK_EQ(Smi::FromInt(1), promise_info->value());
1847 CHECK(promise_info->promise()->IsJSPromise());
1848 CHECK(promise_info->tasks()->IsFixedArray()); 1846 CHECK(promise_info->tasks()->IsFixedArray());
1849 CHECK(promise_info->deferred_promise()->IsFixedArray()); 1847 CHECK(promise_info->deferred_promise()->IsFixedArray());
1850 CHECK(promise_info->deferred_on_resolve()->IsUndefined(isolate)); 1848 CHECK(promise_info->deferred_on_resolve()->IsUndefined(isolate));
1851 CHECK(promise_info->deferred_on_reject()->IsUndefined(isolate)); 1849 CHECK(promise_info->deferred_on_reject()->IsUndefined(isolate));
1852 CHECK(promise_info->context()->IsContext()); 1850 CHECK(promise_info->context()->IsContext());
1853 CHECK_EQ(kDebugPromiseNoID, promise_info->debug_id()); 1851 CHECK_EQ(kDebugPromiseNoID, promise_info->debug_id());
1854 CHECK_EQ(kDebugNotActive, promise_info->debug_name()); 1852 CHECK_EQ(kDebugNotActive, promise_info->debug_name());
1855 } 1853 }
1856 1854
1857 TEST(AllocatePromiseResolveThenableJobInfo) { 1855 TEST(AllocatePromiseResolveThenableJobInfo) {
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 .ToHandleChecked(); 2272 .ToHandleChecked();
2275 Handle<Object> prop2 = 2273 Handle<Object> prop2 =
2276 JSReceiver::GetProperty(isolate, promise, "rejectedReason") 2274 JSReceiver::GetProperty(isolate, promise, "rejectedReason")
2277 .ToHandleChecked(); 2275 .ToHandleChecked();
2278 CHECK_EQ(*rejected_str, *prop2); 2276 CHECK_EQ(*rejected_str, *prop2);
2279 } 2277 }
2280 } 2278 }
2281 2279
2282 } // namespace internal 2280 } // namespace internal
2283 } // namespace v8 2281 } // namespace v8
OLDNEW
« 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