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; |
+ } |
+} |