blob: 78e814fe773141ca74331dbf2120b79c52a819ba [file] [log] [blame]
// Copyright (c) 2013, 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.
library test.parameter_metadata_test;
import 'dart:mirrors';
import 'metadata_test.dart';
const m1 = 'm1';
const m2 = #m2;
const m3 = const CustomAnnotation(3);
class CustomAnnotation {
final value;
const CustomAnnotation(this.value);
toString() => 'CustomAnnotation($value)';
}
class B {
B.foo(int x) {}
factory B.bar(@m3 @m2 int z, x) => new B.foo(0);
baz(@m1 final int x, @m2 int y, @m3 final int z) {}
qux(int x, [@m3 @m2 @m1 int y = 3 + 1]) {}
quux(int x, {String str: "foo"}) {}
corge({@m1 int x: 3 * 17, @m2 String str: "bar"}) {}
set x(@m2 final value) {}
}
main() {
ClassMirror cm = reflectClass(B);
MethodMirror mm;
mm = cm.declarations[#B.foo] as MethodMirror;
checkMetadata(mm.parameters[0], []);
mm = cm.declarations[#B.bar] as MethodMirror;
checkMetadata(mm.parameters[0], [m3, m2]);
checkMetadata(mm.parameters[1], []);
mm = cm.declarations[#baz] as MethodMirror;
checkMetadata(mm.parameters[0], [m1]);
checkMetadata(mm.parameters[1], [m2]);
checkMetadata(mm.parameters[2], [m3]);
mm = cm.declarations[#qux] as MethodMirror;
checkMetadata(mm.parameters[0], []);
checkMetadata(mm.parameters[1], [m3, m2, m1]);
mm = cm.declarations[#quux] as MethodMirror;
checkMetadata(mm.parameters[0], []);
checkMetadata(mm.parameters[1], []);
mm = cm.declarations[#corge] as MethodMirror;
checkMetadata(mm.parameters[0], [m1]);
checkMetadata(mm.parameters[1], [m2]);
mm = cm.declarations[const Symbol('x=')] as MethodMirror;
checkMetadata(mm.parameters[0], [m2]);
}