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

Side by Side Diff: test/mjsunit/strong/mutually-recursive-classes.js

Issue 1087543004: [strong] Allow mutually recursive classes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 years, 8 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/declaration-after-use.js ('k') | no next file » | 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 // Note that it's essential for these tests that the reference is inside dead
8 // code (because we already produce ReferenceErrors for run-time unresolved
9 // variables and don't want to confuse those with strong mode errors). But the
10 // errors should *not* be inside lazy, unexecuted functions, since lazy parsing
11 // doesn't produce strong mode scoping errors).
12
13 // In addition, assertThrows will call eval and that changes variable binding
14 // types (see e.g., UNBOUND_EVAL_SHADOWED). We can avoid unwanted side effects
15 // by wrapping the code to be tested inside an outer function.
16 function assertThrowsHelper(code) {
17 "use strict";
18 let prologue_dead = "(function outer() { if (false) { ";
19 let epilogue_dead = " } })();";
20
21 assertThrows("'use strong'; " + prologue_dead + code + epilogue_dead, Referenc eError);
22
23 // Make sure the error happens only in strong mode (note that we need strict
24 // mode here because of let).
25 assertDoesNotThrow("'use strict'; " + prologue_dead + code + epilogue_dead);
26
27 // But if we don't put the references inside a dead code, it throws a run-time
28 // error (also in strict mode).
29 let prologue_live = "(function outer() { ";
30 let epilogue_live = "})();";
31
32 assertThrows("'use strong'; " + prologue_live + code + epilogue_live, Referenc eError);
33 assertThrows("'use strict'; " + prologue_live + code + epilogue_live, Referenc eError);
34 }
35
36 (function InitTimeReferenceForward() {
37 // It's never OK to have an init time reference to a class which hasn't been
38 // declared.
39 assertThrowsHelper(
40 `class A extends B { };
41 class B {}`);
42
43 assertThrowsHelper(
44 `class A {
45 [B.sm()]() { }
46 };
47 class B {
48 static sm() { return 0; }
49 }`);
50 })();
51
52 (function InitTimeReferenceBackward() {
53 // Backwards is of course fine.
54 "use strong";
55 class A {
56 static sm() { return 0; }
57 };
58 let i = "making these classes non-consecutive";
59 class B extends A {};
60 "by inserting statements and declarations in between";
61 class C {
62 [A.sm()]() { }
63 };
64 })();
65
66 (function BasicMutualRecursion() {
67 "use strong";
68 class A {
69 m() { B; }
70 static sm() { B; }
71 };
72 // No statements or declarations between the classes.
73 class B {
74 m() { A; }
75 static sm() { A; }
76 };
77 })();
OLDNEW
« no previous file with comments | « test/mjsunit/strong/declaration-after-use.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698