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

Side by Side Diff: tests/compiler/dart2js/scanner_offset_length_test.dart

Issue 2738313002: rename fasta.Token.value --> lexeme (Closed)
Patch Set: merge Created 3 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 unified diff | Download patch
OLDNEW
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:front_end/src/fasta/scanner.dart'; 6 import 'package:front_end/src/fasta/scanner.dart';
7 7
8 Token scan(String text) => 8 Token scan(String text) =>
9 new StringScanner(text, includeComments: true).tokenize(); 9 new StringScanner(text, includeComments: true).tokenize();
10 10
11 check(String text) { 11 check(String text) {
12 Token token = scan(text); 12 Token token = scan(text);
13 while (token.kind != EOF_TOKEN) { 13 while (token.kind != EOF_TOKEN) {
14 Expect.equals(token.value.length, token.charCount); 14 Expect.equals(token.lexeme.length, token.charCount);
15 15
16 var start = token.charOffset; 16 var start = token.charOffset;
17 var end = token.charOffset + token.charCount; 17 var end = token.charOffset + token.charCount;
18 18
19 Expect.isTrue(start < text.length, 19 Expect.isTrue(start < text.length,
20 'start=$start < text.length=${text.length}: $text'); 20 'start=$start < text.length=${text.length}: $text');
21 21
22 Expect.isTrue( 22 Expect.isTrue(
23 end <= text.length, 'end=$end <= text.length=${text.length}: $text'); 23 end <= text.length, 'end=$end <= text.length=${text.length}: $text');
24 24
25 Expect.isTrue(start <= end, 'start=$end <= end=$end: $text'); 25 Expect.isTrue(start <= end, 'start=$end <= end=$end: $text');
26 26
27 var substring = text.substring(start, end); 27 var substring = text.substring(start, end);
28 28
29 Expect.stringEquals( 29 Expect.stringEquals(
30 token.value, 30 token.lexeme,
31 substring, 31 substring,
32 'token.value=${token.value} == ' 32 'token.value=${token.lexeme} == '
33 'text.substring(start,end)=${substring}: $text'); 33 'text.substring(start,end)=${substring}: $text');
34 34
35 print('$text: [$start,$end]:$token'); 35 print('$text: [$start,$end]:$token');
36 36
37 token = token.next; 37 token = token.next;
38 } 38 }
39 } 39 }
40 40
41 main() { 41 main() {
42 check('foo'); // identifier 42 check('foo'); // identifier
43 check('\'\''); // empty string 43 check('\'\''); // empty string
44 check('\'foo\''); // simple string 44 check('\'foo\''); // simple string
45 check('\'\$foo\''); // interpolation, identifier 45 check('\'\$foo\''); // interpolation, identifier
46 check('\'\${foo}\''); // interpolation, expression 46 check('\'\${foo}\''); // interpolation, expression
47 47
48 check('//'); // single line comment 48 check('//'); // single line comment
49 check('/**/'); // multi line comment 49 check('/**/'); // multi line comment
50 } 50 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/partial_parser_test.dart ('k') | tests/compiler/dart2js/scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698