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

Side by Side Diff: test/mjsunit/es6/mirror-promises.js

Issue 283373003: Use %DebugGetProperty in debug mirror to check for Promise. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 | « src/promise.js ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 // Flags: --expose-debug-as debug --harmony-promises 5 // Flags: --expose-debug-as debug --harmony-promises
6 // Test the mirror object for promises. 6 // Test the mirror object for promises.
7 7
8 function MirrorRefCache(json_refs) { 8 function MirrorRefCache(json_refs) {
9 var tmp = eval('(' + json_refs + ')'); 9 var tmp = eval('(' + json_refs + ')');
10 this.refs_ = []; 10 this.refs_ = [];
(...skipping 21 matching lines...) Expand all
32 assertTrue(mirror instanceof debug.PromiseMirror); 32 assertTrue(mirror instanceof debug.PromiseMirror);
33 33
34 // Check the mirror properties. 34 // Check the mirror properties.
35 assertEquals(status, mirror.status()); 35 assertEquals(status, mirror.status());
36 assertTrue(mirror.isPromise()); 36 assertTrue(mirror.isPromise());
37 assertEquals('promise', mirror.type()); 37 assertEquals('promise', mirror.type());
38 assertFalse(mirror.isPrimitive()); 38 assertFalse(mirror.isPrimitive());
39 assertEquals("Object", mirror.className()); 39 assertEquals("Object", mirror.className());
40 assertEquals("#<Promise>", mirror.toText()); 40 assertEquals("#<Promise>", mirror.toText());
41 assertSame(promise, mirror.value()); 41 assertSame(promise, mirror.value());
42 assertEquals(value, mirror.promiseValue()); 42 assertTrue(mirror.promiseValue() instanceof debug.Mirror);
43 assertEquals(value, mirror.promiseValue().value());
43 44
44 // Parse JSON representation and check. 45 // Parse JSON representation and check.
45 var fromJSON = eval('(' + json + ')'); 46 var fromJSON = eval('(' + json + ')');
46 assertEquals('promise', fromJSON.type); 47 assertEquals('promise', fromJSON.type);
47 assertEquals('Object', fromJSON.className); 48 assertEquals('Object', fromJSON.className);
48 assertEquals('function', refs.lookup(fromJSON.constructorFunction.ref).type); 49 assertEquals('function', refs.lookup(fromJSON.constructorFunction.ref).type);
49 assertEquals('Promise', refs.lookup(fromJSON.constructorFunction.ref).name); 50 assertEquals('Promise', refs.lookup(fromJSON.constructorFunction.ref).name);
50 assertEquals(status, fromJSON.status); 51 assertEquals(status, fromJSON.status);
51 assertEquals(value, fromJSON.promiseValue); 52 assertEquals(value, refs.lookup(fromJSON.promiseValue.ref).value);
52 } 53 }
53 54
54 // Test a number of different promises. 55 // Test a number of different promises.
55 var resolved = new Promise(function(resolve, reject) { resolve() }); 56 var resolved = new Promise(function(resolve, reject) { resolve() });
56 var rejected = new Promise(function(resolve, reject) { reject() }); 57 var rejected = new Promise(function(resolve, reject) { reject() });
57 var pending = new Promise(function(resolve, reject) {}); 58 var pending = new Promise(function(resolve, reject) {});
58 59
59 testPromiseMirror(resolved, "resolved", undefined); 60 testPromiseMirror(resolved, "resolved", undefined);
60 testPromiseMirror(rejected, "rejected", undefined); 61 testPromiseMirror(rejected, "rejected", undefined);
61 testPromiseMirror(pending, "pending", undefined); 62 testPromiseMirror(pending, "pending", undefined);
(...skipping 17 matching lines...) Expand all
79 assertEquals(1, ip[1].value().value()); 80 assertEquals(1, ip[1].value().value());
80 81
81 var m2 = debug.MakeMirror(new Promise(function(resolve, reject) { reject(2) })); 82 var m2 = debug.MakeMirror(new Promise(function(resolve, reject) { reject(2) }));
82 ip = m2.internalProperties(); 83 ip = m2.internalProperties();
83 assertEquals("rejected", ip[0].value().value()); 84 assertEquals("rejected", ip[0].value().value());
84 assertEquals(2, ip[1].value().value()); 85 assertEquals(2, ip[1].value().value());
85 86
86 var m3 = debug.MakeMirror(new Promise(function(resolve, reject) { })); 87 var m3 = debug.MakeMirror(new Promise(function(resolve, reject) { }));
87 ip = m3.internalProperties(); 88 ip = m3.internalProperties();
88 assertEquals("pending", ip[0].value().value()); 89 assertEquals("pending", ip[0].value().value());
89 assertEquals("undefined", typeof(ip[1].value().value())); 90 assertEquals("undefined", typeof(ip[1].value().value()));
OLDNEW
« no previous file with comments | « src/promise.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698