| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, 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 // Tests that dart2js doesn't support metadata on local elements. | |
| 6 // Remove this file when dart2js support such features. | |
| 7 library trydart.forget_element_assertion; | |
| 8 | |
| 9 import '../../compiler/dart2js/mock_compiler.dart' show | |
| 10 compilerFor; | |
| 11 | |
| 12 import 'compiler_test_case.dart'; | |
| 13 | |
| 14 class FailingTestCase extends CompilerTestCase { | |
| 15 FailingTestCase.intermediate(String source, int errorCount, Uri scriptUri) | |
| 16 : super.init( | |
| 17 source, scriptUri, | |
| 18 compilerFor(source, scriptUri, expectedErrors: errorCount)); | |
| 19 | |
| 20 FailingTestCase(String source, int errorCount) | |
| 21 : this.intermediate(source, errorCount, customUri('main.dart')); | |
| 22 | |
| 23 Future run() { | |
| 24 return compile().then((_) { | |
| 25 print("Failed as expected."); | |
| 26 }).catchError((error, stackTrace) { | |
| 27 print( | |
| 28 "\n\n\n***\n\n\n" | |
| 29 "The compiler didn't fail when compiling:\n $source\n\n" | |
| 30 "Please adjust assumptions in " | |
| 31 "tests/try/poi/forget_element_assertion.dart\n\n" | |
| 32 ); | |
| 33 print("$error\n$stackTrace"); | |
| 34 throw "Please update assumptions in this file."; | |
| 35 }); | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 List<FailingTestCase> assertUnimplementedLocalMetadata() { | |
| 40 return <FailingTestCase>[ | |
| 41 | |
| 42 // This tests that the compiler doesn't accept metadata on local | |
| 43 // functions. If this feature is implemented, please convert this test to | |
| 44 // a positive test in forget_element_test.dart. For example: | |
| 45 // | |
| 46 // new ForgetElementTestCase( | |
| 47 // 'main() { @Constant() foo() {}; return foo(); } $CONSTANT_CLASS', | |
| 48 // metadataCount: 1), | |
| 49 new FailingTestCase( | |
| 50 'main() { @Constant() foo() {}; return foo(); } $CONSTANT_CLASS', | |
| 51 1), | |
| 52 | |
| 53 // This tests that the compiler doesn't accept metadata on local | |
| 54 // variables. If this feature is implemented, please convert this test to | |
| 55 // a positive test in forget_element_test.dart. For example: | |
| 56 // | |
| 57 // new ForgetElementTestCase( | |
| 58 // 'main() { @Constant() var x; return x; } $CONSTANT_CLASS', | |
| 59 // metadataCount: 1), | |
| 60 new FailingTestCase( | |
| 61 'main() { @Constant() var x; return x; } $CONSTANT_CLASS', | |
| 62 1), | |
| 63 ]; | |
| 64 } | |
| OLD | NEW |