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

Side by Side Diff: test/mjsunit/strong/class-object-frozen.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/class-literals.js ('k') | test/mjsunit/strong/classes.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
6
7 "use strict";
8
9 function getClass() {
10 class Foo {
11 static get bar() { return 0 }
12 get bar() { return 0 }
13 }
14 return Foo;
15 }
16
17 function getClassExpr() {
18 return (class { static get bar() { return 0 } get bar() { return 0 } });
19 }
20
21 function getClassStrong() {
22 "use strong";
23 class Foo {
24 static get bar() { return 0 }
25 get bar() { return 0 }
26 }
27 return Foo;
28 }
29
30 function getClassExprStrong() {
31 "use strong";
32 return (class { static get bar() { return 0 } get bar() { return 0 } });
33 }
34
35 function addProperty(o) {
36 o.baz = 1;
37 }
38
39 function convertPropertyToData(o) {
40 assertTrue(o.hasOwnProperty("bar"));
41 Object.defineProperty(o, "bar", { value: 1 });
42 }
43
44 function testWeakClass(classFunc) {
45 assertDoesNotThrow(function(){addProperty(classFunc())});
46 assertDoesNotThrow(function(){addProperty(classFunc().prototype)});
47 assertDoesNotThrow(function(){convertPropertyToData(classFunc())});
48 assertDoesNotThrow(function(){convertPropertyToData(classFunc().prototype)});
49 }
50
51 function testStrongClass(classFunc) {
52 assertThrows(function(){addProperty(classFunc())}, TypeError);
53 assertThrows(function(){addProperty(classFunc().prototype)}, TypeError);
54 assertThrows(function(){convertPropertyToData(classFunc())}, TypeError);
55 assertThrows(function(){convertPropertyToData(classFunc().prototype)},
56 TypeError);
57 }
58
59 testWeakClass(getClass);
60 testWeakClass(getClassExpr);
61
62 testStrongClass(getClassStrong);
63 testStrongClass(getClassExprStrong);
64
65 // Check strong classes don't freeze their parents.
66 (function() {
67 let parent = getClass();
68
69 let classFunc = function() {
70 "use strong";
71 class Foo extends parent {
72 static get bar() { return 0 }
73 get bar() { return 0 }
74 }
75 return Foo;
76 }
77
78 testStrongClass(classFunc);
79 assertDoesNotThrow(function(){addProperty(parent)});
80 assertDoesNotThrow(function(){convertPropertyToData(parent)});
81 })();
82
83 // Check strong classes don't freeze their children.
84 (function() {
85 let parent = getClassStrong();
86
87 let classFunc = function() {
88 class Foo extends parent {
89 static get bar() { return 0 }
90 get bar() { return 0 }
91 }
92 return Foo;
93 }
94
95 assertThrows(function(){addProperty(parent)}, TypeError);
96 assertThrows(function(){convertPropertyToData(parent)}, TypeError);
97 testWeakClass(classFunc);
98 })();
OLDNEW
« no previous file with comments | « test/mjsunit/strong/class-literals.js ('k') | test/mjsunit/strong/classes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698