2012-09-07 23:06:48 +00:00
|
|
|
// Copyright (c) 2012, 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.
|
|
|
|
|
|
|
|
// Test ensuring that compiler can parse metadata. Need to add negative
|
|
|
|
// test cases with illegal metadata annotations.
|
|
|
|
|
2012-11-30 23:20:01 +00:00
|
|
|
library metadata_test.dart;
|
2013-04-05 19:43:16 +00:00
|
|
|
import "package:expect/expect.dart";
|
2012-11-30 23:20:01 +00:00
|
|
|
import "metadata_lib.dart" as Meta;
|
2012-09-07 23:06:48 +00:00
|
|
|
|
|
|
|
class Tag {
|
|
|
|
final String annotation;
|
|
|
|
const Tag(this.annotation);
|
|
|
|
}
|
|
|
|
|
|
|
|
const meta1 = 1;
|
|
|
|
const meta2 = const Tag("meta2");
|
|
|
|
|
|
|
|
const extern = const Tag("external");
|
|
|
|
|
|
|
|
@meta1 var topLevelVar;
|
|
|
|
@Meta.Alien.unspecified() List unknownUnknowns;
|
|
|
|
|
|
|
|
@meta1 typedef int DingDong<@meta2 T>(@meta1 event);
|
|
|
|
|
|
|
|
@meta1 class A <@Tag("typeParam") T> {
|
|
|
|
@meta1 @meta2
|
|
|
|
static String staticField;
|
|
|
|
|
2012-09-07 23:20:21 +00:00
|
|
|
@Meta.Alien("ET") int foo(@meta1 bool fool, {@meta1 @Tag("opt") x: 100}) {
|
2015-03-26 18:28:38 +00:00
|
|
|
@meta2 @meta1 g() => 10;
|
|
|
|
return x * g();
|
2012-09-07 23:06:48 +00:00
|
|
|
}
|
|
|
|
|
2012-09-25 20:09:34 +00:00
|
|
|
@Tag(r"timewarp")
|
2012-09-07 23:06:48 +00:00
|
|
|
List<int> getNextWeeksLottoNumbers() => [1, 2, 3, 4, 5, 6];
|
|
|
|
}
|
|
|
|
|
|
|
|
@meta1 main() {
|
|
|
|
@meta1 var a = new A();
|
|
|
|
Expect.equals(0, a.foo(false, x: 0));
|
|
|
|
|
|
|
|
for (@Tag("loopvar") int i = 0; i < 10; i++) {
|
|
|
|
// Do something.
|
|
|
|
}
|
|
|
|
|
2012-09-25 20:09:34 +00:00
|
|
|
@meta1 var s = r'This is a raw \\ string.';
|
2012-09-07 23:06:48 +00:00
|
|
|
}
|