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

Unified Diff: tests/language/symbol_literal_test.dart

Issue 781203005: Allow Symbols in switch and maps (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years 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
« runtime/vm/object_store.cc ('K') | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/symbol_literal_test.dart
===================================================================
--- tests/language/symbol_literal_test.dart (revision 42183)
+++ tests/language/symbol_literal_test.dart (working copy)
@@ -12,6 +12,14 @@
var check = foo; // Indirection used to avoid inlining.
+testSwitch(Symbol s) {
+ switch(s) {
+ case #abc: return 1;
+ case const Symbol("def"): return 2;
+ default: return 0;
+ }
+}
+
main() {
check(const Symbol("a"), #a);
check(const Symbol("a"), #
@@ -28,6 +36,11 @@
check(const Symbol("=="), # ==);
check(const Symbol("a.toString"), #a.toString);
+ Expect.equals(1, testSwitch(#abc));
+
+ const m = const <Symbol, int>{#A:0, #B:1};
+ Expect.equals(1, m[#B]);
+
// Tries to call the symbol literal #a.toString
Expect.throws(() => #a.toString(), (e) => e is NoSuchMethodError); /// 01: static type warning
}
« runtime/vm/object_store.cc ('K') | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698