| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 import "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
| 7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
| 8 | 8 |
| 9 dummyImplTest() { | 9 dummyImplTest() { |
| 10 String source = """ | 10 String source = """ |
| 11 class A { | 11 class A { |
| 12 foo() => 3; | 12 foo() => 3; |
| 13 noSuchMethod(x) => super.noSuchMethod(x); | 13 noSuchMethod(x) => super.noSuchMethod(x); |
| 14 } | 14 } |
| 15 main() { | 15 main() { |
| 16 print(new A().foo()); | 16 print(new A().foo()); |
| 17 } | 17 } |
| 18 """; | 18 """; |
| 19 Uri uri = new Uri(scheme: 'source'); | 19 Uri uri = new Uri(scheme: 'source'); |
| 20 var compiler = compilerFor(source, uri); | 20 var compiler = compilerFor(source, uri); |
| 21 asyncTest(() => compiler.runCompiler(uri).then((_) { | 21 asyncTest(() => compiler.run(uri).then((_) { |
| 22 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 22 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 23 ClassElement clsA = findElement(compiler, 'A'); | 23 ClassElement clsA = findElement(compiler, 'A'); |
| 24 Expect.isTrue( | 24 Expect.isTrue( |
| 25 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 25 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( |
| 26 clsA.lookupMember('noSuchMethod'))); | 26 clsA.lookupMember('noSuchMethod'))); |
| 27 })); | 27 })); |
| 28 } | 28 } |
| 29 | 29 |
| 30 dummyImplTest2() { | 30 dummyImplTest2() { |
| 31 String source = """ | 31 String source = """ |
| 32 class A extends B { | 32 class A extends B { |
| 33 foo() => 3; | 33 foo() => 3; |
| 34 noSuchMethod(x) => super.noSuchMethod(x); | 34 noSuchMethod(x) => super.noSuchMethod(x); |
| 35 } | 35 } |
| 36 class B {} | 36 class B {} |
| 37 main() { | 37 main() { |
| 38 print(new A().foo()); | 38 print(new A().foo()); |
| 39 } | 39 } |
| 40 """; | 40 """; |
| 41 Uri uri = new Uri(scheme: 'source'); | 41 Uri uri = new Uri(scheme: 'source'); |
| 42 var compiler = compilerFor(source, uri); | 42 var compiler = compilerFor(source, uri); |
| 43 asyncTest(() => compiler.runCompiler(uri).then((_) { | 43 asyncTest(() => compiler.run(uri).then((_) { |
| 44 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 44 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 45 ClassElement clsA = findElement(compiler, 'A'); | 45 ClassElement clsA = findElement(compiler, 'A'); |
| 46 Expect.isTrue( | 46 Expect.isTrue( |
| 47 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 47 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( |
| 48 clsA.lookupMember('noSuchMethod'))); | 48 clsA.lookupMember('noSuchMethod'))); |
| 49 })); | 49 })); |
| 50 } | 50 } |
| 51 | 51 |
| 52 dummyImplTest3() { | 52 dummyImplTest3() { |
| 53 String source = """ | 53 String source = """ |
| 54 class A extends B { | 54 class A extends B { |
| 55 foo() => 3; | 55 foo() => 3; |
| 56 noSuchMethod(x) { | 56 noSuchMethod(x) { |
| 57 return super.noSuchMethod(x); | 57 return super.noSuchMethod(x); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 class B {} | 60 class B {} |
| 61 main() { | 61 main() { |
| 62 print(new A().foo()); | 62 print(new A().foo()); |
| 63 } | 63 } |
| 64 """; | 64 """; |
| 65 Uri uri = new Uri(scheme: 'source'); | 65 Uri uri = new Uri(scheme: 'source'); |
| 66 var compiler = compilerFor(source, uri); | 66 var compiler = compilerFor(source, uri); |
| 67 asyncTest(() => compiler.runCompiler(uri).then((_) { | 67 asyncTest(() => compiler.run(uri).then((_) { |
| 68 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 68 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 69 ClassElement clsA = findElement(compiler, 'A'); | 69 ClassElement clsA = findElement(compiler, 'A'); |
| 70 Expect.isTrue( | 70 Expect.isTrue( |
| 71 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 71 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( |
| 72 clsA.lookupMember('noSuchMethod'))); | 72 clsA.lookupMember('noSuchMethod'))); |
| 73 })); | 73 })); |
| 74 } | 74 } |
| 75 | 75 |
| 76 dummyImplTest4() { | 76 dummyImplTest4() { |
| 77 String source = """ | 77 String source = """ |
| 78 class A extends B { | 78 class A extends B { |
| 79 foo() => 3; | 79 foo() => 3; |
| 80 noSuchMethod(x) => super.noSuchMethod(x); | 80 noSuchMethod(x) => super.noSuchMethod(x); |
| 81 } | 81 } |
| 82 class B { | 82 class B { |
| 83 noSuchMethod(x) => super.noSuchMethod(x); | 83 noSuchMethod(x) => super.noSuchMethod(x); |
| 84 } | 84 } |
| 85 main() { | 85 main() { |
| 86 print(new A().foo()); | 86 print(new A().foo()); |
| 87 } | 87 } |
| 88 """; | 88 """; |
| 89 Uri uri = new Uri(scheme: 'source'); | 89 Uri uri = new Uri(scheme: 'source'); |
| 90 var compiler = compilerFor(source, uri); | 90 var compiler = compilerFor(source, uri); |
| 91 asyncTest(() => compiler.runCompiler(uri).then((_) { | 91 asyncTest(() => compiler.run(uri).then((_) { |
| 92 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 92 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 93 ClassElement clsA = findElement(compiler, 'A'); | 93 ClassElement clsA = findElement(compiler, 'A'); |
| 94 Expect.isTrue( | 94 Expect.isTrue( |
| 95 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 95 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( |
| 96 clsA.lookupMember('noSuchMethod'))); | 96 clsA.lookupMember('noSuchMethod'))); |
| 97 ClassElement clsB = findElement(compiler, 'B'); | 97 ClassElement clsB = findElement(compiler, 'B'); |
| 98 Expect.isTrue( | 98 Expect.isTrue( |
| 99 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 99 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( |
| 100 clsB.lookupMember('noSuchMethod'))); | 100 clsB.lookupMember('noSuchMethod'))); |
| 101 })); | 101 })); |
| 102 } | 102 } |
| 103 | 103 |
| 104 dummyImplTest5() { | 104 dummyImplTest5() { |
| 105 String source = """ | 105 String source = """ |
| 106 class A extends B { | 106 class A extends B { |
| 107 foo() => 3; | 107 foo() => 3; |
| 108 noSuchMethod(x) => super.noSuchMethod(x); | 108 noSuchMethod(x) => super.noSuchMethod(x); |
| 109 } | 109 } |
| 110 class B { | 110 class B { |
| 111 noSuchMethod(x) => throw 'foo'; | 111 noSuchMethod(x) => throw 'foo'; |
| 112 } | 112 } |
| 113 main() { | 113 main() { |
| 114 print(new A().foo()); | 114 print(new A().foo()); |
| 115 } | 115 } |
| 116 """; | 116 """; |
| 117 Uri uri = new Uri(scheme: 'source'); | 117 Uri uri = new Uri(scheme: 'source'); |
| 118 var compiler = compilerFor(source, uri); | 118 var compiler = compilerFor(source, uri); |
| 119 asyncTest(() => compiler.runCompiler(uri).then((_) { | 119 asyncTest(() => compiler.run(uri).then((_) { |
| 120 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 120 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 121 ClassElement clsA = findElement(compiler, 'A'); | 121 ClassElement clsA = findElement(compiler, 'A'); |
| 122 Expect.isTrue( | 122 Expect.isTrue( |
| 123 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( | 123 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( |
| 124 clsA.lookupMember('noSuchMethod'))); | 124 clsA.lookupMember('noSuchMethod'))); |
| 125 ClassElement clsB = findElement(compiler, 'B'); | 125 ClassElement clsB = findElement(compiler, 'B'); |
| 126 Expect.isTrue( | 126 Expect.isTrue( |
| 127 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( | 127 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( |
| 128 clsB.lookupMember('noSuchMethod'))); | 128 clsB.lookupMember('noSuchMethod'))); |
| 129 })); | 129 })); |
| 130 } | 130 } |
| 131 | 131 |
| 132 dummyImplTest6() { | 132 dummyImplTest6() { |
| 133 String source = """ | 133 String source = """ |
| 134 class A { | 134 class A { |
| 135 noSuchMethod(x) => 3; | 135 noSuchMethod(x) => 3; |
| 136 } | 136 } |
| 137 main() { | 137 main() { |
| 138 print(new A().foo()); | 138 print(new A().foo()); |
| 139 } | 139 } |
| 140 """; | 140 """; |
| 141 Uri uri = new Uri(scheme: 'source'); | 141 Uri uri = new Uri(scheme: 'source'); |
| 142 var compiler = compilerFor(source, uri); | 142 var compiler = compilerFor(source, uri); |
| 143 asyncTest(() => compiler.runCompiler(uri).then((_) { | 143 asyncTest(() => compiler.run(uri).then((_) { |
| 144 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 144 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 145 ClassElement clsA = findElement(compiler, 'A'); | 145 ClassElement clsA = findElement(compiler, 'A'); |
| 146 Expect.isTrue( | 146 Expect.isTrue( |
| 147 compiler.backend.noSuchMethodRegistry.otherImpls.contains( | 147 compiler.backend.noSuchMethodRegistry.otherImpls.contains( |
| 148 clsA.lookupMember('noSuchMethod'))); | 148 clsA.lookupMember('noSuchMethod'))); |
| 149 })); | 149 })); |
| 150 } | 150 } |
| 151 | 151 |
| 152 dummyImplTest7() { | 152 dummyImplTest7() { |
| 153 String source = """ | 153 String source = """ |
| 154 class A { | 154 class A { |
| 155 noSuchMethod(x, [y]) => super.noSuchMethod(x); | 155 noSuchMethod(x, [y]) => super.noSuchMethod(x); |
| 156 } | 156 } |
| 157 main() { | 157 main() { |
| 158 print(new A().foo()); | 158 print(new A().foo()); |
| 159 } | 159 } |
| 160 """; | 160 """; |
| 161 Uri uri = new Uri(scheme: 'source'); | 161 Uri uri = new Uri(scheme: 'source'); |
| 162 var compiler = compilerFor(source, uri); | 162 var compiler = compilerFor(source, uri); |
| 163 asyncTest(() => compiler.runCompiler(uri).then((_) { | 163 asyncTest(() => compiler.run(uri).then((_) { |
| 164 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 164 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 165 ClassElement clsA = findElement(compiler, 'A'); | 165 ClassElement clsA = findElement(compiler, 'A'); |
| 166 Expect.isTrue( | 166 Expect.isTrue( |
| 167 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 167 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( |
| 168 clsA.lookupMember('noSuchMethod'))); | 168 clsA.lookupMember('noSuchMethod'))); |
| 169 })); | 169 })); |
| 170 } | 170 } |
| 171 | 171 |
| 172 dummyImplTest8() { | 172 dummyImplTest8() { |
| 173 String source = """ | 173 String source = """ |
| 174 class A { | 174 class A { |
| 175 noSuchMethod(x, [y]) => super.noSuchMethod(x, y); | 175 noSuchMethod(x, [y]) => super.noSuchMethod(x, y); |
| 176 } | 176 } |
| 177 main() { | 177 main() { |
| 178 print(new A().foo()); | 178 print(new A().foo()); |
| 179 } | 179 } |
| 180 """; | 180 """; |
| 181 Uri uri = new Uri(scheme: 'source'); | 181 Uri uri = new Uri(scheme: 'source'); |
| 182 var compiler = compilerFor(source, uri); | 182 var compiler = compilerFor(source, uri); |
| 183 asyncTest(() => compiler.runCompiler(uri).then((_) { | 183 asyncTest(() => compiler.run(uri).then((_) { |
| 184 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 184 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 185 ClassElement clsA = findElement(compiler, 'A'); | 185 ClassElement clsA = findElement(compiler, 'A'); |
| 186 Expect.isTrue( | 186 Expect.isTrue( |
| 187 compiler.backend.noSuchMethodRegistry.otherImpls.contains( | 187 compiler.backend.noSuchMethodRegistry.otherImpls.contains( |
| 188 clsA.lookupMember('noSuchMethod'))); | 188 clsA.lookupMember('noSuchMethod'))); |
| 189 })); | 189 })); |
| 190 } | 190 } |
| 191 | 191 |
| 192 dummyImplTest9() { | 192 dummyImplTest9() { |
| 193 String source = """ | 193 String source = """ |
| 194 class A { | 194 class A { |
| 195 noSuchMethod(x, y) => super.noSuchMethod(x); | 195 noSuchMethod(x, y) => super.noSuchMethod(x); |
| 196 } | 196 } |
| 197 main() { | 197 main() { |
| 198 print(new A().foo()); | 198 print(new A().foo()); |
| 199 } | 199 } |
| 200 """; | 200 """; |
| 201 Uri uri = new Uri(scheme: 'source'); | 201 Uri uri = new Uri(scheme: 'source'); |
| 202 var compiler = compilerFor(source, uri); | 202 var compiler = compilerFor(source, uri); |
| 203 asyncTest(() => compiler.runCompiler(uri).then((_) { | 203 asyncTest(() => compiler.run(uri).then((_) { |
| 204 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 204 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 205 ClassElement clsA = findElement(compiler, 'A'); | 205 ClassElement clsA = findElement(compiler, 'A'); |
| 206 Expect.isTrue( | 206 Expect.isTrue( |
| 207 compiler.backend.noSuchMethodRegistry.otherImpls.contains( | 207 compiler.backend.noSuchMethodRegistry.otherImpls.contains( |
| 208 clsA.lookupMember('noSuchMethod'))); | 208 clsA.lookupMember('noSuchMethod'))); |
| 209 })); | 209 })); |
| 210 } | 210 } |
| 211 | 211 |
| 212 dummyImplTest10() { | 212 dummyImplTest10() { |
| 213 String source = """ | 213 String source = """ |
| 214 class A { | 214 class A { |
| 215 noSuchMethod(Invocation x) { | 215 noSuchMethod(Invocation x) { |
| 216 throw new UnsupportedException(); | 216 throw new UnsupportedException(); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 main() { | 219 main() { |
| 220 print(new A().foo()); | 220 print(new A().foo()); |
| 221 } | 221 } |
| 222 """; | 222 """; |
| 223 Uri uri = new Uri(scheme: 'source'); | 223 Uri uri = new Uri(scheme: 'source'); |
| 224 var compiler = compilerFor(source, uri); | 224 var compiler = compilerFor(source, uri); |
| 225 asyncTest(() => compiler.runCompiler(uri).then((_) { | 225 asyncTest(() => compiler.run(uri).then((_) { |
| 226 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 226 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 227 ClassElement clsA = findElement(compiler, 'A'); | 227 ClassElement clsA = findElement(compiler, 'A'); |
| 228 Expect.isTrue( | 228 Expect.isTrue( |
| 229 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( | 229 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( |
| 230 clsA.lookupMember('noSuchMethod'))); | 230 clsA.lookupMember('noSuchMethod'))); |
| 231 })); | 231 })); |
| 232 } | 232 } |
| 233 | 233 |
| 234 dummyImplTest11() { | 234 dummyImplTest11() { |
| 235 String source = """ | 235 String source = """ |
| 236 class A { | 236 class A { |
| 237 noSuchMethod(Invocation x) { | 237 noSuchMethod(Invocation x) { |
| 238 print('foo'); | 238 print('foo'); |
| 239 throw 'foo'; | 239 throw 'foo'; |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 main() { | 242 main() { |
| 243 print(new A().foo()); | 243 print(new A().foo()); |
| 244 } | 244 } |
| 245 """; | 245 """; |
| 246 Uri uri = new Uri(scheme: 'source'); | 246 Uri uri = new Uri(scheme: 'source'); |
| 247 var compiler = compilerFor(source, uri); | 247 var compiler = compilerFor(source, uri); |
| 248 asyncTest(() => compiler.runCompiler(uri).then((_) { | 248 asyncTest(() => compiler.run(uri).then((_) { |
| 249 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 249 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 250 ClassElement clsA = findElement(compiler, 'A'); | 250 ClassElement clsA = findElement(compiler, 'A'); |
| 251 Expect.isTrue( | 251 Expect.isTrue( |
| 252 compiler.backend.noSuchMethodRegistry.otherImpls.contains( | 252 compiler.backend.noSuchMethodRegistry.otherImpls.contains( |
| 253 clsA.lookupMember('noSuchMethod'))); | 253 clsA.lookupMember('noSuchMethod'))); |
| 254 Expect.isTrue( | 254 Expect.isTrue( |
| 255 compiler.backend.noSuchMethodRegistry.complexNoReturnImpls.contains( | 255 compiler.backend.noSuchMethodRegistry.complexNoReturnImpls.contains( |
| 256 clsA.lookupMember('noSuchMethod'))); | 256 clsA.lookupMember('noSuchMethod'))); |
| 257 })); | 257 })); |
| 258 } | 258 } |
| 259 | 259 |
| 260 dummyImplTest12() { | 260 dummyImplTest12() { |
| 261 String source = """ | 261 String source = """ |
| 262 class A { | 262 class A { |
| 263 noSuchMethod(Invocation x) { | 263 noSuchMethod(Invocation x) { |
| 264 return toString(); | 264 return toString(); |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 main() { | 267 main() { |
| 268 print(new A().foo()); | 268 print(new A().foo()); |
| 269 } | 269 } |
| 270 """; | 270 """; |
| 271 Uri uri = new Uri(scheme: 'source'); | 271 Uri uri = new Uri(scheme: 'source'); |
| 272 var compiler = compilerFor(source, uri); | 272 var compiler = compilerFor(source, uri); |
| 273 asyncTest(() => compiler.runCompiler(uri).then((_) { | 273 asyncTest(() => compiler.run(uri).then((_) { |
| 274 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 274 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 275 ClassElement clsA = findElement(compiler, 'A'); | 275 ClassElement clsA = findElement(compiler, 'A'); |
| 276 Expect.isTrue( | 276 Expect.isTrue( |
| 277 compiler.backend.noSuchMethodRegistry.otherImpls.contains( | 277 compiler.backend.noSuchMethodRegistry.otherImpls.contains( |
| 278 clsA.lookupMember('noSuchMethod'))); | 278 clsA.lookupMember('noSuchMethod'))); |
| 279 Expect.isTrue( | 279 Expect.isTrue( |
| 280 compiler.backend.noSuchMethodRegistry.complexReturningImpls.contains( | 280 compiler.backend.noSuchMethodRegistry.complexReturningImpls.contains( |
| 281 clsA.lookupMember('noSuchMethod'))); | 281 clsA.lookupMember('noSuchMethod'))); |
| 282 })); | 282 })); |
| 283 } | 283 } |
| 284 | 284 |
| 285 main() { | 285 main() { |
| 286 dummyImplTest(); | 286 dummyImplTest(); |
| 287 dummyImplTest2(); | 287 dummyImplTest2(); |
| 288 dummyImplTest3(); | 288 dummyImplTest3(); |
| 289 dummyImplTest4(); | 289 dummyImplTest4(); |
| 290 dummyImplTest5(); | 290 dummyImplTest5(); |
| 291 dummyImplTest6(); | 291 dummyImplTest6(); |
| 292 dummyImplTest7(); | 292 dummyImplTest7(); |
| 293 dummyImplTest8(); | 293 dummyImplTest8(); |
| 294 dummyImplTest9(); | 294 dummyImplTest9(); |
| 295 dummyImplTest10(); | 295 dummyImplTest10(); |
| 296 dummyImplTest11(); | 296 dummyImplTest11(); |
| 297 dummyImplTest12(); | 297 dummyImplTest12(); |
| 298 } | 298 } |
| OLD | NEW |