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

Unified Diff: dart/tests/compiler/dart2js/metadata_test.dart

Issue 12184017: MetadataAnnotation should be spannable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/compiler/dart2js/metadata_test.dart
diff --git a/dart/tests/compiler/dart2js/metadata_test.dart b/dart/tests/compiler/dart2js/metadata_test.dart
index 79a0595d5095170ab6af6fd6175f3f8198ea2c18..de74b88ab49a16d1cf7237ca859c9051adcf93c6 100644
--- a/dart/tests/compiler/dart2js/metadata_test.dart
+++ b/dart/tests/compiler/dart2js/metadata_test.dart
@@ -9,6 +9,22 @@ import 'parser_helper.dart';
import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart';
import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart';
+import '../../../sdk/lib/_internal/compiler/implementation/util/util.dart'
+ show Spannable;
+import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart'
+ show Node;
+
+void checkPosition(Spannable spannable, Node node, String source, compiler) {
+ SourceSpan span = compiler.spanFromSpannable(spannable);
+ Expect.isTrue(span.begin < span.end,
+ 'begin = ${span.begin}; end = ${span.end}');
+ Expect.isTrue(span.end < source.length,
+ 'end = ${span.end}; length = ${source.length}');
+ String yield = source.substring(span.begin, span.end);
+
+ // TODO(ahe): The node does not include "@". Fix that.
ahe 2013/02/05 09:54:10 Filed http://dartbug.com/8326.
+ Expect.stringEquals('@$node', yield);
+}
void checkAnnotation(String name, String declaration,
{bool isTopLevelOnly: false}) {
@@ -24,10 +40,12 @@ void checkAnnotation(String name, String declaration,
compileAndCheck(source, name, (compiler, element) {
compiler.enqueuer.resolution.queueIsClosed = false;
Expect.equals(1, length(element.metadata));
- MetadataAnnotation annotation = element.metadata.head;
+ PartialMetadataAnnotation annotation = element.metadata.head;
annotation.ensureResolved(compiler);
Constant value = annotation.value;
Expect.stringEquals('xyz', value.value.slowToString());
+
+ checkPosition(annotation, annotation.cachedNode, source, compiler);
});
// Ensure that each repeated annotation has a unique instance of
@@ -40,8 +58,8 @@ void checkAnnotation(String name, String declaration,
compileAndCheck(source, name, (compiler, element) {
compiler.enqueuer.resolution.queueIsClosed = false;
Expect.equals(2, length(element.metadata));
- MetadataAnnotation annotation1 = element.metadata.head;
- MetadataAnnotation annotation2 = element.metadata.tail.head;
+ PartialMetadataAnnotation annotation1 = element.metadata.head;
+ PartialMetadataAnnotation annotation2 = element.metadata.tail.head;
annotation1.ensureResolved(compiler);
annotation2.ensureResolved(compiler);
Expect.isFalse(identical(annotation1, annotation2),
@@ -52,6 +70,9 @@ void checkAnnotation(String name, String declaration,
Expect.identical(value1, value2, 'expected same compile-time constant');
Expect.stringEquals('xyz', value1.value.slowToString());
Expect.stringEquals('xyz', value2.value.slowToString());
+
+ checkPosition(annotation1, annotation1.cachedNode, source, compiler);
+ checkPosition(annotation2, annotation2.cachedNode, source, compiler);
});
if (isTopLevelOnly) return;
@@ -72,10 +93,12 @@ void checkAnnotation(String name, String declaration,
Expect.equals(0, length(element.metadata));
element = element.lookupLocalMember(buildSourceString(name));
Expect.equals(1, length(element.metadata));
- MetadataAnnotation annotation = element.metadata.head;
+ PartialMetadataAnnotation annotation = element.metadata.head;
annotation.ensureResolved(compiler);
Constant value = annotation.value;
Expect.stringEquals('xyz', value.value.slowToString());
+
+ checkPosition(annotation, annotation.cachedNode, source, compiler);
});
// Ensure that each repeated annotation has a unique instance of
@@ -94,8 +117,8 @@ void checkAnnotation(String name, String declaration,
Expect.equals(0, length(element.metadata));
element = element.lookupLocalMember(buildSourceString(name));
Expect.equals(2, length(element.metadata));
- MetadataAnnotation annotation1 = element.metadata.head;
- MetadataAnnotation annotation2 = element.metadata.tail.head;
+ PartialMetadataAnnotation annotation1 = element.metadata.head;
+ PartialMetadataAnnotation annotation2 = element.metadata.tail.head;
annotation1.ensureResolved(compiler);
annotation2.ensureResolved(compiler);
Expect.isFalse(identical(annotation1, annotation2),
@@ -106,6 +129,9 @@ void checkAnnotation(String name, String declaration,
Expect.identical(value1, value2, 'expected same compile-time constant');
Expect.stringEquals('xyz', value1.value.slowToString());
Expect.stringEquals('xyz', value2.value.slowToString());
+
+ checkPosition(annotation1, annotation1.cachedNode, source, compiler);
+ checkPosition(annotation1, annotation2.cachedNode, source, compiler);
});
}
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698