OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da
rt'; | 6 import 'package:compiler/implementation/scanner/scannerlib.dart'; |
7 import '../../../sdk/lib/_internal/compiler/implementation/util/characters.dart'
; | 7 import 'package:compiler/implementation/util/characters.dart'; |
8 import 'dart:typed_data'; | 8 import 'dart:typed_data'; |
9 | 9 |
10 Token scan(List<int> bytes) => new Utf8BytesScanner.fromBytes(bytes).tokenize(); | 10 Token scan(List<int> bytes) => new Utf8BytesScanner.fromBytes(bytes).tokenize(); |
11 | 11 |
12 Token scanUTF8(List<int> bytes) { | 12 Token scanUTF8(List<int> bytes) { |
13 int l = bytes.length; | 13 int l = bytes.length; |
14 List<int> stringLiteral = new Uint8List(l + 3); | 14 List<int> stringLiteral = new Uint8List(l + 3); |
15 stringLiteral[0] = 0x27; // single quote | 15 stringLiteral[0] = 0x27; // single quote |
16 stringLiteral[l+1] = 0x27; // single quote | 16 stringLiteral[l+1] = 0x27; // single quote |
17 stringLiteral[l+2] = $EOF; | 17 stringLiteral[l+2] = $EOF; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // "#!" | 64 // "#!" |
65 token = scan([0x23, 0x21]); | 65 token = scan([0x23, 0x21]); |
66 Expect.equals(token.info, EOF_INFO); // Treated as a comment. | 66 Expect.equals(token.info, EOF_INFO); // Treated as a comment. |
67 | 67 |
68 // Regression test for issue 1761. | 68 // Regression test for issue 1761. |
69 // "#! Hello, World!" | 69 // "#! Hello, World!" |
70 token = scan([0x23, 0x21, 0x20, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, | 70 token = scan([0x23, 0x21, 0x20, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, |
71 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21]); | 71 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21]); |
72 Expect.equals(token.info, EOF_INFO); // Treated as a comment. | 72 Expect.equals(token.info, EOF_INFO); // Treated as a comment. |
73 } | 73 } |
OLD | NEW |