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

Unified Diff: tests/language/identical_const_test.dart

Issue 689173004: Properly implement identical() test in analyzer constant evaluation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/test/generated/all_the_rest.dart ('k') | tests/language/language_analyzer.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/identical_const_test.dart
diff --git a/tests/language/identical_const_test.dart b/tests/language/identical_const_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..cd96244823b2811750cb1426f888b30d3a69a576
--- /dev/null
+++ b/tests/language/identical_const_test.dart
@@ -0,0 +1,37 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:expect/expect.dart';
+
+f() {}
+const g = 1;
+
+const identical_ff = identical(f, f);
+const identical_fg = identical(f, g);
+const identical_gf = identical(g, f);
+const identical_gg = identical(g, g);
+
+// Verify proper compile time computation of identical()
+const a = const {
+ identical_ff: 0, /// 01: static type warning
+ identical_gg: 0, /// 02: static type warning
+ true: 0 };
+
+const b = const {
+ identical_fg: 0, /// 03: static type warning
+ identical_gf: 0, /// 04: static type warning
+ false: 0 };
+
+use(x) => x;
+
+main() {
+ use(a);
+ use(b);
+
+ // Verify proper run time computation of identical()
+ Expect.isTrue(identical_ff); /// 05: ok
+ Expect.isTrue(identical_gg); /// 06: ok
+ Expect.isFalse(identical_fg); /// 07: ok
+ Expect.isFalse(identical_gf); /// 08: ok
+}
« no previous file with comments | « pkg/analyzer/test/generated/all_the_rest.dart ('k') | tests/language/language_analyzer.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698