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

Side by Side Diff: test/mjsunit/mirror-error.js

Issue 18092: Added handles to the mirror objects. When a mirror for an object is created... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/mirror-date.js ('k') | test/mjsunit/mirror-function.js » ('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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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 // Flags: --expose-debug-as debug 28 // Flags: --expose-debug-as debug
29 // Test the mirror object for regular error objects 29 // Test the mirror object for regular error objects
30 30
31 function MirrorRefCache(json_refs) {
32 var tmp = eval('(' + json_refs + ')');
33 this.refs_ = [];
34 for (var i = 0; i < tmp.length; i++) {
35 this.refs_[tmp[i].handle] = tmp[i];
36 }
37 }
38
39 MirrorRefCache.prototype.lookup = function(handle) {
40 return this.refs_[handle];
41 }
42
31 function testErrorMirror(e) { 43 function testErrorMirror(e) {
32 // Create mirror and JSON representation. 44 // Create mirror and JSON representation.
33 var mirror = debug.MakeMirror(e); 45 var mirror = debug.MakeMirror(e);
34 var json = mirror.toJSONProtocol(true); 46 var serializer = debug.MakeMirrorSerializer();
47 var json = serializer.serializeValue(mirror);
48 var refs = new MirrorRefCache(serializer.serializeReferencedObjects());
35 49
36 // Check the mirror hierachy. 50 // Check the mirror hierachy.
37 assertTrue(mirror instanceof debug.Mirror); 51 assertTrue(mirror instanceof debug.Mirror);
38 assertTrue(mirror instanceof debug.ValueMirror); 52 assertTrue(mirror instanceof debug.ValueMirror);
39 assertTrue(mirror instanceof debug.ObjectMirror); 53 assertTrue(mirror instanceof debug.ObjectMirror);
40 assertTrue(mirror instanceof debug.ErrorMirror); 54 assertTrue(mirror instanceof debug.ErrorMirror);
41 55
42 // Check the mirror properties. 56 // Check the mirror properties.
43 assertTrue(mirror.isError()); 57 assertTrue(mirror.isError());
44 assertEquals('error', mirror.type()); 58 assertEquals('error', mirror.type());
45 assertFalse(mirror.isPrimitive()); 59 assertFalse(mirror.isPrimitive());
46 assertEquals(mirror.message(), e.message, 'source'); 60 assertEquals(mirror.message(), e.message, 'source');
47 61
48 // Parse JSON representation and check. 62 // Parse JSON representation and check.
49 var fromJSON = eval('(' + json + ')'); 63 var fromJSON = eval('(' + json + ')');
50 assertEquals('error', fromJSON.type); 64 assertEquals('error', fromJSON.type);
51 assertEquals('Error', fromJSON.className); 65 assertEquals('Error', fromJSON.className);
52 assertEquals(fromJSON.message, e.message, 'message'); 66 if (e.message) {
67 var found_message = false;
68 for (var i in fromJSON.properties) {
69 var p = fromJSON.properties[i];
70 print(p.name);
71 if (p.name == 'message') {
72 assertEquals(e.message, refs.lookup(p.ref).value);
73 found_message = true;
74 }
75 }
76 assertTrue(found_message, 'Property message not found');
77 }
53 78
54 // Check the formatted text (regress 1231579). 79 // Check the formatted text (regress 1231579).
55 assertEquals(fromJSON.text, e.toString(), 'toString'); 80 assertEquals(fromJSON.text, e.toString(), 'toString');
56 } 81 }
57 82
58 83
59 // Test Date values. 84 // Test Date values.
60 testErrorMirror(new Error()); 85 testErrorMirror(new Error());
61 testErrorMirror(new Error('This does not work')); 86 testErrorMirror(new Error('This does not work'));
62 testErrorMirror(new Error(123+456)); 87 testErrorMirror(new Error(123+456));
63 testErrorMirror(new EvalError('EvalError')); 88 testErrorMirror(new EvalError('EvalError'));
64 testErrorMirror(new RangeError('RangeError')); 89 testErrorMirror(new RangeError('RangeError'));
65 testErrorMirror(new ReferenceError('ReferenceError')); 90 testErrorMirror(new ReferenceError('ReferenceError'));
66 testErrorMirror(new SyntaxError('SyntaxError')); 91 testErrorMirror(new SyntaxError('SyntaxError'));
67 testErrorMirror(new TypeError('TypeError')); 92 testErrorMirror(new TypeError('TypeError'));
68 testErrorMirror(new URIError('URIError')); 93 testErrorMirror(new URIError('URIError'));
OLDNEW
« no previous file with comments | « test/mjsunit/mirror-date.js ('k') | test/mjsunit/mirror-function.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698