| OLD | NEW |
| 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 'dart:convert' show | 7 import 'dart:convert' show |
| 8 JSON; | 8 JSON; |
| 9 | 9 |
| 10 import '../poi/source_update.dart'; | 10 import '../poi/source_update.dart'; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (!name.endsWith(".patch")) { | 105 if (!name.endsWith(".patch")) { |
| 106 fileMap[name] = new List<String>.filled(updateCount, files[name]); | 106 fileMap[name] = new List<String>.filled(updateCount, files[name]); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 if (updateCount != expectations.length) { | 109 if (updateCount != expectations.length) { |
| 110 throw new StateError( | 110 throw new StateError( |
| 111 "Number of patches and expectations differ " | 111 "Number of patches and expectations differ " |
| 112 "(${updateCount} patches, ${expectations.length} expectations)."); | 112 "(${updateCount} patches, ${expectations.length} expectations)."); |
| 113 } | 113 } |
| 114 List<ProgramResult> result = new List<ProgramResult>(updateCount); | 114 List<ProgramResult> result = new List<ProgramResult>(updateCount); |
| 115 int i = 0; | 115 for (int i = 0; i < updateCount; i++) { |
| 116 for (String name in fileMap.keys) { | |
| 117 ProgramExpectation expectation = decodeExpectation(expectations[i]); | 116 ProgramExpectation expectation = decodeExpectation(expectations[i]); |
| 118 result[i] = new ProgramResult( | 117 result[i] = new ProgramResult( |
| 119 <String, String>{}, | 118 <String, String>{}, |
| 120 expectation.messages, | 119 expectation.messages, |
| 121 compileUpdatesShouldThrow: expectation.compileUpdatesShouldThrow); | 120 compileUpdatesShouldThrow: expectation.compileUpdatesShouldThrow); |
| 122 i++; | |
| 123 } | 121 } |
| 124 for (String name in fileMap.keys) { | 122 for (String name in fileMap.keys) { |
| 125 for (int j = 0; j < updateCount; j++) { | 123 for (int i = 0; i < updateCount; i++) { |
| 126 result[j].code[name] = fileMap[name][j]; | 124 result[i].code[name] = fileMap[name][i]; |
| 127 } | 125 } |
| 128 } | 126 } |
| 129 return result; | 127 return result; |
| 130 } else { | 128 } else { |
| 131 throw new StateError("Unknown encoding of updates"); | 129 throw new StateError("Unknown encoding of updates"); |
| 132 } | 130 } |
| 133 } | 131 } |
| 134 } | 132 } |
| 135 | 133 |
| 136 ProgramExpectation decodeExpectation(expectation) { | 134 ProgramExpectation decodeExpectation(expectation) { |
| 137 if (expectation is ProgramExpectation) { | 135 if (expectation is ProgramExpectation) { |
| 138 return expectation; | 136 return expectation; |
| 139 } else if (expectation is String) { | 137 } else if (expectation is String) { |
| 140 return new ProgramExpectation(<String>[expectation]); | 138 return new ProgramExpectation(<String>[expectation]); |
| 141 } else if (expectation is List) { | 139 } else if (expectation is List) { |
| 142 return new ProgramExpectation(new List<String>.from(expectation)); | 140 return new ProgramExpectation(new List<String>.from(expectation)); |
| 143 } else { | 141 } else { |
| 144 throw new ArgumentError("Don't know how to decode $expectation"); | 142 throw new ArgumentError("Don't know how to decode $expectation"); |
| 145 } | 143 } |
| 146 } | 144 } |
| OLD | NEW |