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

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

Issue 150103012: Revert "Implement Microtask Delivery Queue" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/mjsunit/fuzz-natives-part3.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28 #include "v8.h"
29
30 #include "cctest.h"
31
32 using namespace v8;
33 namespace i = v8::internal;
34
35 namespace {
36 class HarmonyIsolate {
37 public:
38 HarmonyIsolate() {
39 i::FLAG_harmony_observation = true;
40 i::FLAG_harmony_promises = true;
41 isolate_ = Isolate::New();
42 isolate_->Enter();
43 }
44
45 ~HarmonyIsolate() {
46 isolate_->Exit();
47 isolate_->Dispose();
48 }
49
50 Isolate* GetIsolate() const { return isolate_; }
51
52 private:
53 Isolate* isolate_;
54 };
55 }
56
57
58 TEST(MicrotaskDeliverySimple) {
59 HarmonyIsolate isolate;
60 HandleScope scope(isolate.GetIsolate());
61 LocalContext context(isolate.GetIsolate());
62 CompileRun(
63 "var ordering = [];"
64 "var resolver = {};"
65 "function handler(resolve) { resolver.resolve = resolve; }"
66 "var obj = {};"
67 "var observeOrders = [1, 4];"
68 "function observer() {"
69 "ordering.push(observeOrders.shift());"
70 "resolver.resolve();"
71 "}"
72 "var p = new Promise(handler);"
73 "p.then(function() {"
74 "ordering.push(2);"
75 "}).then(function() {"
76 "ordering.push(3);"
77 "obj.id++;"
78 "return new Promise(handler);"
79 "}).then(function() {"
80 "ordering.push(5);"
81 "}).then(function() {"
82 "ordering.push(6);"
83 "});"
84 "Object.observe(obj, observer);"
85 "obj.id = 1;");
86 CHECK_EQ(6, CompileRun("ordering.length")->Int32Value());
87 CHECK_EQ(1, CompileRun("ordering[0]")->Int32Value());
88 CHECK_EQ(2, CompileRun("ordering[1]")->Int32Value());
89 CHECK_EQ(3, CompileRun("ordering[2]")->Int32Value());
90 CHECK_EQ(4, CompileRun("ordering[3]")->Int32Value());
91 CHECK_EQ(5, CompileRun("ordering[4]")->Int32Value());
92 CHECK_EQ(6, CompileRun("ordering[5]")->Int32Value());
93 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/mjsunit/fuzz-natives-part3.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698