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

Side by Side Diff: tests/language/src/MethodOverrideTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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/language/src/MethodNameTest.dart ('k') | tests/language/src/MultiAssignTest.dart » ('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) 2011, 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 // Checks that a method with an instantiated return type can override a method
6 // with a generic return type.
7
8 typedef Collection<K> GetKeysFunctionType<K>();
9
10 class MapBase<K, V> implements Map<K, V> {
11 Collection<K> getKeys() {
12 throw 'Must be implemented';
13 }
14
15 void Tests() {
16 Expect.isTrue(this is MapBase<int, int>);
17
18 Expect.isTrue(getKeys is GetKeysFunctionType);
19 Expect.isTrue(getKeys is GetKeysFunctionType<int>);
20 Expect.isTrue(getKeys is !GetKeysFunctionType<String>);
21 Expect.isTrue(getKeys is !GetKeysFunctionType<MapBase<int, int>>);
22 }
23 }
24
25
26 class MethodOverrideTest extends MapBase<String, String> {
27 Collection<String> getKeys() {
28 throw 'Is implemented';
29 }
30
31 void Tests() {
32 Expect.isTrue(this is MethodOverrideTest);
33 Expect.isTrue(this is MapBase<String, String>);
34
35 Expect.isTrue(getKeys is GetKeysFunctionType);
36 Expect.isTrue(getKeys is GetKeysFunctionType<String>);
37 Expect.isTrue(getKeys is !GetKeysFunctionType<int>);
38 Expect.isTrue(super.getKeys is GetKeysFunctionType);
39 Expect.isTrue(super.getKeys is GetKeysFunctionType<String>);
40 Expect.isTrue(super.getKeys is !GetKeysFunctionType<int>);
41 }
42 }
43
44
45 main() {
46 // Since method overriding is only checked statically, explicitly check
47 // the subtyping relation using a function type alias.
48 var x = new MethodOverrideTest();
49 Expect.isTrue(x.getKeys is GetKeysFunctionType<String>);
50
51 // Perform a few more tests.
52 x.Tests();
53
54 var m = new MapBase<int, int>();
55 Expect.isTrue(m.getKeys is GetKeysFunctionType<int>);
56
57 // Perform a few more tests.
58 m.Tests();
59 }
OLDNEW
« no previous file with comments | « tests/language/src/MethodNameTest.dart ('k') | tests/language/src/MultiAssignTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698