| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 // Test ensuring that compiler can parse metadata. Need to add negative | 5 // Test ensuring that compiler can parse metadata. Need to add negative |
| 6 // test cases with illegal metadata annotations. | 6 // test cases with illegal metadata annotations. |
| 7 | 7 |
| 8 library metadata_test.dart; | 8 library metadata_test.dart; |
| 9 |
| 9 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| 10 import "metadata_lib.dart" as Meta; | 11 import "metadata_lib.dart" as Meta; |
| 11 | 12 |
| 12 class Tag { | 13 class Tag { |
| 13 final String annotation; | 14 final String annotation; |
| 14 const Tag(this.annotation); | 15 const Tag(this.annotation); |
| 15 } | 16 } |
| 16 | 17 |
| 17 const meta1 = 1; | 18 const meta1 = 1; |
| 18 const meta2 = const Tag("meta2"); | 19 const meta2 = const Tag("meta2"); |
| 19 | 20 |
| 20 const extern = const Tag("external"); | 21 const extern = const Tag("external"); |
| 21 | 22 |
| 22 @meta1 var topLevelVar; | 23 @meta1 |
| 23 @Meta.Alien.unspecified() List unknownUnknowns; | 24 var topLevelVar; |
| 25 @Meta.Alien.unspecified() |
| 26 List unknownUnknowns; |
| 24 | 27 |
| 25 @meta1 typedef int DingDong<@meta2 T>(@meta1 event); | 28 @meta1 |
| 29 typedef int DingDong<@meta2 T>(@meta1 event); |
| 26 | 30 |
| 27 @meta1 class A <@Tag("typeParam") T> { | 31 @meta1 |
| 28 @meta1 @meta2 | 32 class A<@Tag("typeParam") T> { |
| 33 @meta1 |
| 34 @meta2 |
| 29 static String staticField; | 35 static String staticField; |
| 30 | 36 |
| 31 @Meta.Alien("ET") int foo(@meta1 bool fool, {@meta1 @Tag("opt") x: 100}) { | 37 @Meta.Alien("ET") |
| 32 @meta2 @meta1 g() => 10; | 38 int foo(@meta1 bool fool, {@meta1 @Tag("opt") x: 100}) { |
| 39 g() => 10; |
| 33 return x * g(); | 40 return x * g(); |
| 34 } | 41 } |
| 35 | 42 |
| 36 @Tag(r"timewarp") | 43 @Tag(r"timewarp") |
| 37 List<int> getNextWeeksLottoNumbers() => [1, 2, 3, 4, 5, 6]; | 44 List<int> getNextWeeksLottoNumbers() => [1, 2, 3, 4, 5, 6]; |
| 38 } | 45 } |
| 39 | 46 |
| 40 @meta1 main() { | 47 @meta1 |
| 41 @meta1 var a = new A(); | 48 main() { |
| 49 @meta1 |
| 50 var a = new A(); |
| 42 Expect.equals(0, a.foo(false, x: 0)); | 51 Expect.equals(0, a.foo(false, x: 0)); |
| 43 | 52 |
| 44 for (@Tag("loopvar") int i = 0; i < 10; i++) { | 53 for (@Tag("loopvar") |
| 54 int i = 0; |
| 55 i < 10; |
| 56 i++) { |
| 45 // Do something. | 57 // Do something. |
| 46 } | 58 } |
| 47 | 59 |
| 48 @meta1 var s = r'This is a raw \\ string.'; | 60 @meta1 |
| 61 var s = r'This is a raw \\ string.'; |
| 49 } | 62 } |
| OLD | NEW |