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

Side by Side Diff: pkg/analyzer/test/services/formatter_test.dart

Issue 119583002: Path fix for data-driving formatting tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 'dart:io'; 5 import 'dart:io';
6 6
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 8
9 import 'package:analyzer/src/generated/java_core.dart' show CharSequence; 9 import 'package:analyzer/src/generated/java_core.dart' show CharSequence;
10 import 'package:analyzer/src/generated/scanner.dart'; 10 import 'package:analyzer/src/generated/scanner.dart';
11 import 'package:analyzer/src/services/formatter_impl.dart'; 11 import 'package:analyzer/src/services/formatter_impl.dart';
12 import 'package:analyzer/src/services/writer.dart'; 12 import 'package:analyzer/src/services/writer.dart';
13 13
14 // Test data location
15 const TEST_DATA_DIR = 'pkg/analyzer/test/services/data';
kustermann 2014/01/02 10:22:00 You should not use forward slashes, windows uses b
pquitslund 2014/01/02 18:39:11 Ah, yes. I mistakenly thought that the new File c
16
14 main() { 17 main() {
15 18
16 //TODO(pquitslund): disabled pending build investigation 19 /// Data driven statement tests
20 group('stmt_tests.data', () {
21 runTests('stmt_tests.data', (input, expectedOutput) {
22 expect(formatStatement(input) + '\n', equals(expectedOutput));
23 });
24 });
17 25
18 // /// Data driven statement tests 26 /// Data driven compilation unit tests
19 // group('stmt_tests.data', () { 27 group('cu_tests.data', () {
20 // runTests(new File('data/stmt_tests.data'), (input, expectedOutput) { 28 runTests('cu_tests.data', (input, expectedOutput) {
21 // expect(formatStatement(input) + '\n', equals(expectedOutput)); 29 expectCUFormatsTo(input, expectedOutput);
22 // }); 30 });
23 // }); 31 });
24 //
25 // /// Data driven compilation unit tests
26 // group('cu_tests.data', () {
27 // runTests(new File('data/cu_tests.data'), (input, expectedOutput) {
28 // expectCUFormatsTo(input, expectedOutput);
29 // });
30 // });
31 32
32 /// Formatter tests 33 /// Formatter tests
33 group('formatter', () { 34 group('formatter', () {
34 35
35 test('failed parse', () { 36 test('failed parse', () {
36 var formatter = new CodeFormatter(); 37 var formatter = new CodeFormatter();
37 expect(() => formatter.format(CodeKind.COMPILATION_UNIT, '~'), 38 expect(() => formatter.format(CodeKind.COMPILATION_UNIT, '~'),
38 throwsA(new isInstanceOf<FormatterException>())); 39 throwsA(new isInstanceOf<FormatterException>()));
39 }); 40 });
40 41
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 throwsA(new isInstanceOf<FormatterException>())); 1302 throwsA(new isInstanceOf<FormatterException>()));
1302 1303
1303 expectCUFormatsTo(src, expected, {transforms: true}) => 1304 expectCUFormatsTo(src, expected, {transforms: true}) =>
1304 expect(formatCU(src, options: new FormatterOptions( 1305 expect(formatCU(src, options: new FormatterOptions(
1305 codeTransforms: transforms)).source, equals(expected)); 1306 codeTransforms: transforms)).source, equals(expected));
1306 1307
1307 expectStmtFormatsTo(src, expected, {transforms: true}) => 1308 expectStmtFormatsTo(src, expected, {transforms: true}) =>
1308 expect(formatStatement(src, options: 1309 expect(formatStatement(src, options:
1309 new FormatterOptions(codeTransforms: transforms)), equals(expected)); 1310 new FormatterOptions(codeTransforms: transforms)), equals(expected));
1310 1311
1311 runTests(testFile, expectClause(input, output)) { 1312
1313 runTests(testFileName, expectClause(input, output)) {
1312 1314
1313 var testIndex = 1; 1315 var testIndex = 1;
1316 var testFile = new File('$TEST_DATA_DIR/$testFileName');
kustermann 2014/01/02 10:22:00 Since you import 'dart:io' anyway, you could use d
pquitslund 2014/01/02 18:39:11 Perfect. Great idea!
1314 var lines = testFile.readAsLinesSync(); 1317 var lines = testFile.readAsLinesSync();
1315 1318
1316 for (var i = 1; i < lines.length; ++i) { 1319 for (var i = 1; i < lines.length; ++i) {
1317 var input = '', expectedOutput = ''; 1320 var input = '', expectedOutput = '';
1318 while(lines[i] != '<<<') { 1321 while(lines[i] != '<<<') {
1319 input += lines[i++] + '\n'; 1322 input += lines[i++] + '\n';
1320 } 1323 }
1321 while(++i < lines.length && lines[i] != '>>>') { 1324 while(++i < lines.length && lines[i] != '>>>') {
1322 expectedOutput += lines[i] + '\n'; 1325 expectedOutput += lines[i] + '\n';
1323 } 1326 }
1324 test('test - (${testIndex++})', () { 1327 test('test - (${testIndex++})', () {
1325 expectClause(input, expectedOutput); 1328 expectClause(input, expectedOutput);
1326 }); 1329 });
1327 } 1330 }
1328 } 1331 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698