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

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

Issue 762213002: Support top-level field declaration and assignment in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comments Created 6 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
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<TestSpec> 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/output pair that defines the expected [output] of when processing 17 /// A [input] for which a certain processing result is expected.
18 /// the [input]. 18 class TestSpecBase {
19 class TestSpec {
20 final String input; 19 final String input;
21 final String output;
22 20
23 const TestSpec(this.input, this.output); 21 const TestSpecBase(this.input);
24 } 22 }
25 23
26 typedef TestGroup(Group group, RunTest check); 24 typedef TestGroup(Group group, RunTest check);
27 typedef RunTest(TestSpec result); 25 typedef RunTest(TestSpecBase result);
28 26
29 /// Test [data] using [testGroup] and [check]. 27 /// Test [data] using [testGroup] and [check].
30 void performTests(List<Group> data, TestGroup testGroup, RunTest runTest) { 28 void performTests(List<Group> data, TestGroup testGroup, RunTest runTest) {
31 for (Group group in data) { 29 for (Group group in data) {
32 testGroup(group, runTest); 30 testGroup(group, runTest);
33 } 31 }
34 } 32 }
35 33
36 /// Test group using unittest. 34 /// Test group using unittest.
37 unittester(Group group, RunTest runTest) { 35 unittester(Group group, RunTest runTest) {
38 test(group.name, () { 36 test(group.name, () {
39 for (TestSpec result in group.results) { 37 for (TestSpecBase result in group.results) {
40 runTest(result); 38 runTest(result);
41 } 39 }
42 }); 40 });
43 } 41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698