OLD | NEW |
| (Empty) |
1 /// This test-case automatically generates various tests from Dart source | |
2 /// code. Unfortunately the parser is currently unable to parse most of | |
3 /// these files. | |
4 library petitparser.test.dart_file_test; | |
5 | |
6 import 'dart:io'; | |
7 | |
8 import 'package:test/test.dart'; | |
9 | |
10 import 'package:petitparser/dart.dart'; | |
11 import 'package:petitparser/test.dart'; | |
12 | |
13 void generateTests(DartGrammar dart, String title, List<FileSystemEntity> files)
{ | |
14 group(title, () { | |
15 files | |
16 .where((file) => file is File && file.path.endsWith('.dart')) | |
17 .forEach((File file) { | |
18 test(file.path, () { | |
19 var source = new StringBuffer(); | |
20 file | |
21 .openRead() | |
22 .transform(SYSTEM_ENCODING.decoder) | |
23 .listen((part) => source.write(part), onDone: expectAsync(() { | |
24 expect(source.toString(), accept(dart)); | |
25 }), onError: fail); | |
26 }); | |
27 }); | |
28 }); | |
29 } | |
30 | |
31 void main() { | |
32 var dart = new DartGrammar(); | |
33 generateTests(dart, 'Dart SDK', new Directory('packages') | |
34 .listSync(recursive: true, followLinks: false)); | |
35 generateTests(dart, 'PetitParser', Directory.current | |
36 .listSync(recursive: true, followLinks: true)); | |
37 } | |
OLD | NEW |