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

Side by Side Diff: test/mjsunit/string-wrapper.js

Issue 1873833002: [elements] Add more tests to increase coverage (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« test/mjsunit/array-splice.js ('K') | « test/mjsunit/delete.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 var limit = 10000; 5 var limit = 10000;
6 6
7 function testStringWrapper(string) { 7 function testStringWrapper(string) {
8 assertEquals('a', string[0]); 8 assertEquals('a', string[0]);
9 assertEquals('b', string[1]); 9 assertEquals('b', string[1]);
10 assertEquals('c', string[2]); 10 assertEquals('c', string[2]);
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 testStringWrapper(string); 33 testStringWrapper(string);
34 assertEquals(limit, string[limit]); 34 assertEquals(limit, string[limit]);
35 35
36 for (var i = limit; i > 0; i -= 2) { 36 for (var i = limit; i > 0; i -= 2) {
37 delete string[i]; 37 delete string[i];
38 } 38 }
39 testStringWrapper(string); 39 testStringWrapper(string);
40 assertEquals(undefined, string[limit]); 40 assertEquals(undefined, string[limit]);
41 })(); 41 })();
42
43
44 (function testReconfigureStringWrapperElements() {
45 var s = new String('abc');
46 // Can't reconfigure string contents.
47 assertThrows(() => Object.defineProperty(s, '1', {value: "value"}), TypeError) ;
48
49 // Configure a property outside the string range
50 var value = 'v1';
51 Object.defineProperty(s, '3', {
52 get: () => {return value},
53 configurable:true
54 });
55 assertEquals('v1', s[3]);
56 value = 'v2';
57 assertEquals('v2', s[3]);
58
59 Object.defineProperty(s, '3', {value: 'v3', configurable: false});
60 assertEquals('v3', s[3]);
61 assertThrows(() => Object.defineProperty(s, '3', {value:2}), TypeError);
62 })();
OLDNEW
« test/mjsunit/array-splice.js ('K') | « test/mjsunit/delete.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698