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

Side by Side Diff: dart/tests/compiler/dart2js/metadata_test.dart

Issue 10870010: Evaluate compile-time constants of metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #import("dart:uri"); 5 #import("dart:uri");
6 6
7 #import('compiler_helper.dart'); 7 #import('compiler_helper.dart');
8 8
9 #import('../../../lib/compiler/implementation/elements/elements.dart'); 9 #import('../../../lib/compiler/implementation/elements/elements.dart');
10 #import('../../../lib/compiler/implementation/leg.dart'); 10 #import('../../../lib/compiler/implementation/leg.dart');
11 11
12 void testClassMetadata() { 12 void testClassMetadata() {
13 // TODO(ahe): native should be "const", not "final". 13 // TODO(ahe): native should be "const", not "final".
14 final source = """final native = 'xyz'; 14 final source = """final native = 'xyz';
15 @native class Foo {} 15 @native class Foo {}
16 main() {}"""; 16 main() {}""";
17 17
18 check(compiler, element) { 18 check(compiler, element) {
19 Expect.isFalse(element.metadata.isEmpty()); 19 Expect.isFalse(element.metadata.isEmpty());
20 Expect.isTrue(element.metadata.tail.isEmpty());
20 MetadataAnnotation annotation = element.metadata.head; 21 MetadataAnnotation annotation = element.metadata.head;
21 Expect.isNotNull(annotation); 22 annotation.ensureResolved(compiler);
22 Constant value = annotation.value; 23 Constant value = annotation.value;
23 return; // TODO(ahe): I'm working on the following. 24 Expect.stringEquals('xyz', value.value.slowToString());
24 Expect.isNotNull(value);
25 } 25 }
26 26
27 compileAndCheck(source, 'Foo', check); 27 compileAndCheck(source, 'Foo', check);
28 } 28 }
29 29
30 void testTopLevelMethodMetadata() { 30 void testTopLevelMethodMetadata() {
31 // TODO(ahe): native should be "const", not "final". 31 // TODO(ahe): native should be "const", not "final".
32 final source = """final native = 'xyz'; 32 final source = """final native = 'xyz';
33 @native 33 @native
34 main() {}"""; 34 main() {}""";
35 35
36 check(compiler, element) { 36 check(compiler, element) {
37 Expect.isFalse(element.metadata.isEmpty()); 37 Expect.isFalse(element.metadata.isEmpty());
38 Expect.isTrue(element.metadata.tail.isEmpty());
38 MetadataAnnotation annotation = element.metadata.head; 39 MetadataAnnotation annotation = element.metadata.head;
39 Expect.isNotNull(annotation); 40 annotation.ensureResolved(compiler);
40 Constant value = annotation.value; 41 Constant value = annotation.value;
41 return; // TODO(ahe): I'm working on the following. 42 Expect.stringEquals('xyz', value.value.slowToString());
42 Expect.isNotNull(value);
43 } 43 }
44 44
45 compileAndCheck(source, 'main', check); 45 compileAndCheck(source, 'main', check);
46 } 46 }
47 47
48 void main() { 48 void main() {
49 testClassMetadata(); 49 testClassMetadata();
50 testTopLevelMethodMetadata(); 50 testTopLevelMethodMetadata();
51 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698