OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class BaseClass { | 7 class BaseClass { |
8 var foo; | 8 var foo; |
9 BaseClass() { foo = 0; } | 9 BaseClass() { |
| 10 foo = 0; |
| 11 } |
10 toString() => "BaseClass"; | 12 toString() => "BaseClass"; |
11 } | 13 } |
12 | 14 |
13 /** | 15 /** |
14 * This class declaration causes an intentional type warning as it | 16 * This class declaration causes an intentional type warning as it |
15 * isn't marked abstract. It is abstract because it doesn't | 17 * isn't marked abstract. It is abstract because it doesn't |
16 * "implement" the field foo. | 18 * "implement" the field foo. |
17 */ | 19 */ |
18 class ImplementsClass implements BaseClass { | 20 class ImplementsClass implements BaseClass { |
19 ImplementsClass() {} | 21 ImplementsClass() {} |
(...skipping 19 matching lines...) Expand all Loading... |
39 } on NoSuchMethodError catch (ex) { | 41 } on NoSuchMethodError catch (ex) { |
40 // Expected error. | 42 // Expected error. |
41 } | 43 } |
42 try { | 44 try { |
43 c2.foo; | 45 c2.foo; |
44 Expect.fail('expected a NoSuchMethodError'); | 46 Expect.fail('expected a NoSuchMethodError'); |
45 } on NoSuchMethodError catch (ex) { | 47 } on NoSuchMethodError catch (ex) { |
46 // Expected error. | 48 // Expected error. |
47 } | 49 } |
48 Expect.equals(true, c1 is BaseClass); | 50 Expect.equals(true, c1 is BaseClass); |
49 Expect.equals(true, c1 is !ExtendsClass); | 51 Expect.equals(true, c1 is! ExtendsClass); |
50 Expect.equals(true, c2 is BaseClass); | 52 Expect.equals(true, c2 is BaseClass); |
51 Expect.equals(true, c2 is ExtendsClass); | 53 Expect.equals(true, c2 is ExtendsClass); |
52 Expect.equals(true, c2 is !ImplementsClass); | 54 Expect.equals(true, c2 is! ImplementsClass); |
53 Expect.equals("BaseClass", "${new BaseClass()}"); | 55 Expect.equals("BaseClass", "${new BaseClass()}"); |
54 | 56 |
55 // Verify we don't inherit toString from BaseClass | 57 // Verify we don't inherit toString from BaseClass |
56 Expect.notEquals("BaseClass", "${c1}"); | 58 Expect.notEquals("BaseClass", "${c1}"); |
57 Expect.notEquals("BaseClass", "${c2}"); | 59 Expect.notEquals("BaseClass", "${c2}"); |
58 } | 60 } |
OLD | NEW |