mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 05:41:37 +00:00
b99dafd2d2
BUG= http://dartbug.com/19635 R=johnniwinther@google.com Review URL: https://codereview.chromium.org//417693002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38536 260f80e4-7a28-3924-810f-c04153c831b5
116 lines
3.6 KiB
Dart
116 lines
3.6 KiB
Dart
// Copyright (c) 2014, 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 mirror_test;
|
|
|
|
@MirrorsUsed(targets: "mirror_test")
|
|
import 'dart:mirrors';
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
class A {
|
|
var req1, opt1, opt2;
|
|
A.a0([opt1]) : this.opt1 = opt1;
|
|
A.b0([opt1, opt2]) : this.opt1 = opt1, this.opt2 = opt2;
|
|
A.c0([opt1 = 499]) : this.opt1 = opt1;
|
|
A.d0([opt1 = 499, opt2 = 42]) : this.opt1 = opt1, this.opt2 = opt2;
|
|
A.a1(req1, [opt1]) : this.req1 = req1, this.opt1 = opt1;
|
|
A.b1(req1, [opt1, opt2])
|
|
: this.req1 = req1, this.opt1 = opt1, this.opt2 = opt2;
|
|
A.c1(req1, [opt1 = 499]) : this.req1 = req1, this.opt1 = opt1;
|
|
A.d1(req1, [opt1 = 499, opt2 = 42])
|
|
: this.req1 = req1, this.opt1 = opt1, this.opt2 = opt2;
|
|
}
|
|
|
|
main() {
|
|
ClassMirror cm = reflectClass(A);
|
|
|
|
var o;
|
|
o = cm.newInstance(#a0, []).reflectee;
|
|
Expect.equals(null, o.req1);
|
|
Expect.equals(null, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#b0, []).reflectee;
|
|
Expect.equals(null, o.req1);
|
|
Expect.equals(null, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#c0, []).reflectee;
|
|
Expect.equals(null, o.req1);
|
|
Expect.equals(499, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#d0, []).reflectee;
|
|
Expect.equals(null, o.req1);
|
|
Expect.equals(499, o.opt1);
|
|
Expect.equals(42, o.opt2);
|
|
|
|
o = cm.newInstance(#a0, [77]).reflectee;
|
|
Expect.equals(null, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#b0, [77]).reflectee;
|
|
Expect.equals(null, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#c0, [77]).reflectee;
|
|
Expect.equals(null, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#d0, [77]).reflectee;
|
|
Expect.equals(null, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(42, o.opt2);
|
|
|
|
o = cm.newInstance(#b0, [77, 11]).reflectee;
|
|
Expect.equals(null, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(11, o.opt2);
|
|
o = cm.newInstance(#d0, [77, 11]).reflectee;
|
|
Expect.equals(null, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(11, o.opt2);
|
|
|
|
o = cm.newInstance(#a1, [123]).reflectee;
|
|
Expect.equals(123, o.req1);
|
|
Expect.equals(null, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#b1, [123]).reflectee;
|
|
Expect.equals(123, o.req1);
|
|
Expect.equals(null, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#c1, [123]).reflectee;
|
|
Expect.equals(123, o.req1);
|
|
Expect.equals(499, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#d1, [123]).reflectee;
|
|
Expect.equals(123, o.req1);
|
|
Expect.equals(499, o.opt1);
|
|
Expect.equals(42, o.opt2);
|
|
|
|
o = cm.newInstance(#a1, [123, 77]).reflectee;
|
|
Expect.equals(123, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#b1, [123, 77]).reflectee;
|
|
Expect.equals(123, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#c1, [123, 77]).reflectee;
|
|
Expect.equals(123, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(null, o.opt2);
|
|
o = cm.newInstance(#d1, [123, 77]).reflectee;
|
|
Expect.equals(123, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(42, o.opt2);
|
|
|
|
o = cm.newInstance(#b1, [123, 77, 11]).reflectee;
|
|
Expect.equals(123, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(11, o.opt2);
|
|
o = cm.newInstance(#d1, [123, 77, 11]).reflectee;
|
|
Expect.equals(123, o.req1);
|
|
Expect.equals(77, o.opt1);
|
|
Expect.equals(11, o.opt2);
|
|
}
|