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

Side by Side Diff: test/mjsunit/strong/object-freeze-property.js

Issue 1773653002: [strong] Remove all remainders of strong mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Oversight Created 4 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
« no previous file with comments | « test/mjsunit/strong/object-delete.js ('k') | test/mjsunit/strong/object-set-prototype.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // 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 // Flags: --strong-mode --allow-natives-syntax
6
7 // TODO(conradw): Track implementation of strong bit for other objects, add
8 // tests.
9
10 function getSloppyObjects() {
11 return [(function(){}), ({})];
12 }
13
14 function getStrictObjects() {
15 "use strict";
16 return [(function(){}), ({})];
17 }
18
19 function getStrongObjects() {
20 "use strong";
21 // Strong functions can't have properties added to them.
22 return [{}];
23 }
24
25 (function testStrongObjectFreezePropValid() {
26 "use strict";
27 let strongObjects = getStrongObjects();
28
29 for (let o of strongObjects) {
30 Object.defineProperty(o, "foo", { configurable: true, writable: true });
31 assertDoesNotThrow(
32 function() {
33 "use strong";
34 Object.defineProperty(o, "foo", {configurable: true, writable: false });
35 });
36 }
37 })();
38
39 (function testStrongObjectFreezePropInvalid() {
40 "use strict";
41 let sloppyObjects = getSloppyObjects();
42 let strictObjects = getStrictObjects();
43 let strongObjects = getStrongObjects();
44 let weakObjects = sloppyObjects.concat(strictObjects);
45
46 for (let o of weakObjects) {
47 Object.defineProperty(o, "foo", { writable: true });
48 assertDoesNotThrow(
49 function() {
50 "use strong";
51 Object.defineProperty(o, "foo", { writable: false });
52 });
53 }
54 for (let o of strongObjects) {
55 function defProp(o) {
56 Object.defineProperty(o, "foo", { writable: false });
57 }
58 function defProps(o) {
59 Object.defineProperties(o, { "foo": { writable: false } });
60 }
61 function freezeProp(o) {
62 Object.freeze(o);
63 }
64 Object.defineProperty(o, "foo", { writable: true });
65 for (let func of [defProp, defProps, freezeProp]) {
66 assertThrows(function(){func(o)}, TypeError);
67 assertThrows(function(){func(o)}, TypeError);
68 assertThrows(function(){func(o)}, TypeError);
69 %OptimizeFunctionOnNextCall(func);
70 assertThrows(function(){func(o)}, TypeError);
71 %DeoptimizeFunction(func);
72 assertThrows(function(){func(o)}, TypeError);
73 }
74 }
75 })();
OLDNEW
« no previous file with comments | « test/mjsunit/strong/object-delete.js ('k') | test/mjsunit/strong/object-set-prototype.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698