Chromium Code Reviews| Index: tests/compiler/dart2js/no_such_method_enabled_test.dart |
| diff --git a/tests/compiler/dart2js/no_such_method_enabled_test.dart b/tests/compiler/dart2js/no_such_method_enabled_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f57d42306ebe33eda0241acb2001220b480147ba |
| --- /dev/null |
| +++ b/tests/compiler/dart2js/no_such_method_enabled_test.dart |
| @@ -0,0 +1,127 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import 'package:expect/expect.dart'; |
| +import "package:async_helper/async_helper.dart"; |
| +import 'compiler_helper.dart'; |
| + |
| +dummyImplTest() { |
| + String source = """ |
| +class A { |
| + foo() => 3; |
| + noSuchMethod(x) => super.noSuchMethod(x); |
| +} |
| +main() { |
| + print(new A().foo()); |
| +} |
| +"""; |
| + Uri uri = new Uri(scheme: 'source'); |
| + var compiler = compilerFor(source, uri); |
| + asyncTest(() => |
| + compiler.runCompiler(uri).then((_) => |
| + Expect.isFalse(compiler.backend.enabledNoSuchMethod))); |
| +} |
| + |
| +dummyImplTest2() { |
| + String source = """ |
| +class A extends B { |
| + foo() => 3; |
| + noSuchMethod(x) => super.noSuchMethod(x); |
| +} |
| +class B {} |
| +main() { |
| + print(new A().foo()); |
| +} |
| +"""; |
| + Uri uri = new Uri(scheme: 'source'); |
| + var compiler = compilerFor(source, uri); |
| + asyncTest(() => |
| + compiler.runCompiler(uri).then((_) => |
| + Expect.isFalse(compiler.backend.enabledNoSuchMethod))); |
| +} |
| + |
| +dummyImplTest3() { |
| + String source = """ |
| +class A extends B { |
| + foo() => 3; |
| + noSuchMethod(x) { |
| + return super.noSuchMethod(x); |
| + } |
| +} |
| +class B {} |
| +main() { |
| + print(new A().foo()); |
| +} |
| +"""; |
| + Uri uri = new Uri(scheme: 'source'); |
| + var compiler = compilerFor(source, uri); |
| + asyncTest(() => |
| + compiler.runCompiler(uri).then((_) => |
| + Expect.isFalse(compiler.backend.enabledNoSuchMethod))); |
| +} |
| + |
| +dummyImplTest4() { |
| + String source = """ |
| +class A extends B { |
| + foo() => 3; |
| + noSuchMethod(x) => super.noSuchMethod(x); |
| +} |
| +class B { |
| + noSuchMethod(x) => super.noSuchMethod(x); |
| +} |
| +main() { |
| + print(new A().foo()); |
| +} |
| +"""; |
| + Uri uri = new Uri(scheme: 'source'); |
| + var compiler = compilerFor(source, uri); |
| + asyncTest(() => |
| + compiler.runCompiler(uri).then((_) => |
| + Expect.isFalse(compiler.backend.enabledNoSuchMethod))); |
| +} |
| + |
| +dummyImplTest5() { |
| + String source = """ |
| +class A extends B { |
| + foo() => 3; |
| + noSuchMethod(x) => super.noSuchMethod(x); |
| +} |
| +class B { |
| + noSuchMethod(x) => throw 'foo'; |
| +} |
| +main() { |
| + print(new A().foo()); |
| +} |
| +"""; |
| + Uri uri = new Uri(scheme: 'source'); |
| + var compiler = compilerFor(source, uri); |
| + asyncTest(() => |
| + compiler.runCompiler(uri).then((_) => |
| + Expect.isTrue(compiler.backend.enabledNoSuchMethod))); |
|
Johnni Winther
2015/03/18 10:47:16
Maybe test that [B.noSuchMethod] is in the [throwi
Harry Terkelsen
2015/03/18 20:54:50
Done.
|
| +} |
| + |
| +dummyImplTest6() { |
| + String source = """ |
| +class A { |
| + noSuchMethod(x) => 3; |
| +} |
| +main() { |
| + print(new A().foo()); |
| +} |
| +"""; |
| + Uri uri = new Uri(scheme: 'source'); |
| + var compiler = compilerFor(source, uri); |
| + asyncTest(() => |
| + compiler.runCompiler(uri).then((_) => |
| + Expect.isTrue(compiler.backend.enabledNoSuchMethod))); |
|
Johnni Winther
2015/03/18 10:47:16
Maybe test that [A.noSuchMethod] is in the [otherI
Harry Terkelsen
2015/03/18 20:54:50
Done.
|
| +} |
| + |
| +main() { |
| + dummyImplTest(); |
| + dummyImplTest2(); |
| + dummyImplTest3(); |
| + dummyImplTest4(); |
| + dummyImplTest5(); |
| + dummyImplTest6(); |
| +} |