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

Side by Side Diff: sdk/lib/_internal/pub/test/version_solver_test.dart

Issue 17071010: Cleanup MatchState in pub. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 months 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 | « sdk/lib/_internal/pub/test/test_pub.dart ('k') | sdk/lib/_internal/pub/test/version_test.dart » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 pub_update_test; 5 library pub_update_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 SolveSuccessMatcher(this._expected, this._maxTries); 947 SolveSuccessMatcher(this._expected, this._maxTries);
948 948
949 Description describe(Description description) { 949 Description describe(Description description) {
950 return description.add( 950 return description.add(
951 'Solver to use at most $_maxTries attempts to find:\n' 951 'Solver to use at most $_maxTries attempts to find:\n'
952 '${_listPackages(_expected.values)}'); 952 '${_listPackages(_expected.values)}');
953 } 953 }
954 954
955 Description describeMismatch(SolveResult result, 955 Description describeMismatch(SolveResult result,
956 Description description, 956 Description description,
957 MatchState state, bool verbose) { 957 Map state, bool verbose) {
958 if (!result.succeeded) { 958 if (!result.succeeded) {
959 description.add('Solver failed with:\n${result.error}'); 959 description.add('Solver failed with:\n${result.error}');
960 return null; 960 return null;
961 } 961 }
962 962
963 description.add('Resolved:\n${_listPackages(result.packages)}\n'); 963 description.add('Resolved:\n${_listPackages(result.packages)}\n');
964 description.add(state.state); 964 description.add(state.state);
965 return description; 965 return description;
966 } 966 }
967 967
968 bool matches(SolveResult result, MatchState state) { 968 bool matches(SolveResult result, Map state) {
969 if (!result.succeeded) return false; 969 if (!result.succeeded) return false;
970 970
971 var expected = new Map.from(_expected); 971 var expected = new Map.from(_expected);
972 var failures = new StringBuffer(); 972 var failures = new StringBuffer();
973 973
974 for (var id in result.packages) { 974 for (var id in result.packages) {
975 if (!expected.containsKey(id.name)) { 975 if (!expected.containsKey(id.name)) {
976 failures.writeln('Should not have selected $id'); 976 failures.writeln('Should not have selected $id');
977 } else { 977 } else {
978 var expectedId = expected.remove(id.name); 978 var expectedId = expected.remove(id.name);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 description.add('Solver should fail after at most $_maxTries attempts.'); 1023 description.add('Solver should fail after at most $_maxTries attempts.');
1024 if (!_expected.isEmpty) { 1024 if (!_expected.isEmpty) {
1025 var textList = _expected.map((s) => '"$s"').join(", "); 1025 var textList = _expected.map((s) => '"$s"').join(", ");
1026 description.add(' The error should contain $textList.'); 1026 description.add(' The error should contain $textList.');
1027 } 1027 }
1028 return description; 1028 return description;
1029 } 1029 }
1030 1030
1031 Description describeMismatch(SolveResult result, 1031 Description describeMismatch(SolveResult result,
1032 Description description, 1032 Description description,
1033 MatchState state, bool verbose) { 1033 Map state, bool verbose) {
1034 description.add(state.state); 1034 description.add(state.state);
1035 return description; 1035 return description;
1036 } 1036 }
1037 1037
1038 bool matches(SolveResult result, MatchState state) { 1038 bool matches(SolveResult result, Map state) {
1039 var failures = new StringBuffer(); 1039 var failures = new StringBuffer();
1040 1040
1041 if (result.succeeded) { 1041 if (result.succeeded) {
1042 failures.writeln('Solver succeeded'); 1042 failures.writeln('Solver succeeded');
1043 } else { 1043 } else {
1044 if (_expectedType != null && result.error.runtimeType != _expectedType) { 1044 if (_expectedType != null && result.error.runtimeType != _expectedType) {
1045 failures.writeln('Should have error type $_expectedType, got ' 1045 failures.writeln('Should have error type $_expectedType, got '
1046 '${result.error.runtimeType}'); 1046 '${result.error.runtimeType}');
1047 } 1047 }
1048 1048
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 var source = "mock1"; 1191 var source = "mock1";
1192 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); 1192 var match = new RegExp(r"(.*) from (.*)").firstMatch(description);
1193 if (match != null) { 1193 if (match != null) {
1194 name = match[1]; 1194 name = match[1];
1195 source = match[2]; 1195 source = match[2];
1196 if (source == "root") source = null; 1196 if (source == "root") source = null;
1197 } 1197 }
1198 1198
1199 callback(isDev, name, source); 1199 callback(isDev, name, source);
1200 } 1200 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/test_pub.dart ('k') | sdk/lib/_internal/pub/test/version_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698