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

Unified Diff: dart/tests/try/web/program_result.dart

Issue 799403005: Avoid repeating common parts of ProgramResults. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: dart/tests/try/web/program_result.dart
diff --git a/dart/tests/try/web/program_result.dart b/dart/tests/try/web/program_result.dart
index faa56516cf353eb3433438c3be1321ba43fb085f..a085a7ffb6ee4f10b02caf2ded7439fd18ae6a9f 100644
--- a/dart/tests/try/web/program_result.dart
+++ b/dart/tests/try/web/program_result.dart
@@ -4,6 +4,8 @@
library trydart.test.program_result;
+import '../poi/source_update.dart';
+
class ProgramResult {
final String code;
@@ -17,4 +19,39 @@ class ProgramResult {
List<String> messagesWith(String extra) {
return new List<String>.from(messages)..add(extra);
}
+
+ static List<ProgramResult> decode(List encodedResults) {
+ if (encodedResults.length != 2) {
+ throw new ArgumentError(
+ "Unexpected encoding of program results: $encodedResults");
+ }
+ if (encodedResults[0].length == 1) {
+ throw new ArgumentError("Trivial diff, no reason to use decode.");
+ }
+ List<String> sources = expandUpdates(encodedResults[0]);
+ List<ProgramExpectation> expectations = encodedResults[1];
+ if (sources.length != expectations.length) {
+ throw new ArgumentError(
+ "Length mismatch: ${sources.length} != ${expectations.length}");
+ }
+ List<ProgramResult> result = new List<ProgramResult>(sources.length);
+ for (int i = 0; i < sources.length; i++) {
+ result[i] = expectations[i].toResult(sources[i]);
+ }
+ return result;
+ }
+}
+
+class ProgramExpectation {
+ final List<String> messages;
+
+ final bool compileUpdatesShouldThrow;
+
+ const ProgramExpectation(
+ this.messages, {this.compileUpdatesShouldThrow: false});
+
+ ProgramResult toResult(String code) {
+ return new ProgramResult(
+ code, messages, compileUpdatesShouldThrow: compileUpdatesShouldThrow);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698