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

Side by Side Diff: test/cctest/test-microtask-delivery.cc

Issue 1163803002: Cosmetic changes to tests to make it easier to concatenate them. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix snapshot-external.cc Created 5 years, 6 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-hydrogen-types.cc ('k') | test/cctest/test-reloc-info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "src/v8.h" 28 #include "src/v8.h"
29 29
30 #include "test/cctest/cctest.h" 30 #include "test/cctest/cctest.h"
31 31
32 using namespace v8;
33 namespace i = v8::internal; 32 namespace i = v8::internal;
34 33
35 namespace { 34 namespace {
36 class HarmonyIsolate { 35 class HarmonyIsolate {
37 public: 36 public:
38 HarmonyIsolate() { 37 HarmonyIsolate() {
39 v8::Isolate::CreateParams create_params; 38 v8::Isolate::CreateParams create_params;
40 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); 39 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
41 isolate_ = Isolate::New(create_params); 40 isolate_ = v8::Isolate::New(create_params);
42 isolate_->Enter(); 41 isolate_->Enter();
43 } 42 }
44 43
45 ~HarmonyIsolate() { 44 ~HarmonyIsolate() {
46 isolate_->Exit(); 45 isolate_->Exit();
47 isolate_->Dispose(); 46 isolate_->Dispose();
48 } 47 }
49 48
50 Isolate* GetIsolate() const { return isolate_; } 49 v8::Isolate* GetIsolate() const { return isolate_; }
51 50
52 private: 51 private:
53 Isolate* isolate_; 52 v8::Isolate* isolate_;
54 }; 53 };
55 } 54 }
56 55
57 56
58 TEST(MicrotaskDeliverySimple) { 57 TEST(MicrotaskDeliverySimple) {
59 HarmonyIsolate isolate; 58 HarmonyIsolate isolate;
60 HandleScope scope(isolate.GetIsolate()); 59 v8::HandleScope scope(isolate.GetIsolate());
61 LocalContext context(isolate.GetIsolate()); 60 LocalContext context(isolate.GetIsolate());
62 CompileRun( 61 CompileRun(
63 "var ordering = [];" 62 "var ordering = [];"
64 "var resolver = {};" 63 "var resolver = {};"
65 "function handler(resolve) { resolver.resolve = resolve; }" 64 "function handler(resolve) { resolver.resolve = resolve; }"
66 "var obj = {};" 65 "var obj = {};"
67 "var observeOrders = [1, 4];" 66 "var observeOrders = [1, 4];"
68 "function observer() {" 67 "function observer() {"
69 "ordering.push(observeOrders.shift());" 68 "ordering.push(observeOrders.shift());"
70 "resolver.resolve();" 69 "resolver.resolve();"
(...skipping 17 matching lines...) Expand all
88 CHECK_EQ(2, CompileRun("ordering[1]")->Int32Value()); 87 CHECK_EQ(2, CompileRun("ordering[1]")->Int32Value());
89 CHECK_EQ(3, CompileRun("ordering[2]")->Int32Value()); 88 CHECK_EQ(3, CompileRun("ordering[2]")->Int32Value());
90 CHECK_EQ(4, CompileRun("ordering[3]")->Int32Value()); 89 CHECK_EQ(4, CompileRun("ordering[3]")->Int32Value());
91 CHECK_EQ(5, CompileRun("ordering[4]")->Int32Value()); 90 CHECK_EQ(5, CompileRun("ordering[4]")->Int32Value());
92 CHECK_EQ(6, CompileRun("ordering[5]")->Int32Value()); 91 CHECK_EQ(6, CompileRun("ordering[5]")->Int32Value());
93 } 92 }
94 93
95 94
96 TEST(MicrotaskPerIsolateState) { 95 TEST(MicrotaskPerIsolateState) {
97 HarmonyIsolate isolate; 96 HarmonyIsolate isolate;
98 HandleScope scope(isolate.GetIsolate()); 97 v8::HandleScope scope(isolate.GetIsolate());
99 LocalContext context1(isolate.GetIsolate()); 98 LocalContext context1(isolate.GetIsolate());
100 isolate.GetIsolate()->SetAutorunMicrotasks(false); 99 isolate.GetIsolate()->SetAutorunMicrotasks(false);
101 CompileRun( 100 CompileRun(
102 "var obj = { calls: 0 };"); 101 "var obj = { calls: 0 };");
103 Handle<Value> obj = CompileRun("obj"); 102 v8::Handle<v8::Value> obj = CompileRun("obj");
104 { 103 {
105 LocalContext context2(isolate.GetIsolate()); 104 LocalContext context2(isolate.GetIsolate());
106 context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), 105 context2->Global()->Set(
107 obj); 106 v8::String::NewFromUtf8(isolate.GetIsolate(), "obj"), obj);
108 CompileRun( 107 CompileRun(
109 "var resolver = {};" 108 "var resolver = {};"
110 "new Promise(function(resolve) {" 109 "new Promise(function(resolve) {"
111 "resolver.resolve = resolve;" 110 "resolver.resolve = resolve;"
112 "}).then(function() {" 111 "}).then(function() {"
113 "obj.calls++;" 112 "obj.calls++;"
114 "});" 113 "});"
115 "(function() {" 114 "(function() {"
116 "resolver.resolve();" 115 "resolver.resolve();"
117 "})();"); 116 "})();");
118 } 117 }
119 { 118 {
120 LocalContext context3(isolate.GetIsolate()); 119 LocalContext context3(isolate.GetIsolate());
121 context3->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), 120 context3->Global()->Set(
122 obj); 121 v8::String::NewFromUtf8(isolate.GetIsolate(), "obj"), obj);
123 CompileRun( 122 CompileRun(
124 "var foo = { id: 1 };" 123 "var foo = { id: 1 };"
125 "Object.observe(foo, function() {" 124 "Object.observe(foo, function() {"
126 "obj.calls++;" 125 "obj.calls++;"
127 "});" 126 "});"
128 "foo.id++;"); 127 "foo.id++;");
129 } 128 }
130 { 129 {
131 LocalContext context4(isolate.GetIsolate()); 130 LocalContext context4(isolate.GetIsolate());
132 context4->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), 131 context4->Global()->Set(
133 obj); 132 v8::String::NewFromUtf8(isolate.GetIsolate(), "obj"), obj);
134 isolate.GetIsolate()->RunMicrotasks(); 133 isolate.GetIsolate()->RunMicrotasks();
135 CHECK_EQ(2, CompileRun("obj.calls")->Int32Value()); 134 CHECK_EQ(2, CompileRun("obj.calls")->Int32Value());
136 } 135 }
137 } 136 }
OLDNEW
« no previous file with comments | « test/cctest/test-hydrogen-types.cc ('k') | test/cctest/test-reloc-info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698