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

Side by Side Diff: tests/lib/mirrors/enum_test.dart

Issue 938513002: Add ClassMirror.isEnum. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« runtime/lib/mirrors.cc ('K') | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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.enums;
6
7 import 'dart:mirrors';
8 import 'package:expect/expect.dart';
9 import 'stringify.dart';
10
11 class C {}
12 enum Suite { CLUBS, DIAMONDS, SPADES, HEARTS }
13
14 main() {
15 Expect.isFalse(reflectClass(C).isEnum);
16
17 Expect.isTrue(reflectClass(Suite).isEnum);
18 Expect.isFalse(reflectClass(Suite).isAbstract);
19 Expect.equals(0, reflectClass(Suite).declarations.values.where(
20 (d) => d is MethodMirror && d.isConstructor).length);
21
22 Expect.equals(reflectClass(Suite),
23 (reflectClass(C).owner as LibraryMirror).declarations[#Suite],
24 "found in library");
25
26 Expect.equals(reflectClass(Suite), reflect(Suite.CLUBS).type);
27
28 Expect.equals(0, reflect(Suite.CLUBS).getField(#index).reflectee);
29 Expect.equals(1, reflect(Suite.DIAMONDS).getField(#index).reflectee);
30 Expect.equals(2, reflect(Suite.SPADES).getField(#index).reflectee);
31 Expect.equals(3, reflect(Suite.HEARTS).getField(#index).reflectee);
32
33 Expect.equals("Suite.CLUBS",
34 reflect(Suite.CLUBS).invoke(#toString, []).reflectee);
35 Expect.equals("Suite.DIAMONDS",
36 reflect(Suite.DIAMONDS).invoke(#toString, []).reflectee);
37 Expect.equals("Suite.SPADES",
38 reflect(Suite.SPADES).invoke(#toString, []).reflectee);
39 Expect.equals("Suite.HEARTS",
40 reflect(Suite.HEARTS).invoke(#toString, []).reflectee);
41
42 Expect.setEquals(
43 ['Variable(s(index) in s(Suite), final)',
44 'Variable(s(CLUBS) in s(Suite), static, final)',
45 'Variable(s(DIAMONDS) in s(Suite), static, final)',
46 'Variable(s(SPADES) in s(Suite), static, final)',
47 'Variable(s(HEARTS) in s(Suite), static, final)',
48 'Variable(s(values) in s(Suite), static, final)',
49 'Method(s(toString) in s(Suite))'],
50 reflectClass(Suite).declarations.values
51 .where((d) => !d.isPrivate).map(stringify));
52 }
OLDNEW
« runtime/lib/mirrors.cc ('K') | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698