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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/tests/try/web/incremental_compilation_update_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library trydart.test.program_result; 5 library trydart.test.program_result;
6 6
7 import '../poi/source_update.dart';
8
7 class ProgramResult { 9 class ProgramResult {
8 final String code; 10 final String code;
9 11
10 final List<String> messages; 12 final List<String> messages;
11 13
12 final bool compileUpdatesShouldThrow; 14 final bool compileUpdatesShouldThrow;
13 15
14 const ProgramResult( 16 const ProgramResult(
15 this.code, this.messages, {this.compileUpdatesShouldThrow: false}); 17 this.code, this.messages, {this.compileUpdatesShouldThrow: false});
16 18
17 List<String> messagesWith(String extra) { 19 List<String> messagesWith(String extra) {
18 return new List<String>.from(messages)..add(extra); 20 return new List<String>.from(messages)..add(extra);
19 } 21 }
20 } 22 }
23
24 class ProgramExpectation {
25 final List<String> messages;
26
27 final bool compileUpdatesShouldThrow;
28
29 const ProgramExpectation(
30 this.messages, {this.compileUpdatesShouldThrow: false});
31
32 ProgramResult toResult(String code) {
33 return new ProgramResult(
34 code, messages, compileUpdatesShouldThrow: compileUpdatesShouldThrow);
35 }
36 }
37
38 class EncodedResult {
39 final List updates;
40
41 final List<ProgramExpectation> expectations;
42
43 const EncodedResult(this.updates, this.expectations);
44
45 List<ProgramResult> decode() {
46 if (updates.length == 1) {
47 throw new StateError("Trivial diff, no reason to use decode.");
48 }
49 List<String> sources = expandUpdates(updates);
50 if (sources.length != expectations.length) {
51 throw new StateError(
52 "Number of sources and expectations differ "
53 "(${sources.length} sources, ${expectations.length} expectations).");
54 }
55 List<ProgramResult> result = new List<ProgramResult>(sources.length);
56 for (int i = 0; i < sources.length; i++) {
57 result[i] = expectations[i].toResult(sources[i]);
58 }
59 return result;
60 }
61 }
OLDNEW
« 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