| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 // Dart test checking that static/instance field shadowing do not conflict. | |
| 5 | |
| 6 import 'package:expect/expect.dart' show Expect; | |
| 7 | |
| 8 // Test that certain interfaces/classes are blacklisted from being | |
| 9 // implemented or extended. | |
| 10 | |
| 11 class MyBool | |
| 12 extends bool //# 01a: compile-time error | |
| 13 implements bool //# 01b: compile-time error | |
| 14 extends Object with bool //# 01c: compile-time error | |
| 15 { | |
| 16 factory MyBool() => throw "bad"; | |
| 17 } | |
| 18 | |
| 19 abstract class MyBoolInterface | |
| 20 extends bool //# 02a: compile-time error | |
| 21 implements bool //# 02b: compile-time error | |
| 22 extends Object with bool //# 02c: compile-time error | |
| 23 { | |
| 24 factory MyBoolInterface() => throw "bad"; | |
| 25 } | |
| 26 | |
| 27 class MyNum | |
| 28 extends num //# 03a: compile-time error | |
| 29 implements num //# 03b: compile-time error | |
| 30 extends Object with num //# 03c: compile-time error | |
| 31 { | |
| 32 factory MyNum() => throw "bad"; | |
| 33 } | |
| 34 | |
| 35 abstract class MyNumInterface | |
| 36 extends num //# 04a: compile-time error | |
| 37 implements num //# 04b: compile-time error | |
| 38 extends Object with num //# 04c: compile-time error | |
| 39 { | |
| 40 factory MyNumInterface() => throw "bad"; | |
| 41 } | |
| 42 | |
| 43 class MyInt | |
| 44 extends int //# 05a: compile-time error | |
| 45 implements int //# 05b: compile-time error | |
| 46 extends Object with int //# 05c: compile-time error | |
| 47 { | |
| 48 factory MyInt() => throw "bad"; | |
| 49 } | |
| 50 | |
| 51 abstract class MyIntInterface | |
| 52 extends int //# 06a: compile-time error | |
| 53 implements int //# 06b: compile-time error | |
| 54 extends Object with int //# 06c: compile-time error | |
| 55 { | |
| 56 factory MyIntInterface() => throw "bad"; | |
| 57 } | |
| 58 | |
| 59 class MyDouble | |
| 60 extends double //# 07a: compile-time error | |
| 61 implements double //# 07b: compile-time error | |
| 62 extends Object with double //# 07c: compile-time error | |
| 63 { | |
| 64 factory MyDouble() => throw "bad"; | |
| 65 } | |
| 66 | |
| 67 abstract class MyDoubleInterface | |
| 68 extends double //# 08a: compile-time error | |
| 69 implements double //# 08b: compile-time error | |
| 70 extends Object with double //# 08c: compile-time error | |
| 71 { | |
| 72 factory MyDoubleInterface() => throw "bad"; | |
| 73 } | |
| 74 | |
| 75 class MyString | |
| 76 extends String //# 09a: compile-time error | |
| 77 implements String //# 09b: compile-time error | |
| 78 extends Object with String //# 09c: compile-time error | |
| 79 { | |
| 80 factory MyString() => throw "bad"; | |
| 81 } | |
| 82 | |
| 83 abstract class MyStringInterface | |
| 84 extends String //# 10a: compile-time error | |
| 85 implements String //# 10b: compile-time error | |
| 86 extends Object with String //# 10c: compile-time error | |
| 87 { | |
| 88 factory MyStringInterface() => throw "bad"; | |
| 89 } | |
| 90 | |
| 91 class MyFunction implements Function { | |
| 92 factory MyFunction() => throw "bad"; | |
| 93 } | |
| 94 | |
| 95 class MyOtherFunction extends Function { | |
| 96 factory MyOtherFunction() => throw "bad"; | |
| 97 } | |
| 98 | |
| 99 abstract class MyFunctionInterface implements Function { | |
| 100 factory MyFunctionInterface() => throw "bad"; | |
| 101 } | |
| 102 | |
| 103 class MyDynamic | |
| 104 extends dynamic //# 13a: compile-time error | |
| 105 implements dynamic //# 13b: compile-time error | |
| 106 extends Object with dynamic //# 13c: compile-time error | |
| 107 { | |
| 108 factory MyDynamic() => throw "bad"; | |
| 109 } | |
| 110 | |
| 111 abstract class MyDynamicInterface | |
| 112 extends dynamic //# 14a: compile-time error | |
| 113 implements dynamic //# 14b: compile-time error | |
| 114 extends Object with dynamic //# 14c: compile-time error | |
| 115 { | |
| 116 factory MyDynamicInterface() => throw "bad"; | |
| 117 } | |
| 118 | |
| 119 bool isBadString(e) => identical("bad", e); | |
| 120 | |
| 121 main() { | |
| 122 Expect.throws(() => new MyBool(), isBadString); | |
| 123 Expect.throws(() => new MyBoolInterface(), isBadString); | |
| 124 Expect.throws(() => new MyNum(), isBadString); | |
| 125 Expect.throws(() => new MyNumInterface(), isBadString); | |
| 126 Expect.throws(() => new MyInt(), isBadString); | |
| 127 Expect.throws(() => new MyIntInterface(), isBadString); | |
| 128 Expect.throws(() => new MyDouble(), isBadString); | |
| 129 Expect.throws(() => new MyDoubleInterface(), isBadString); | |
| 130 Expect.throws(() => new MyString(), isBadString); | |
| 131 Expect.throws(() => new MyStringInterface(), isBadString); | |
| 132 Expect.throws(() => new MyFunction(), isBadString); | |
| 133 Expect.throws(() => new MyOtherFunction(), isBadString); | |
| 134 Expect.throws(() => new MyFunctionInterface(), isBadString); | |
| 135 Expect.throws(() => new MyDynamic(), isBadString); | |
| 136 Expect.throws(() => new MyDynamicInterface(), isBadString); | |
| 137 } | |
| OLD | NEW |