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

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

Issue 1259813003: Fix #23871: identical on consts should be always const (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: comment Created 5 years, 4 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 | « runtime/vm/ast.cc ('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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 main() { 7 main() {
8 const f0 = 42; 8 const f0 = 42;
9 const f1; /// 01: compile-time error 9 const f1; /// 01: compile-time error
10 const int f2 = 87; 10 const int f2 = 87;
(...skipping 14 matching lines...) Expand all
25 Expect.isTrue(A0 is int); 25 Expect.isTrue(A0 is int);
26 Expect.isTrue(A1 is int); 26 Expect.isTrue(A1 is int);
27 Expect.isTrue(A2 is int); /// 08: compile-time error 27 Expect.isTrue(A2 is int); /// 08: compile-time error
28 Expect.isTrue(A3 is int); /// 08: continued 28 Expect.isTrue(A3 is int); /// 08: continued
29 29
30 Expect.isTrue(C0.X is C1); 30 Expect.isTrue(C0.X is C1);
31 Expect.isTrue(C0.X.x is C1); /// 09: compile-time error 31 Expect.isTrue(C0.X.x is C1); /// 09: compile-time error
32 32
33 Expect.equals("Hello 42", B2); 33 Expect.equals("Hello 42", B2);
34 Expect.equals("42Hello", B3); /// 10: compile-time error 34 Expect.equals("42Hello", B3); /// 10: compile-time error
35
36 const cf1 = identical(const Point(1, 2), const Point(1, 2));
37
38 const cf2 = identical(const Point(1, 2), new Point(1, 2)); /// 11: compile-ti me error
39
40 var f4 = B4; /// 12: compile-time error
41 var f5 = B5;
35 } 42 }
36 43
37 const F0 = 42; 44 const F0 = 42;
38 const F1; /// 03: continued 45 const F1; /// 03: continued
39 const int F2 = 87; 46 const int F2 = 87;
40 const int F3; /// 04: continued 47 const int F3; /// 04: continued
41 48
42 class Point { 49 class Point {
43 final x, y; 50 final x, y;
44 const Point(this.x, this.y); 51 const Point(this.x, this.y);
(...skipping 23 matching lines...) Expand all
68 : x = C0.X /// 09: continued 75 : x = C0.X /// 09: continued
69 ; 76 ;
70 final x = null; 77 final x = null;
71 } 78 }
72 79
73 // Check that sub-expressions of binary + are numeric. 80 // Check that sub-expressions of binary + are numeric.
74 const B0 = 42; 81 const B0 = 42;
75 const B1 = "Hello"; 82 const B1 = "Hello";
76 const B2 = "$B1 $B0"; 83 const B2 = "$B1 $B0";
77 const B3 = B0 + B1; /// 10: continued 84 const B3 = B0 + B1; /// 10: continued
85
86 // Check identical.
87
88 const B4 = identical(1, new Point(1,2));
89 const B5 = identical(1, const Point(1,2));
OLDNEW
« no previous file with comments | « runtime/vm/ast.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698