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

Unified Diff: pkg/front_end/test/scanner_roundtrip_test.dart

Issue 2689733003: Add the ability to convert an analyzer token stream to a Fasta one. (Closed)
Patch Set: Created 3 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
Index: pkg/front_end/test/scanner_roundtrip_test.dart
diff --git a/pkg/front_end/test/scanner_roundtrip_test.dart b/pkg/front_end/test/scanner_roundtrip_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..27c3956674e28b184740c2ebe245d646c23372af
--- /dev/null
+++ b/pkg/front_end/test/scanner_roundtrip_test.dart
@@ -0,0 +1,101 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:front_end/src/fasta/analyzer/token_utils.dart';
+import 'package:front_end/src/fasta/scanner/error_token.dart' as fasta;
+import 'package:front_end/src/fasta/scanner/keyword.dart' as fasta;
+import 'package:front_end/src/fasta/scanner/string_scanner.dart' as fasta;
+import 'package:front_end/src/fasta/scanner/token.dart' as fasta;
+import 'package:front_end/src/fasta/scanner/token_constants.dart' as fasta;
+import 'package:front_end/src/scanner/errors.dart';
+import 'package:front_end/src/scanner/token.dart';
+import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'scanner_test.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(ScannerTest_RoundTrip);
+ });
+}
+
+/// Scanner tests that use the analyzer scanner, then convert the resulting
+/// token stream into a Fasta token stream, then convert back to an analyzer
+/// token stream before verifying assertions.
+///
+/// These tests help to validate the correctness of the analyzer->Fasta token
+/// stream conversion.
+@reflectiveTest
+class ScannerTest_RoundTrip extends ScannerTest {
+ @override
+ Token scanWithListener(String source, ErrorListener listener,
+ {bool genericMethodComments: false,
+ bool lazyAssignmentOperators: false}) {
+ var analyzerToken = super.scanWithListener(source, listener,
+ genericMethodComments: genericMethodComments,
+ lazyAssignmentOperators: lazyAssignmentOperators);
+ var fastaToken = fromAnalyzerTokenStream(analyzerToken);
+ return toAnalyzerTokenStream(fastaToken,
+ (ScannerErrorCode errorCode, int offset, List<Object> arguments) {
+ // Since [scanWithListener] reports errors to the listener, we don't
+ // expect any error tokens in the Fasta token stream; so this callback
+ // should never be called.
+ fail('Unexpected error reported: $errorCode, $offset, $arguments');
+ });
+ }
+
+ @override
+ @failingTest
+ void test_ampersand_ampersand_eq() {
+ // TODO(paulberry,ahe): Fasta scanner doesn't support lazy assignment
+ // operators.
+ super.test_ampersand_ampersand_eq();
+ }
+
+ @override
+ @failingTest
+ void test_bar_bar_eq() {
+ // TODO(paulberry,ahe): Fasta scanner doesn't support lazy assignment
+ // operators.
+ super.test_bar_bar_eq();
+ }
+
+ @override
+ @failingTest
+ void test_comment_generic_method_type_assign() {
+ // TODO(paulberry,ahe): Fasta scanner doesn't support generic comment
+ // syntax.
+ super.test_comment_generic_method_type_assign();
+ }
+
+ @override
+ @failingTest
+ void test_comment_generic_method_type_list() {
+ // TODO(paulberry,ahe): Fasta scanner doesn't support generic comment
+ // syntax.
+ super.test_comment_generic_method_type_list();
+ }
+
+ @override
+ @failingTest
+ void test_scriptTag_withArgs() {
+ // TODO(paulberry,ahe): Fasta scanner doesn't support script tag
+ super.test_scriptTag_withArgs();
+ }
+
+ @override
+ @failingTest
+ void test_scriptTag_withoutSpace() {
+ // TODO(paulberry,ahe): Fasta scanner doesn't support script tag
+ super.test_scriptTag_withoutSpace();
+ }
+
+ @override
+ @failingTest
+ void test_scriptTag_withSpace() {
+ // TODO(paulberry,ahe): Fasta scanner doesn't support script tag
+ super.test_scriptTag_withSpace();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698