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

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

Issue 992333003: dart2js: Handle zero-terminated content explicitly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment and close server in finally. Created 5 years, 9 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: tests/compiler/dart2js/scanner_test.dart
diff --git a/tests/compiler/dart2js/scanner_test.dart b/tests/compiler/dart2js/scanner_test.dart
index f9f42fa7d7abb0a003a5974d276f71ee3e605a39..e3a82fbc13036a09c6c03a3a6e3e5df1605c69f2 100644
--- a/tests/compiler/dart2js/scanner_test.dart
+++ b/tests/compiler/dart2js/scanner_test.dart
@@ -7,13 +7,19 @@ import 'package:compiler/src/scanner/scannerlib.dart';
import 'package:compiler/src/util/characters.dart';
import 'dart:typed_data';
-Token scan(List<int> bytes) => new Utf8BytesScanner.fromBytes(bytes).tokenize();
+Token scan(List<int> bytes) {
+ List<int> zeroTerminated = new Uint8List(bytes.length + 1);
+ zeroTerminated.setRange(0, bytes.length, bytes);
+ zeroTerminated[bytes.length] = 0;
+ return new Utf8BytesScanner.fromBytes(zeroTerminated).tokenize();
+}
Token scanUTF8(List<int> bytes) {
int l = bytes.length;
List<int> stringLiteral = new Uint8List(l + 3);
stringLiteral[0] = 0x27; // single quote
stringLiteral[l+1] = 0x27; // single quote
+ // The bytes given to the scanner must be 0-terminated.
stringLiteral[l+2] = $EOF;
for (int i = 0; i < l; i++) {
stringLiteral[i+1] = bytes[i];
« no previous file with comments | « tests/compiler/dart2js/one_line_dart_program.dart ('k') | tests/compiler/dart2js/zero_termination_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698