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

Side by Side Diff: tests/language/ref_before_declaration_test.dart

Issue 49253006: Compile time error on forward references to functions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Test compile-time errors for illegal variable declarations if the name 5 // Test compile-time errors for illegal variable declarations if the name
6 // has been referenced before the variable is declared. 6 // has been referenced before the variable is declared.
7 7
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 use(value) => value; 10 use(value) => value;
(...skipping 23 matching lines...) Expand all
34 34
35 void test3() { 35 void test3() {
36 if (true) { 36 if (true) {
37 use(x); // Refers to top-level x. 37 use(x); // Refers to top-level x.
38 use(y); // Refers to top-level y. 38 use(y); // Refers to top-level y.
39 } 39 }
40 final x = "I have not yet begun to procrastinate."; /// 02: compile-time er ror 40 final x = "I have not yet begun to procrastinate."; /// 02: compile-time er ror
41 const y = "Honk if you like peace and quiet!"; /// 03: compile-time error 41 const y = "Honk if you like peace and quiet!"; /// 03: compile-time error
42 } 42 }
43 43
44 void test4() {
45 void Q() {
46 P(); // Refers to non-existing top-level function P
47 }
48 void P() { /// 06: compile-time error
49 Q(); /// 06: continued
50 } /// 06: continued
51 }
52
44 test() { 53 test() {
45 test1(); 54 test1();
46 test2(); 55 test2();
47 test3(); 56 test3();
57 test4();
48 } 58 }
49 } 59 }
50 60
51 void testTypeRef() { 61 void testTypeRef() {
52 String s = 'Can vegetarians eat animal crackers?'; 62 String s = 'Can vegetarians eat animal crackers?';
53 var String = "I distinctly remember forgetting that."; /// 04: compile-time e rror 63 var String = "I distinctly remember forgetting that."; /// 04: compile-time e rror
54 } 64 }
55 65
56 void testLibPrefix() { 66 void testLibPrefix() {
57 var pie = math.PI; 67 var pie = math.PI;
(...skipping 14 matching lines...) Expand all
72 var int = 007; 82 var int = 007;
73 } 83 }
74 84
75 void main() { 85 void main() {
76 var c = new C(); 86 var c = new C();
77 c.test(); 87 c.test();
78 testTypeRef(); 88 testTypeRef();
79 testLibPrefix(); 89 testLibPrefix();
80 noErrorsExpected(); 90 noErrorsExpected();
81 } 91 }
OLDNEW
« tests/co19/co19-co19.status ('K') | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698