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

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

Issue 179293005: Check that const-map keys don't override equals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/language/language.status » ('j') | 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 (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 import "package:expect/expect.dart";
6
7 class A {
8 const factory A() = B;
9 }
10
11 class B implements A {
12 const B();
13
14 operator ==(o) => true; /// 00: compile-time error
15 }
16
17 confuse(x) {
18 if (new DateTime.now() == 42) return confuse(2);
19 return x;
20 }
21
22 main() {
23 // It is a compile-time error if the key type overrides operator ==.
24 var m = const { const A(): 42 };
25 Expect.equals(42, m[confuse(const B())]);
26
27 m = const { "foo": 99, const A(): 499 };
28 Expect.equals(499, m[confuse(const B())]);
29 }
OLDNEW
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698