| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, 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 import "package:async_helper/async_helper.dart"; | |
| 7 import 'compiler_helper.dart'; | |
| 8 | |
| 9 dummyImplTest() { | |
| 10 String source = """ | |
| 11 class A { | |
| 12 foo() => 3; | |
| 13 noSuchMethod(x) => super.noSuchMethod(x); | |
| 14 } | |
| 15 main() { | |
| 16 print(new A().foo()); | |
| 17 } | |
| 18 """; | |
| 19 Uri uri = new Uri(scheme: 'source'); | |
| 20 var compiler = compilerFor(source, uri); | |
| 21 asyncTest(() => compiler.runCompiler(uri).then((_) { | |
| 22 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | |
| 23 ClassElement clsA = findElement(compiler, 'A'); | |
| 24 Expect.isTrue( | |
| 25 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | |
| 26 clsA.lookupMember('noSuchMethod'))); | |
| 27 })); | |
| 28 } | |
| 29 | |
| 30 dummyImplTest2() { | |
| 31 String source = """ | |
| 32 class A extends B { | |
| 33 foo() => 3; | |
| 34 noSuchMethod(x) => super.noSuchMethod(x); | |
| 35 } | |
| 36 class B {} | |
| 37 main() { | |
| 38 print(new A().foo()); | |
| 39 } | |
| 40 """; | |
| 41 Uri uri = new Uri(scheme: 'source'); | |
| 42 var compiler = compilerFor(source, uri); | |
| 43 asyncTest(() => compiler.runCompiler(uri).then((_) { | |
| 44 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | |
| 45 ClassElement clsA = findElement(compiler, 'A'); | |
| 46 Expect.isTrue( | |
| 47 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | |
| 48 clsA.lookupMember('noSuchMethod'))); | |
| 49 })); | |
| 50 } | |
| 51 | |
| 52 dummyImplTest3() { | |
| 53 String source = """ | |
| 54 class A extends B { | |
| 55 foo() => 3; | |
| 56 noSuchMethod(x) { | |
| 57 return super.noSuchMethod(x); | |
| 58 } | |
| 59 } | |
| 60 class B {} | |
| 61 main() { | |
| 62 print(new A().foo()); | |
| 63 } | |
| 64 """; | |
| 65 Uri uri = new Uri(scheme: 'source'); | |
| 66 var compiler = compilerFor(source, uri); | |
| 67 asyncTest(() => compiler.runCompiler(uri).then((_) { | |
| 68 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | |
| 69 ClassElement clsA = findElement(compiler, 'A'); | |
| 70 Expect.isTrue( | |
| 71 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | |
| 72 clsA.lookupMember('noSuchMethod'))); | |
| 73 })); | |
| 74 } | |
| 75 | |
| 76 dummyImplTest4() { | |
| 77 String source = """ | |
| 78 class A extends B { | |
| 79 foo() => 3; | |
| 80 noSuchMethod(x) => super.noSuchMethod(x); | |
| 81 } | |
| 82 class B { | |
| 83 noSuchMethod(x) => super.noSuchMethod(x); | |
| 84 } | |
| 85 main() { | |
| 86 print(new A().foo()); | |
| 87 } | |
| 88 """; | |
| 89 Uri uri = new Uri(scheme: 'source'); | |
| 90 var compiler = compilerFor(source, uri); | |
| 91 asyncTest(() => compiler.runCompiler(uri).then((_) { | |
| 92 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | |
| 93 ClassElement clsA = findElement(compiler, 'A'); | |
| 94 Expect.isTrue( | |
| 95 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | |
| 96 clsA.lookupMember('noSuchMethod'))); | |
| 97 ClassElement clsB = findElement(compiler, 'B'); | |
| 98 Expect.isTrue( | |
| 99 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | |
| 100 clsB.lookupMember('noSuchMethod'))); | |
| 101 })); | |
| 102 } | |
| 103 | |
| 104 dummyImplTest5() { | |
| 105 String source = """ | |
| 106 class A extends B { | |
| 107 foo() => 3; | |
| 108 noSuchMethod(x) => super.noSuchMethod(x); | |
| 109 } | |
| 110 class B { | |
| 111 noSuchMethod(x) => throw 'foo'; | |
| 112 } | |
| 113 main() { | |
| 114 print(new A().foo()); | |
| 115 } | |
| 116 """; | |
| 117 Uri uri = new Uri(scheme: 'source'); | |
| 118 var compiler = compilerFor(source, uri); | |
| 119 asyncTest(() => compiler.runCompiler(uri).then((_) { | |
| 120 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | |
| 121 ClassElement clsA = findElement(compiler, 'A'); | |
| 122 Expect.isTrue( | |
| 123 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( | |
| 124 clsA.lookupMember('noSuchMethod'))); | |
| 125 ClassElement clsB = findElement(compiler, 'B'); | |
| 126 Expect.isTrue( | |
| 127 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( | |
| 128 clsB.lookupMember('noSuchMethod'))); | |
| 129 })); | |
| 130 } | |
| 131 | |
| 132 dummyImplTest6() { | |
| 133 String source = """ | |
| 134 class A { | |
| 135 noSuchMethod(x) => 3; | |
| 136 } | |
| 137 main() { | |
| 138 print(new A().foo()); | |
| 139 } | |
| 140 """; | |
| 141 Uri uri = new Uri(scheme: 'source'); | |
| 142 var compiler = compilerFor(source, uri); | |
| 143 asyncTest(() => compiler.runCompiler(uri).then((_) { | |
| 144 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | |
| 145 ClassElement clsA = findElement(compiler, 'A'); | |
| 146 Expect.isTrue( | |
| 147 compiler.backend.noSuchMethodRegistry.otherImpls.contains( | |
| 148 clsA.lookupMember('noSuchMethod'))); | |
| 149 })); | |
| 150 } | |
| 151 | |
| 152 main() { | |
| 153 dummyImplTest(); | |
| 154 dummyImplTest2(); | |
| 155 dummyImplTest3(); | |
| 156 dummyImplTest4(); | |
| 157 dummyImplTest5(); | |
| 158 dummyImplTest6(); | |
| 159 } | |
| OLD | NEW |