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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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
« no previous file with comments | « tests/compiler/dart2js/resolver_test.dart ('k') | tests/compiler/dart2js/scanner_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:compiler/src/scanner/string_scanner.dart'; 6 import 'package:compiler/src/scanner/string_scanner.dart';
7 import 'package:compiler/src/tokens/token.dart'; 7 import 'package:compiler/src/tokens/token.dart';
8 import 'package:compiler/src/tokens/token_constants.dart'; 8 import 'package:compiler/src/tokens/token_constants.dart';
9 9
10 Token scan(String text) => 10 Token scan(String text) =>
11 new StringScanner.fromString(text, includeComments: true).tokenize(); 11 new StringScanner.fromString(text, includeComments: true).tokenize();
12 12
13 check(String text) { 13 check(String text) {
14 Token token = scan(text); 14 Token token = scan(text);
15 while (token.kind != EOF_TOKEN) { 15 while (token.kind != EOF_TOKEN) {
16 Expect.equals(token.value.length, token.charCount); 16 Expect.equals(token.value.length, token.charCount);
17 17
18 var start = token.charOffset; 18 var start = token.charOffset;
19 var end = token.charOffset + token.charCount; 19 var end = token.charOffset + token.charCount;
20 20
21 Expect.isTrue(start < text.length, 21 Expect.isTrue(start < text.length,
22 'start=$start < text.length=${text.length}: $text'); 22 'start=$start < text.length=${text.length}: $text');
23 23
24 Expect.isTrue(end <= text.length, 24 Expect.isTrue(
25 'end=$end <= text.length=${text.length}: $text'); 25 end <= text.length, 'end=$end <= text.length=${text.length}: $text');
26 26
27 Expect.isTrue(start <= end, 'start=$end <= end=$end: $text'); 27 Expect.isTrue(start <= end, 'start=$end <= end=$end: $text');
28 28
29 var substring = text.substring(start, end); 29 var substring = text.substring(start, end);
30 30
31 Expect.stringEquals(token.value, substring, 31 Expect.stringEquals(
32 token.value,
33 substring,
32 'token.value=${token.value} == ' 34 'token.value=${token.value} == '
33 'text.substring(start,end)=${substring}: $text'); 35 'text.substring(start,end)=${substring}: $text');
34 36
35 print('$text: [$start,$end]:$token'); 37 print('$text: [$start,$end]:$token');
36 38
37 token = token.next; 39 token = token.next;
38 } 40 }
39 } 41 }
40 42
41 main() { 43 main() {
42 check('foo'); // identifier 44 check('foo'); // identifier
43 check('\'\''); // empty string 45 check('\'\''); // empty string
44 check('\'foo\''); // simple string 46 check('\'foo\''); // simple string
45 check('\'\$foo\''); // interpolation, identifier 47 check('\'\$foo\''); // interpolation, identifier
46 check('\'\${foo}\''); // interpolation, expression 48 check('\'\${foo}\''); // interpolation, expression
47 49
48 check('//'); // single line comment 50 check('//'); // single line comment
49 check('/**/'); // multi line comment 51 check('/**/'); // multi line comment
50 } 52 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/resolver_test.dart ('k') | tests/compiler/dart2js/scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698