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

Side by Side Diff: pkg/analyzer2dart/test/test_helper.dart

Issue 900403003: Support default constructors in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
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 /// Helpers for defining input/output based unittests through (constant) data. 5 /// Helpers for defining input/output based unittests through (constant) data.
6 6
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 8
9 /// A unittest group with a name and a list of input/output results. 9 /// A unittest group with a name and a list of input/output results.
10 class Group { 10 class Group {
11 final String name; 11 final String name;
12 final List<TestSpecBase> results; 12 final List<TestSpecBase> results;
13 13
14 const Group(this.name, this.results); 14 const Group(this.name, this.results);
15 } 15 }
16 16
17 /// A [input] for which a certain processing result is expected. 17 /// A [input] for which a certain processing result is expected.
18 class TestSpecBase { 18 class TestSpecBase {
19 final String input; 19 final String input;
20 20
21 const TestSpecBase(this.input); 21 const TestSpecBase(this.input);
22 } 22 }
23 23
24 typedef TestGroup(Group group, RunTest check); 24 typedef TestGroup(Group group, RunTest check);
25 typedef RunTest(TestSpecBase result); 25 typedef RunTest(TestSpecBase result);
26 26
27 /// Test [data] using [testGroup] and [check]. 27 /// Test [data] using [testGroup] and [check].
28 void performTests(List<Group> data, TestGroup testGroup, RunTest runTest) { 28 void performTests(List<Group> data,
29 TestGroup testGroup,
30 RunTest runTest,
31 List<String> groupsToRun) {
29 for (Group group in data) { 32 for (Group group in data) {
33 if (groupsToRun.isNotEmpty &&
34 !groupsToRun.contains(group.name)) {
35 // Skip this group.
36 continue;
37 }
30 testGroup(group, runTest); 38 testGroup(group, runTest);
31 } 39 }
32 } 40 }
33 41
34 /// Test group using unittest. 42 /// Test group using unittest.
35 unittester(Group group, RunTest runTest) { 43 unittester(Group group, RunTest runTest) {
36 test(group.name, () { 44 test(group.name, () {
37 for (TestSpecBase result in group.results) { 45 for (TestSpecBase result in group.results) {
38 runTest(result); 46 runTest(result);
39 } 47 }
40 }); 48 });
41 } 49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698