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

Side by Side Diff: pkg/analyzer/test/generated/scanner_test.dart

Issue 1271553002: Issue 23919. Fix for line starts in multiline comments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 | « pkg/analyzer/lib/src/generated/scanner.dart ('k') | no next file » | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library engine.scanner_test; 5 library engine.scanner_test;
6 6
7 import 'package:analyzer/src/generated/error.dart'; 7 import 'package:analyzer/src/generated/error.dart';
8 import 'package:analyzer/src/generated/scanner.dart'; 8 import 'package:analyzer/src/generated/scanner.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 scanner.preserveComments = false; 259 scanner.preserveComments = false;
260 Token token = scanner.tokenize(); 260 Token token = scanner.tokenize();
261 expect(token, isNotNull); 261 expect(token, isNotNull);
262 expect(token.precedingComments, isNull); 262 expect(token.precedingComments, isNull);
263 } 263 }
264 264
265 void test_comment_multi() { 265 void test_comment_multi() {
266 _assertComment(TokenType.MULTI_LINE_COMMENT, "/* comment */"); 266 _assertComment(TokenType.MULTI_LINE_COMMENT, "/* comment */");
267 } 267 }
268 268
269 void test_comment_multi_lineEnds() {
270 String code = r'''
271 /**
272 * aa
273 * bbb
274 * c
275 */''';
276 GatheringErrorListener listener = new GatheringErrorListener();
277 Scanner scanner = new Scanner(null, new CharSequenceReader(code), listener);
278 scanner.tokenize();
279 expect(scanner.lineStarts, equals(<int>[
280 code.indexOf('/**'),
281 code.indexOf(' * aa'),
282 code.indexOf(' * bbb'),
283 code.indexOf(' * c'),
284 code.indexOf(' */')
285 ]));
286 }
287
269 void test_comment_multi_unterminated() { 288 void test_comment_multi_unterminated() {
270 _assertError(ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT, 3, "/* x"); 289 _assertError(ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT, 3, "/* x");
271 } 290 }
272 291
273 void test_comment_nested() { 292 void test_comment_nested() {
274 _assertComment( 293 _assertComment(
275 TokenType.MULTI_LINE_COMMENT, "/* comment /* within a */ comment */"); 294 TokenType.MULTI_LINE_COMMENT, "/* comment /* within a */ comment */");
276 } 295 }
277 296
278 void test_comment_single() { 297 void test_comment_single() {
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 expect(TokenType.LT_LT.isUserDefinableOperator, isTrue); 1386 expect(TokenType.LT_LT.isUserDefinableOperator, isTrue);
1368 expect(TokenType.MINUS.isUserDefinableOperator, isTrue); 1387 expect(TokenType.MINUS.isUserDefinableOperator, isTrue);
1369 expect(TokenType.PERCENT.isUserDefinableOperator, isTrue); 1388 expect(TokenType.PERCENT.isUserDefinableOperator, isTrue);
1370 expect(TokenType.PLUS.isUserDefinableOperator, isTrue); 1389 expect(TokenType.PLUS.isUserDefinableOperator, isTrue);
1371 expect(TokenType.SLASH.isUserDefinableOperator, isTrue); 1390 expect(TokenType.SLASH.isUserDefinableOperator, isTrue);
1372 expect(TokenType.STAR.isUserDefinableOperator, isTrue); 1391 expect(TokenType.STAR.isUserDefinableOperator, isTrue);
1373 expect(TokenType.TILDE.isUserDefinableOperator, isTrue); 1392 expect(TokenType.TILDE.isUserDefinableOperator, isTrue);
1374 expect(TokenType.TILDE_SLASH.isUserDefinableOperator, isTrue); 1393 expect(TokenType.TILDE_SLASH.isUserDefinableOperator, isTrue);
1375 } 1394 }
1376 } 1395 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/scanner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698