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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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 | « tests/compiler/dart2js/message_span_test.dart ('k') | tests/compiler/dart2js/minify_many_locals_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/metadata_test.dart
diff --git a/tests/compiler/dart2js/metadata_test.dart b/tests/compiler/dart2js/metadata_test.dart
index 9255a755a0b0ddf3191afaa4d0c41f8c3ac4a86c..ef2994ca194effd62e751f638f5eb60bf7b6a7e7 100644
--- a/tests/compiler/dart2js/metadata_test.dart
+++ b/tests/compiler/dart2js/metadata_test.dart
@@ -3,24 +3,21 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/constants/values.dart'
- show PrimitiveConstantValue;
+import 'package:compiler/src/constants/values.dart' show PrimitiveConstantValue;
import 'package:expect/expect.dart';
import 'compiler_helper.dart';
-import 'package:compiler/src/parser/partial_elements.dart' show
- PartialMetadataAnnotation;
-import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show
- DiagnosticReporter;
-
-void checkPosition(Spannable spannable,
- Node node,
- String source,
- DiagnosticReporter reporter) {
+import 'package:compiler/src/parser/partial_elements.dart'
+ show PartialMetadataAnnotation;
+import 'package:compiler/src/diagnostics/diagnostic_listener.dart'
+ show DiagnosticReporter;
+
+void checkPosition(Spannable spannable, Node node, String source,
+ DiagnosticReporter reporter) {
SourceSpan span = reporter.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}');
+ 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.
@@ -28,7 +25,7 @@ void checkPosition(Spannable spannable,
}
void checkAnnotation(String name, String declaration,
- {bool isTopLevelOnly: false}) {
+ {bool isTopLevelOnly: false}) {
// Ensure that a compile-time constant can be resolved from an
// annotation.
var source1 = """const native = 'xyz';
@@ -38,8 +35,8 @@ void checkAnnotation(String name, String declaration,
compileAndCheck(source1, name, (compiler, element) {
compiler.enqueuer.resolution.queueIsClosed = false;
- Expect.equals(1, element.metadata.length,
- 'Unexpected metadata count on $element.');
+ Expect.equals(
+ 1, element.metadata.length, 'Unexpected metadata count on $element.');
PartialMetadataAnnotation annotation = element.metadata.first;
annotation.ensureResolved(compiler.resolution);
PrimitiveConstantValue value =
@@ -64,8 +61,8 @@ void checkAnnotation(String name, String declaration,
PartialMetadataAnnotation annotation2 = element.metadata.elementAt(1);
annotation1.ensureResolved(compiler.resolution);
annotation2.ensureResolved(compiler.resolution);
- Expect.isFalse(identical(annotation1, annotation2),
- 'expected unique instances');
+ Expect.isFalse(
+ identical(annotation1, annotation2), 'expected unique instances');
Expect.notEquals(annotation1, annotation2, 'expected unequal instances');
PrimitiveConstantValue value1 =
compiler.constants.getConstantValue(annotation1.constant);
@@ -129,8 +126,8 @@ void checkAnnotation(String name, String declaration,
PartialMetadataAnnotation annotation2 = element.metadata.elementAt(1);
annotation1.ensureResolved(compiler.resolution);
annotation2.ensureResolved(compiler.resolution);
- Expect.isFalse(identical(annotation1, annotation2),
- 'expected unique instances');
+ Expect.isFalse(
+ identical(annotation1, annotation2), 'expected unique instances');
Expect.notEquals(annotation1, annotation2, 'expected unequal instances');
PrimitiveConstantValue value1 =
compiler.constants.getConstantValue(annotation1.constant);
@@ -161,8 +158,7 @@ void testTopLevelFieldMetadata() {
}
void testLibraryTags() {
- void compileAndCheckLibrary(
- String source,
+ void compileAndCheckLibrary(String source,
List<MetadataAnnotation> extractMetadata(LibraryElement element)) {
Uri partUri = new Uri(scheme: 'source', path: 'part.dart');
String partSource = '@native part of foo;';
@@ -173,26 +169,26 @@ void testLibraryTags() {
Uri uri = new Uri(scheme: 'source', path: 'main.dart');
var compiler = compilerFor(source, uri)
- ..registerSource(partUri, partSource)
- ..registerSource(libUri, libSource);
+ ..registerSource(partUri, partSource)
+ ..registerSource(libUri, libSource);
asyncTest(() => compiler.run(uri).then((_) {
- compiler.enqueuer.resolution.queueIsClosed = false;
- LibraryElement element = compiler.libraryLoader.lookupLibrary(uri);
- Expect.isNotNull(element, 'Cannot find $uri');
-
- List<MetadataAnnotation> metadata = extractMetadata(element);
- Expect.equals(1, metadata.length);
-
- PartialMetadataAnnotation annotation = metadata.first;
- annotation.ensureResolved(compiler.resolution);
- PrimitiveConstantValue value =
- compiler.constants.getConstantValue(annotation.constant);
- Expect.stringEquals('xyz', value.primitiveValue.slowToString());
-
- checkPosition(
- annotation, annotation.cachedNode, source, compiler.reporter);
- }));
+ compiler.enqueuer.resolution.queueIsClosed = false;
+ LibraryElement element = compiler.libraryLoader.lookupLibrary(uri);
+ Expect.isNotNull(element, 'Cannot find $uri');
+
+ List<MetadataAnnotation> metadata = extractMetadata(element);
+ Expect.equals(1, metadata.length);
+
+ PartialMetadataAnnotation annotation = metadata.first;
+ annotation.ensureResolved(compiler.resolution);
+ PrimitiveConstantValue value =
+ compiler.constants.getConstantValue(annotation.constant);
+ Expect.stringEquals('xyz', value.primitiveValue.slowToString());
+
+ checkPosition(
+ annotation, annotation.cachedNode, source, compiler.reporter);
+ }));
}
var source;
@@ -225,8 +221,8 @@ void testLibraryTags() {
part 'part.dart';
const native = 'xyz';
main() {}""";
- compileAndCheckLibrary(source,
- (e) => e.compilationUnits.first.partTag.metadata);
+ compileAndCheckLibrary(
+ source, (e) => e.compilationUnits.first.partTag.metadata);
}
void main() {
« no previous file with comments | « tests/compiler/dart2js/message_span_test.dart ('k') | tests/compiler/dart2js/minify_many_locals_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698