1fb12c24a7
R=johnniwinther@google.com Review URL: https://codereview.chromium.org//799403005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42387 260f80e4-7a28-3924-810f-c04153c831b5
62 lines
1.7 KiB
Dart
62 lines
1.7 KiB
Dart
// 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.
|
|
|
|
library trydart.test.program_result;
|
|
|
|
import '../poi/source_update.dart';
|
|
|
|
class ProgramResult {
|
|
final String code;
|
|
|
|
final List<String> messages;
|
|
|
|
final bool compileUpdatesShouldThrow;
|
|
|
|
const ProgramResult(
|
|
this.code, this.messages, {this.compileUpdatesShouldThrow: false});
|
|
|
|
List<String> messagesWith(String extra) {
|
|
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;
|
|
}
|
|
}
|