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

Unified Diff: pkg/analyzer2dart/test/test_helper.dart

Issue 669673006: Add SExpression test and share tests between dart2dart and analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer2dart/test/sexpr_test.dart ('k') | tests/compiler/dart2js/backend_dart/end2end_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer2dart/test/test_helper.dart
diff --git a/pkg/analyzer2dart/test/test_helper.dart b/pkg/analyzer2dart/test/test_helper.dart
new file mode 100644
index 0000000000000000000000000000000000000000..75565775f1d68f7d1b5cc551a9b07d4b766477ba
--- /dev/null
+++ b/pkg/analyzer2dart/test/test_helper.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Helpers for defining input/output based unittests through (constant) data.
+
+import 'package:unittest/unittest.dart';
+
+/// A unittest group with a name and a list of input/output results.
+class Group {
+ final String name;
+ final List<Result> results;
+
+ const Group(this.name, this.results);
+}
+
+/// A input/output pair that defines the expected [output] of when processing
+/// the [input].
+class Result {
Paul Berry 2014/10/22 13:03:50 The name "Result" is confusing because it's not th
Johnni Winther 2014/10/23 06:44:02 Done.
+ final String input;
+ final String output;
+
+ const Result(this.input, this.output);
+}
+
+typedef TestGroup(Group group, CheckResult check);
+typedef CheckResult(Result result);
Paul Berry 2014/10/22 13:03:50 Similarly, "CheckResult" sounds like a function wh
Johnni Winther 2014/10/23 06:44:02 Done.
+
+/// Test [data] using [testGroup] and [check].
+void performTests(List<Group> data, TestGroup testGroup, CheckResult check) {
+ for (Group group in data) {
+ testGroup(group, check);
+ }
+}
+
+/// Test group using unittest.
+unittester(Group group, CheckResult check) {
+ test(group.name, () {
+ for (Result result in group.results) {
+ check(result);
+ }
+ });
+}
« no previous file with comments | « pkg/analyzer2dart/test/sexpr_test.dart ('k') | tests/compiler/dart2js/backend_dart/end2end_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698