Chromium Code Reviews| 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..0cc2d58986f0390ee479da8c92cb21f1e93512e4 |
| --- /dev/null |
| +++ b/test/mjsunit/strong/literals.js |
| @@ -0,0 +1,69 @@ |
| +// 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})); |
|
arv (Not doing code reviews)
2015/05/13 16:39:37
Please add tests with accessors, methods, __proto_
Dmitry Lomov (no reviews)
2015/05/18 09:15:56
Also regexps, if I understand the patch correctly.
rossberg
2015/05/18 09:32:37
Done. Turns out that super does not work currently
rossberg
2015/05/18 09:32:37
Those don't work yet, see the existing tests below
Dmitry Lomov (no reviews)
2015/05/18 10:56:30
I see, missed that.
|
| + // 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])); |
| +})(); |
| + |
| +(function StrongArrayLiterals(...args) { |
| + 'use strong'; |
| + // TODO(rossberg): implement strong array literals |
| + // assertTrue(%IsStrong(args)); |
| + // 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/)); |
| +})(); |