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

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

Issue 2952153003: add test for internal scanner API (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/test/scanner_fasta_test.dart
diff --git a/pkg/front_end/test/scanner_fasta_test.dart b/pkg/front_end/test/scanner_fasta_test.dart
index 12e12e87a6564e30710c8988ad6d9b778fe72da2..dcf80823bdc1325fa574ffec53e54e81141200fb 100644
--- a/pkg/front_end/test/scanner_fasta_test.dart
+++ b/pkg/front_end/test/scanner_fasta_test.dart
@@ -5,6 +5,7 @@ import 'dart:convert';
import 'package:analyzer/src/fasta/token_utils.dart';
import 'package:front_end/src/fasta/fasta_codes.dart';
+import 'package:front_end/src/fasta/scanner.dart' as usedForFuzzTesting;
import 'package:front_end/src/fasta/scanner/error_token.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;
@@ -20,6 +21,7 @@ import 'scanner_test.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(ScannerTest_Fasta);
+ defineReflectiveTests(ScannerTest_Fasta_FuzzTestAPI);
defineReflectiveTests(ScannerTest_Fasta_UTF8);
defineReflectiveTests(ScannerTest_Fasta_Direct);
defineReflectiveTests(ScannerTest_Fasta_Direct_UTF8);
@@ -27,6 +29,27 @@ main() {
}
@reflectiveTest
+class ScannerTest_Fasta_FuzzTestAPI {
+ test_API() {
+ // These two API are used when fuzz testing the scanner.
+ String source = 'class A { }';
+
+ usedForFuzzTesting.ScannerResult result =
+ usedForFuzzTesting.scanString(source);
+ expect(result?.hasErrors, isFalse);
+ expect(result.tokens?.type, same(Keyword.CLASS));
+
+ // UTF8 encode source with trailing zero
+ List<int> bytes = UTF8.encode(source).toList();
+ bytes.add(0);
+
+ result = usedForFuzzTesting.scan(bytes);
+ expect(result?.hasErrors, isFalse);
+ expect(result.tokens?.type, same(Keyword.CLASS));
+ }
+}
+
+@reflectiveTest
class ScannerTest_Fasta_UTF8 extends ScannerTest_Fasta {
@override
createScanner(String source, {bool genericMethodComments: false}) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698