Chromium Code Reviews

Side by Side Diff: test/codegen/lib/mirrors/hot_set_field_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.
Jump to:
View unified diff |
OLDNEW
(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 test.hot_set_field;
6
7 import 'dart:mirrors';
8 import 'package:expect/expect.dart';
9
10 class C {
11 var field;
12 var _field;
13 }
14
15 const int optimizationThreshold = 20;
16
17 testPublic() {
18 var c = new C();
19 var im = reflect(c);
20
21 for (int i = 0; i < (2 * optimizationThreshold); i++) {
22 im.setField(#field, i);
23 Expect.equals(i, c.field);
24 }
25 }
26
27 testPrivate() {
28 var c = new C();
29 var im = reflect(c);
30
31 for (int i = 0; i < (2 * optimizationThreshold); i++) {
32 im.setField(#_field, i);
33 Expect.equals(i, c._field);
34 }
35 }
36
37 testPrivateWrongLibrary() {
38 var c = new C();
39 var im = reflect(c);
40 var selector = MirrorSystem.getSymbol('_field', reflectClass(Mirror).owner);
41
42 for (int i = 0; i < (2 * optimizationThreshold); i++) {
43 Expect.throws(() => im.setField(selector, i), (e) => e is NoSuchMethodError) ;
44 }
45 }
46
47 main() {
48 testPublic();
49 testPrivate();
50 testPrivateWrongLibrary();
51 }
OLDNEW
« no previous file with comments | « test/codegen/lib/mirrors/hot_get_field_test.dart ('k') | test/codegen/lib/mirrors/immutable_collections_test.dart » ('j') | no next file with comments »

Powered by Google App Engine