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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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 // Checks that a method with an instantiated return type can override a method 7 // Checks that a method with an instantiated return type can override a method
8 // with a generic return type. 8 // with a generic return type.
9 9
10 typedef V RemoveFunctionType<K, V>(K key); 10 typedef V RemoveFunctionType<K, V>(K key);
11 11
12 class MapBase<K, V> implements Map<K, V> { 12 class MapBase<K, V> implements Map<K, V> {
13 K remove(K key) { 13 K remove(K key) {
14 throw 'Must be implemented'; 14 throw 'Must be implemented';
15 } 15 }
16 16
17 void Tests() { 17 void Tests() {
18 Expect.isTrue(this is MapBase<int, int>); 18 Expect.isTrue(this is MapBase<int, int>);
19 19
20 Expect.isTrue(remove is RemoveFunctionType); 20 Expect.isTrue(remove is RemoveFunctionType);
21 Expect.isTrue(remove is RemoveFunctionType<int, int>); 21 Expect.isTrue(remove is RemoveFunctionType<int, int>);
22 Expect.isTrue(remove is !RemoveFunctionType<String, int>); 22 Expect.isTrue(remove is! RemoveFunctionType<String, int>);
23 Expect.isTrue(remove is !RemoveFunctionType<MapBase<int, int>, int>); 23 Expect.isTrue(remove is! RemoveFunctionType<MapBase<int, int>, int>);
24 } 24 }
25 } 25 }
26 26
27
28 class MethodOverrideTest extends MapBase<String, String> { 27 class MethodOverrideTest extends MapBase<String, String> {
29 String remove(String key) { 28 String remove(String key) {
30 throw 'Must be implemented'; 29 throw 'Must be implemented';
31 } 30 }
32 31
33 void Tests() { 32 void Tests() {
34 Expect.isTrue(this is MethodOverrideTest); 33 Expect.isTrue(this is MethodOverrideTest);
35 Expect.isTrue(this is MapBase<String, String>); 34 Expect.isTrue(this is MapBase<String, String>);
36 35
37 Expect.isTrue(remove is RemoveFunctionType); 36 Expect.isTrue(remove is RemoveFunctionType);
38 Expect.isTrue(remove is RemoveFunctionType<String, String>); 37 Expect.isTrue(remove is RemoveFunctionType<String, String>);
39 Expect.isTrue(remove is !RemoveFunctionType<int, int>); 38 Expect.isTrue(remove is! RemoveFunctionType<int, int>);
40 Expect.isTrue(super.remove is RemoveFunctionType); 39 Expect.isTrue(super.remove is RemoveFunctionType);
41 Expect.isTrue(super.remove is RemoveFunctionType<String, String>); 40 Expect.isTrue(super.remove is RemoveFunctionType<String, String>);
42 Expect.isTrue(super.remove is !RemoveFunctionType<int, int>); 41 Expect.isTrue(super.remove is! RemoveFunctionType<int, int>);
43 } 42 }
44 } 43 }
45 44
46
47 main() { 45 main() {
48 // Since method overriding is only checked statically, explicitly check 46 // Since method overriding is only checked statically, explicitly check
49 // the subtyping relation using a function type alias. 47 // the subtyping relation using a function type alias.
50 var x = new MethodOverrideTest(); 48 var x = new MethodOverrideTest();
51 Expect.isTrue(x.remove is RemoveFunctionType<String, String>); 49 Expect.isTrue(x.remove is RemoveFunctionType<String, String>);
52 50
53 // Perform a few more tests. 51 // Perform a few more tests.
54 x.Tests(); 52 x.Tests();
55 53
56 var m = new MapBase<int, int>(); 54 var m = new MapBase<int, int>();
57 Expect.isTrue(m.remove is RemoveFunctionType<int, int>); 55 Expect.isTrue(m.remove is RemoveFunctionType<int, int>);
58 56
59 // Perform a few more tests. 57 // Perform a few more tests.
60 m.Tests(); 58 m.Tests();
61 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698