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

Side by Side Diff: test/mjsunit/bugs/bug-2615.js

Issue 656683003: Revert "Remove SmartMove, bringing Array methods further into spec compliance" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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/array-unshift.js ('k') | test/mjsunit/regress/regress-2615.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
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 var a = [];
29 a[0xfffffffe] = 10;
30 assertThrows("a.unshift(1);", RangeError);
31 assertEquals(0xffffffff, a.length);
32 assertEquals(10, a[0xffffffff]);
33 assertEquals(undefined, a[0xfffffffe]);
34
35 a = [1,2,3];
36 a[0xfffffffe] = 10;
37 assertThrows("a.splice(1,1,7,7,7,7,7);", RangeError);
38 assertEquals([1,7,7,7,7,7,3], a.slice(0, 7));
39 assertEquals(0xffffffff, a.length);
40 assertEquals(10, a[0xfffffffe + 5 - 1]);
41
42 a = [1];
43 Object.defineProperty(a, "1", {writable:false, configurable:false, value: 100});
44 assertThrows("a.unshift(4);", TypeError);
45 assertEquals([1, 100, 100], a);
46 var desc = Object.getOwnPropertyDescriptor(a, "1");
47 assertEquals(false, desc.writable);
48 assertEquals(false, desc.configurable);
49
50 a = [1];
51 var g = function() { return 100; };
52 Object.defineProperty(a, "1", {get:g});
53 assertThrows("a.unshift(0);", TypeError);
54 assertEquals([1, 100, 100], a);
55 desc = Object.getOwnPropertyDescriptor(a, "1");
56 assertEquals(false, desc.configurable);
57 assertEquals(g, desc.get);
58
59 a = [1];
60 var c = 0;
61 var s = function(v) { c += 1; };
62 Object.defineProperty(a, "1", {set:s});
63 a.unshift(10);
64 assertEquals([10, undefined, undefined], a);
65 assertEquals(1, c);
66 desc = Object.getOwnPropertyDescriptor(a, "1");
67 assertEquals(false, desc.configurable);
68 assertEquals(s, desc.set);
69
70 a = [1];
71 Object.defineProperty(a, "1", {configurable:false, value:10});
72 assertThrows("a.splice(1,1);", TypeError);
73 assertEquals([1, 10], a);
74 desc = Object.getOwnPropertyDescriptor(a, "1");
75 assertEquals(false, desc.configurable);
76
77 a = [0,1,2,3,4,5,6];
78 Object.defineProperty(a, "3", {configurable:false, writable:false, value:3});
79 assertThrows("a.splice(1,4);", TypeError);
80 assertEquals([0,5,6,3,,,,,], a);
81 desc = Object.getOwnPropertyDescriptor(a, "3");
82 assertEquals(false, desc.configurable);
83 assertEquals(false, desc.writable);
84
85 a = [0,1,2,3,4,5,6];
86 Object.defineProperty(a, "5", {configurable:false, value:5});
87 assertThrows("a.splice(1,4);", TypeError);
88 assertEquals([0,5,6,3,4,5,,,], a);
89 desc = Object.getOwnPropertyDescriptor(a, "5");
90 assertEquals(false, desc.configurable);
91
92 a = [1,2,3,,5];
93 Object.defineProperty(a, "1", {configurable:false, writable:true, value:2});
94 assertEquals(1, a.shift());
95 assertEquals([2,3,,5], a);
96 desc = Object.getOwnPropertyDescriptor(a, "1");
97 assertEquals(false, desc.configurable);
98 assertEquals(true, desc.writable);
99 assertThrows("a.shift();", TypeError);
100 assertEquals([3,3,,5], a);
101 desc = Object.getOwnPropertyDescriptor(a, "1");
102 assertEquals(false, desc.configurable);
103 assertEquals(true, desc.writable);
104
105 a = [1,2,3];
106 Object.defineProperty(a, "2", {configurable:false, value:3});
107 assertThrows("a.pop();", TypeError);
108 assertEquals([1,2,3], a);
109 desc = Object.getOwnPropertyDescriptor(a, "2");
110 assertEquals(false, desc.configurable);
111
28 a = [1,2,,,5]; 112 a = [1,2,,,5];
29 Object.defineProperty(a, "4", {writable:true, configurable:false, value:5}); 113 Object.defineProperty(a, "4", {writable:true, configurable:false, value:5});
30 assertThrows("a.sort();", TypeError); 114 assertThrows("a.sort();", TypeError);
31 assertEquals([1,2,5,,5], a); 115 assertEquals([1,2,5,,5], a);
32 desc = Object.getOwnPropertyDescriptor(a, "2"); 116 desc = Object.getOwnPropertyDescriptor(a, "2");
33 assertEquals(true, desc.configurable); 117 assertEquals(true, desc.configurable);
34 desc = Object.getOwnPropertyDescriptor(a, "4"); 118 desc = Object.getOwnPropertyDescriptor(a, "4");
35 assertEquals(false, desc.configurable); 119 assertEquals(false, desc.configurable);
36 120
37 a = [1,2,3,,5,6]; 121 a = [1,2,3,,5,6];
38 Object.defineProperty(a, "4", {value:5, writable:false}); 122 Object.defineProperty(a, "4", {value:5, writable:false});
39 assertThrows("a.sort();", TypeError); 123 assertThrows("a.sort();", TypeError);
40 assertEquals([1,2,3,5,5,6], a); 124 assertEquals([1,2,3,5,5,6], a);
41 desc = Object.getOwnPropertyDescriptor(a, "4"); 125 desc = Object.getOwnPropertyDescriptor(a, "4");
42 assertEquals(false, desc.writable); 126 assertEquals(false, desc.writable);
OLDNEW
« no previous file with comments | « test/mjsunit/array-unshift.js ('k') | test/mjsunit/regress/regress-2615.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698