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

Side by Side Diff: test/mjsunit/object-literal.js

Issue 48006: Reapply revisions 1432, 1433, 1469 and 1472 while fixing issue 279. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 var arr = []; 52 var arr = [];
53 for (var i = 0; i < 2; i++) { 53 for (var i = 0; i < 2; i++) {
54 arr[i] = { 54 arr[i] = {
55 a: 7, 55 a: 7,
56 b: { x: 12, y: 24 }, 56 b: { x: 12, y: 24 },
57 c: 'Zebra' 57 c: 'Zebra'
58 } 58 }
59 } 59 }
60 60
61 arr[0].a = 2; 61 arr[0].b.x = 2;
62 assertEquals(2, arr[0].a); 62 assertEquals(2, arr[0].b.x);
63 assertEquals(7, arr[1].a); 63 assertEquals(12, arr[1].b.x);
64
65
66 function makeSparseArray() {
67 return {
68 '0': { x: 12, y: 24 },
69 '1000000': { x: 0, y: 0 }
70 };
71 }
72
73 var sa1 = makeSparseArray();
74 sa1[0].x = 0;
75 var sa2 = makeSparseArray();
76 assertEquals(12, sa2[0].x);
77
78 // Test that non-constant literals work.
79 var n = new Object();
80
81 function makeNonConstantArray() { return [ [ n ] ]; }
82
83 var a = makeNonConstantArray();
84 a[0][0].foo = "bar";
85 assertEquals("bar", n.foo);
86
87 function makeNonConstantObject() { return { a: { b: n } }; }
88
89 a = makeNonConstantObject();
90 a.a.b.bar = "foo";
91 assertEquals("foo", n.bar);
92
93 // Test that exceptions for regexps still hold.
94 function makeRegexpInArray() { return [ [ /a*/, {} ] ]; }
95
96 a = makeRegexpInArray();
97 var b = makeRegexpInArray();
98 assertTrue(a[0][0] === b[0][0]);
99 assertFalse(a[0][1] === b[0][1]);
100
101 function makeRegexpInObject() { return { a: { b: /b*/, c: {} } }; }
102 a = makeRegexpInObject();
103 b = makeRegexpInObject();
104 assertTrue(a.a.b === b.a.b);
105 assertFalse(a.a.c === b.a.c);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698