blob: 5774952a944929349e3b88a224bd82638106946c [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5(function () {
6 var o = new String("ab");
7 function store(o, i, v) { o[i] = v; }
8 function load(o, i) { return o[i]; }
9
10 // Initialize the IC.
11 store(o, 2, 10);
12 load(o, 2);
13
14 store(o, 0, 100);
15 assertEquals("a", load(o, 0));
16})();
17
18(function () {
19 var o = {__proto__: new String("ab")};
20 function store(o, i, v) { o[i] = v; }
21 function load(o, i) { return o[i]; }
22
23 // Initialize the IC.
24 store(o, 2, 10);
25 load(o, 2);
26
27 store(o, 0, 100);
28 assertEquals("a", load(o, 0));
29})();
30
31(function () {
32 "use strict";
33 var o = {__proto__: {}};
34 function store(o, i, v) { o[i] = v; }
35
36 // Initialize the IC.
37 store(o, 0, 100);
38 o.__proto__.__proto__ = new String("bla");
39 assertThrows(function () { store(o, 1, 100) });
40})();