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

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

Issue 27510003: Scanner for UTF-8 byte arrays (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixes compiler tests Created 7 years, 2 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import "package:async_helper/async_helper.dart"; 6 import "package:async_helper/async_helper.dart";
7 import 'compiler_helper.dart'; 7 import 'compiler_helper.dart';
8 import 'parser_helper.dart'; 8 import 'parser_helper.dart';
9 9
10 void checkPosition(Spannable spannable, Node node, String source, compiler) { 10 void checkPosition(Spannable spannable, Node node, String source, compiler) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 @native 75 @native
76 $declaration 76 $declaration
77 } 77 }
78 main() {}"""; 78 main() {}""";
79 79
80 compileAndCheck(source3, 'Foo', (compiler, element) { 80 compileAndCheck(source3, 'Foo', (compiler, element) {
81 compiler.enqueuer.resolution.queueIsClosed = false; 81 compiler.enqueuer.resolution.queueIsClosed = false;
82 Expect.equals(0, length(element.metadata)); 82 Expect.equals(0, length(element.metadata));
83 element.ensureResolved(compiler); 83 element.ensureResolved(compiler);
84 Expect.equals(0, length(element.metadata)); 84 Expect.equals(0, length(element.metadata));
85 element = element.lookupLocalMember(buildSourceString(name)); 85 element = element.lookupLocalMember(name);
86 Expect.equals(1, length(element.metadata)); 86 Expect.equals(1, length(element.metadata));
87 PartialMetadataAnnotation annotation = element.metadata.head; 87 PartialMetadataAnnotation annotation = element.metadata.head;
88 annotation.ensureResolved(compiler); 88 annotation.ensureResolved(compiler);
89 Constant value = annotation.value; 89 Constant value = annotation.value;
90 Expect.stringEquals('xyz', value.value.slowToString()); 90 Expect.stringEquals('xyz', value.value.slowToString());
91 91
92 checkPosition(annotation, annotation.cachedNode, source3, compiler); 92 checkPosition(annotation, annotation.cachedNode, source3, compiler);
93 }); 93 });
94 94
95 // Ensure that each repeated annotation has a unique instance of 95 // Ensure that each repeated annotation has a unique instance of
96 // [MetadataAnnotation]. 96 // [MetadataAnnotation].
97 var source4 = """const native = 'xyz'; 97 var source4 = """const native = 'xyz';
98 class Foo { 98 class Foo {
99 @native @native 99 @native @native
100 $declaration 100 $declaration
101 } 101 }
102 main() {}"""; 102 main() {}""";
103 103
104 compileAndCheck(source4, 'Foo', (compiler, element) { 104 compileAndCheck(source4, 'Foo', (compiler, element) {
105 compiler.enqueuer.resolution.queueIsClosed = false; 105 compiler.enqueuer.resolution.queueIsClosed = false;
106 Expect.equals(0, length(element.metadata)); 106 Expect.equals(0, length(element.metadata));
107 element.ensureResolved(compiler); 107 element.ensureResolved(compiler);
108 Expect.equals(0, length(element.metadata)); 108 Expect.equals(0, length(element.metadata));
109 element = element.lookupLocalMember(buildSourceString(name)); 109 element = element.lookupLocalMember(name);
110 Expect.equals(2, length(element.metadata)); 110 Expect.equals(2, length(element.metadata));
111 PartialMetadataAnnotation annotation1 = element.metadata.head; 111 PartialMetadataAnnotation annotation1 = element.metadata.head;
112 PartialMetadataAnnotation annotation2 = element.metadata.tail.head; 112 PartialMetadataAnnotation annotation2 = element.metadata.tail.head;
113 annotation1.ensureResolved(compiler); 113 annotation1.ensureResolved(compiler);
114 annotation2.ensureResolved(compiler); 114 annotation2.ensureResolved(compiler);
115 Expect.isFalse(identical(annotation1, annotation2), 115 Expect.isFalse(identical(annotation1, annotation2),
116 'expected unique instances'); 116 'expected unique instances');
117 Expect.notEquals(annotation1, annotation2, 'expected unequal instances'); 117 Expect.notEquals(annotation1, annotation2, 'expected unequal instances');
118 Constant value1 = annotation1.value; 118 Constant value1 = annotation1.value;
119 Constant value2 = annotation2.value; 119 Constant value2 = annotation2.value;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 compileAndCheckLibrary(source, 207 compileAndCheckLibrary(source,
208 (e) => e.compilationUnits.first.partTag.metadata); 208 (e) => e.compilationUnits.first.partTag.metadata);
209 } 209 }
210 210
211 void main() { 211 void main() {
212 testClassMetadata(); 212 testClassMetadata();
213 testTopLevelMethodMetadata(); 213 testTopLevelMethodMetadata();
214 testTopLevelFieldMetadata(); 214 testTopLevelFieldMetadata();
215 testLibraryTags(); 215 testLibraryTags();
216 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698