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

Unified Diff: test/mjsunit/strong/literals.js

Issue 1143813002: Reland "[strong] Object literals create strong objects" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix handlification bug Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-literals.cc ('k') | test/mjsunit/strong/objects.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/strong/literals.js
diff --git a/test/mjsunit/strong/literals.js b/test/mjsunit/strong/literals.js
new file mode 100644
index 0000000000000000000000000000000000000000..b9368e1f9a34c4544e9f98455d4b483a1fb83a51
--- /dev/null
+++ b/test/mjsunit/strong/literals.js
@@ -0,0 +1,79 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --strong-mode --allow-natives-syntax
+// Flags: --harmony-arrow-functions --harmony-rest-parameters
+
+
+(function WeakObjectLiterals() {
+ assertTrue(!%IsStrong({}));
+ assertTrue(!%IsStrong({a: 0, b: 0}));
+ assertTrue(!%IsStrong({f: function(){}}));
+ assertTrue(!%IsStrong(Realm.eval(Realm.current(),
+ "({f: function(){}})")));
+})();
+
+(function StrongObjectLiterals() {
+ 'use strong';
+ assertTrue(%IsStrong({}));
+ assertTrue(%IsStrong({a: 0, b: 0}));
+ assertTrue(%IsStrong({__proto__: {}, get a() {}, set b(x) {}}));
+ assertTrue(%IsStrong({[Date() + ""]: 0, [Symbol()]: 0}));
+ // TODO(rossberg): super does not work yet
+ // assertTrue(%IsStrong({m() { super.m() }}));
+ // Object literals with constant functions are treated specially,
+ // but currently only on the toplevel.
+ assertTrue(%IsStrong({f: function(){}}));
+ // TODO(rossberg): implement strong object literals with functions
+ // assertTrue(%IsStrong(Realm.eval(Realm.current(),
+ // "'use strong'; ({f: function(){}})")));
+})();
+
+(function WeakArrayLiterals(...args) {
+ assertTrue(!%IsStrong(args));
+ assertTrue(!%IsStrong([]));
+ assertTrue(!%IsStrong([1, 2, 3]));
+ Array.prototype = {}
+ assertTrue(!%IsStrong([]));
+ assertTrue(!%IsStrong([1, 2, 3]));
+})();
+
+(function StrongArrayLiterals(...args) {
+ 'use strong';
+ // TODO(rossberg): implement strong array literals
+ // assertTrue(%IsStrong(args));
+ // assertTrue(%IsStrong([]));
+ // assertTrue(%IsStrong([1, 2, 3]));
+ // Array.prototype = {}
+ // assertTrue(%IsStrong([]));
+ // assertTrue(%IsStrong([1, 2, 3]));
+})(0); // TODO(arv): drop dummy
+
+(function WeakFunctionLiterals() {
+ function f() {}
+ assertTrue(!%IsStrong(f));
+ assertTrue(!%IsStrong(function(){}));
+ assertTrue(!%IsStrong(() => {}));
+ assertTrue(!%IsStrong(x => x));
+})();
+
+(function StrongFunctionLiterals(g) {
+ 'use strong';
+ function f() {}
+ assertTrue(%IsStrong(f));
+ assertTrue(%IsStrong(g));
+ assertTrue(%IsStrong(function(){}));
+ assertTrue(%IsStrong(() => {}));
+ assertTrue(%IsStrong(x => x));
+})(function() { 'use strong' });
+
+(function WeakRegExpLiterals() {
+ assertTrue(!%IsStrong(/abc/));
+})();
+
+(function StrongRegExpLiterals() {
+ 'use strong';
+ // TODO(rossberg): implement strong regexp literals
+ // assertTrue(%IsStrong(/abc/));
+})();
« no previous file with comments | « src/runtime/runtime-literals.cc ('k') | test/mjsunit/strong/objects.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698