| 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 'package:compiler/src/scanner/string_scanner.dart'; | 6 import 'package:dart_scanner/dart_scanner.dart'; |
| 7 import 'package:compiler/src/tokens/token.dart'; | |
| 8 import 'package:compiler/src/tokens/token_constants.dart'; | |
| 9 | 7 |
| 10 Token scan(String text) => | 8 Token scan(String text) => |
| 11 new StringScanner.fromString(text, includeComments: true).tokenize(); | 9 new StringScanner(text, includeComments: true).tokenize(); |
| 12 | 10 |
| 13 check(String text) { | 11 check(String text) { |
| 14 Token token = scan(text); | 12 Token token = scan(text); |
| 15 while (token.kind != EOF_TOKEN) { | 13 while (token.kind != EOF_TOKEN) { |
| 16 Expect.equals(token.value.length, token.charCount); | 14 Expect.equals(token.value.length, token.charCount); |
| 17 | 15 |
| 18 var start = token.charOffset; | 16 var start = token.charOffset; |
| 19 var end = token.charOffset + token.charCount; | 17 var end = token.charOffset + token.charCount; |
| 20 | 18 |
| 21 Expect.isTrue(start < text.length, | 19 Expect.isTrue(start < text.length, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 43 main() { | 41 main() { |
| 44 check('foo'); // identifier | 42 check('foo'); // identifier |
| 45 check('\'\''); // empty string | 43 check('\'\''); // empty string |
| 46 check('\'foo\''); // simple string | 44 check('\'foo\''); // simple string |
| 47 check('\'\$foo\''); // interpolation, identifier | 45 check('\'\$foo\''); // interpolation, identifier |
| 48 check('\'\${foo}\''); // interpolation, expression | 46 check('\'\${foo}\''); // interpolation, expression |
| 49 | 47 |
| 50 check('//'); // single line comment | 48 check('//'); // single line comment |
| 51 check('/**/'); // multi line comment | 49 check('/**/'); // multi line comment |
| 52 } | 50 } |
| OLD | NEW |