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 library mirror_test; |
| 6 |
| 7 @MirrorsUsed(targets: "mirror_test") |
| 8 import 'dart:mirrors'; |
| 9 |
| 10 import 'package:expect/expect.dart'; |
| 11 |
| 12 class A { |
| 13 var req1, opt1, opt2; |
| 14 A.a0([opt1]) : this.opt1 = opt1; |
| 15 A.b0([opt1, opt2]) : this.opt1 = opt1, this.opt2 = opt2; |
| 16 A.c0([opt1 = 499]) : this.opt1 = opt1; |
| 17 A.d0([opt1 = 499, opt2 = 42]) : this.opt1 = opt1, this.opt2 = opt2; |
| 18 A.a1(req1, [opt1]) : this.req1 = req1, this.opt1 = opt1; |
| 19 A.b1(req1, [opt1, opt2]) |
| 20 : this.req1 = req1, this.opt1 = opt1, this.opt2 = opt2; |
| 21 A.c1(req1, [opt1 = 499]) : this.req1 = req1, this.opt1 = opt1; |
| 22 A.d1(req1, [opt1 = 499, opt2 = 42]) |
| 23 : this.req1 = req1, this.opt1 = opt1, this.opt2 = opt2; |
| 24 } |
| 25 |
| 26 main() { |
| 27 ClassMirror cm = reflectClass(A); |
| 28 |
| 29 var o; |
| 30 o = cm.newInstance(#a0, []).reflectee; |
| 31 Expect.equals(null, o.req1); |
| 32 Expect.equals(null, o.opt1); |
| 33 Expect.equals(null, o.opt2); |
| 34 o = cm.newInstance(#b0, []).reflectee; |
| 35 Expect.equals(null, o.req1); |
| 36 Expect.equals(null, o.opt1); |
| 37 Expect.equals(null, o.opt2); |
| 38 o = cm.newInstance(#c0, []).reflectee; |
| 39 Expect.equals(null, o.req1); |
| 40 Expect.equals(499, o.opt1); |
| 41 Expect.equals(null, o.opt2); |
| 42 o = cm.newInstance(#d0, []).reflectee; |
| 43 Expect.equals(null, o.req1); |
| 44 Expect.equals(499, o.opt1); |
| 45 Expect.equals(42, o.opt2); |
| 46 |
| 47 o = cm.newInstance(#a0, [77]).reflectee; |
| 48 Expect.equals(null, o.req1); |
| 49 Expect.equals(77, o.opt1); |
| 50 Expect.equals(null, o.opt2); |
| 51 o = cm.newInstance(#b0, [77]).reflectee; |
| 52 Expect.equals(null, o.req1); |
| 53 Expect.equals(77, o.opt1); |
| 54 Expect.equals(null, o.opt2); |
| 55 o = cm.newInstance(#c0, [77]).reflectee; |
| 56 Expect.equals(null, o.req1); |
| 57 Expect.equals(77, o.opt1); |
| 58 Expect.equals(null, o.opt2); |
| 59 o = cm.newInstance(#d0, [77]).reflectee; |
| 60 Expect.equals(null, o.req1); |
| 61 Expect.equals(77, o.opt1); |
| 62 Expect.equals(42, o.opt2); |
| 63 |
| 64 o = cm.newInstance(#b0, [77, 11]).reflectee; |
| 65 Expect.equals(null, o.req1); |
| 66 Expect.equals(77, o.opt1); |
| 67 Expect.equals(11, o.opt2); |
| 68 o = cm.newInstance(#d0, [77, 11]).reflectee; |
| 69 Expect.equals(null, o.req1); |
| 70 Expect.equals(77, o.opt1); |
| 71 Expect.equals(11, o.opt2); |
| 72 |
| 73 o = cm.newInstance(#a1, [123]).reflectee; |
| 74 Expect.equals(123, o.req1); |
| 75 Expect.equals(null, o.opt1); |
| 76 Expect.equals(null, o.opt2); |
| 77 o = cm.newInstance(#b1, [123]).reflectee; |
| 78 Expect.equals(123, o.req1); |
| 79 Expect.equals(null, o.opt1); |
| 80 Expect.equals(null, o.opt2); |
| 81 o = cm.newInstance(#c1, [123]).reflectee; |
| 82 Expect.equals(123, o.req1); |
| 83 Expect.equals(499, o.opt1); |
| 84 Expect.equals(null, o.opt2); |
| 85 o = cm.newInstance(#d1, [123]).reflectee; |
| 86 Expect.equals(123, o.req1); |
| 87 Expect.equals(499, o.opt1); |
| 88 Expect.equals(42, o.opt2); |
| 89 |
| 90 o = cm.newInstance(#a1, [123, 77]).reflectee; |
| 91 Expect.equals(123, o.req1); |
| 92 Expect.equals(77, o.opt1); |
| 93 Expect.equals(null, o.opt2); |
| 94 o = cm.newInstance(#b1, [123, 77]).reflectee; |
| 95 Expect.equals(123, o.req1); |
| 96 Expect.equals(77, o.opt1); |
| 97 Expect.equals(null, o.opt2); |
| 98 o = cm.newInstance(#c1, [123, 77]).reflectee; |
| 99 Expect.equals(123, o.req1); |
| 100 Expect.equals(77, o.opt1); |
| 101 Expect.equals(null, o.opt2); |
| 102 o = cm.newInstance(#d1, [123, 77]).reflectee; |
| 103 Expect.equals(123, o.req1); |
| 104 Expect.equals(77, o.opt1); |
| 105 Expect.equals(42, o.opt2); |
| 106 |
| 107 o = cm.newInstance(#b1, [123, 77, 11]).reflectee; |
| 108 Expect.equals(123, o.req1); |
| 109 Expect.equals(77, o.opt1); |
| 110 Expect.equals(11, o.opt2); |
| 111 o = cm.newInstance(#d1, [123, 77, 11]).reflectee; |
| 112 Expect.equals(123, o.req1); |
| 113 Expect.equals(77, o.opt1); |
| 114 Expect.equals(11, o.opt2); |
| 115 } |
OLD | NEW |