Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: test/codegen/lib/mirrors/set_field_with_final_inheritance_test.dart

Issue 2265533002: Add mirrors tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013, 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 test.set_field_with_final_inheritance;
6
7 import 'dart:mirrors';
8 import 'package:expect/expect.dart';
9
10 class S {
11 var sideEffect = 0;
12
13 var mutableWithInheritedMutable = 1;
14 final mutableWithInheritedFinal = 2;
15 set mutableWithInheritedSetter(x) => sideEffect = 3;
16
17 var finalWithInheritedMutable = 4;
18 final finalWithInheritedFinal = 5;
19 set finalWithInheritedSetter(x) => sideEffect = 6;
20
21 var setterWithInheritedMutable = 7;
22 final setterWithInheritedFinal = 8;
23 set setterWithInheritedSetter(x) => sideEffect = 9;
24 }
25
26 class C extends S {
27 var mutableWithInheritedMutable = 10;
28 var mutableWithInheritedFinal = 11;
29 var mutableWithInheritedSetter = 12;
30
31 final finalWithInheritedMutable = 13;
32 final finalWithInheritedFinal = 14;
33 final finalWithInheritedSetter = 15;
34
35 set setterWithInheritedMutable(x) => sideEffect = 16;
36 set setterWithInheritedFinal(x) => sideEffect = 17;
37 set setterWithInheritedSetter(x) => sideEffect = 18;
38
39 get superMutableWithInheritedMutable => super.mutableWithInheritedMutable;
40 get superMutableWithInheritedFinal => super.mutableWithInheritedFinal;
41
42 get superFinalWithInheritedMutable => super.finalWithInheritedMutable;
43 get superFinalWithInheritedFinal => super.finalWithInheritedFinal;
44
45 get superSetterWithInheritedMutable => super.setterWithInheritedMutable;
46 get superSetterWithInheritedFinal => super.setterWithInheritedFinal;
47 }
48
49 main() {
50 C c;
51 InstanceMirror im;
52
53 c = new C();
54 im = reflect(c);
55 Expect.equals(19, im.setField(#mutableWithInheritedMutable, 19).reflectee);
56 Expect.equals(19, c.mutableWithInheritedMutable);
57 Expect.equals(1, c.superMutableWithInheritedMutable);
58 Expect.equals(0, c.sideEffect);
59
60 c = new C();
61 im = reflect(c);
62 Expect.equals(20, im.setField(#mutableWithInheritedFinal, 20).reflectee);
63 Expect.equals(20, c.mutableWithInheritedFinal);
64 Expect.equals(2, c.superMutableWithInheritedFinal);
65 Expect.equals(0, c.sideEffect);
66
67 c = new C();
68 im = reflect(c);
69 Expect.equals(21, im.setField(#mutableWithInheritedSetter, 21).reflectee);
70 Expect.equals(21, c.mutableWithInheritedSetter);
71 Expect.equals(0, c.sideEffect);
72
73
74 c = new C();
75 im = reflect(c);
76 Expect.equals(22, im.setField(#finalWithInheritedMutable, 22).reflectee);
77 Expect.equals(13, c.finalWithInheritedMutable);
78 Expect.equals(22, c.superFinalWithInheritedMutable);
79 Expect.equals(0, c.sideEffect);
80
81 c = new C();
82 im = reflect(c);
83 Expect.throws(() => im.setField(#finalWithInheritedFinal, 23),
84 (e) => e is NoSuchMethodError);
85 Expect.equals(14, c.finalWithInheritedFinal);
86 Expect.equals(5, c.superFinalWithInheritedFinal);
87 Expect.equals(0, c.sideEffect);
88
89 c = new C();
90 im = reflect(c);
91 Expect.equals(24, im.setField(#finalWithInheritedSetter, 24).reflectee);
92 Expect.equals(15, c.finalWithInheritedSetter);
93 Expect.equals(6, c.sideEffect);
94
95
96 c = new C();
97 im = reflect(c);
98 Expect.equals(25, im.setField(#setterWithInheritedMutable, 25).reflectee);
99 Expect.equals(7, c.setterWithInheritedMutable);
100 Expect.equals(7, c.superSetterWithInheritedMutable);
101 Expect.equals(16, c.sideEffect);
102
103 c = new C();
104 im = reflect(c);
105 Expect.equals(26, im.setField(#setterWithInheritedFinal, 26).reflectee);
106 Expect.equals(8, c.setterWithInheritedFinal);
107 Expect.equals(8, c.superSetterWithInheritedFinal);
108 Expect.equals(17, c.sideEffect);
109
110 c = new C();
111 im = reflect(c);
112 Expect.equals(27, im.setField(#setterWithInheritedSetter, 27).reflectee);
113 Expect.equals(18, c.sideEffect);
114 }
OLDNEW
« no previous file with comments | « test/codegen/lib/mirrors/runtime_type_test.dart ('k') | test/codegen/lib/mirrors/set_field_with_final_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698