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

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: Merged with r42384. 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
« no previous file with comments | « dart/tests/try/web/incremental_compilation_update_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2bd31007259a17035a467f5214fd7190fcc6712d 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;
@@ -18,3 +20,42 @@ class ProgramResult {
return new List<String>.from(messages)..add(extra);
}
}
+
+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);
+ }
+}
+
+class EncodedResult {
+ final List updates;
+
+ final List<ProgramExpectation> expectations;
+
+ const EncodedResult(this.updates, this.expectations);
+
+ List<ProgramResult> decode() {
+ if (updates.length == 1) {
+ throw new StateError("Trivial diff, no reason to use decode.");
+ }
+ List<String> sources = expandUpdates(updates);
+ if (sources.length != expectations.length) {
+ throw new StateError(
+ "Number of sources and expectations differ "
+ "(${sources.length} sources, ${expectations.length} expectations).");
+ }
+ 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;
+ }
+}
« no previous file with comments | « dart/tests/try/web/incremental_compilation_update_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698