| OLD | NEW |
| 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 // TODO(jmesserly): this was factored out of | 5 // TODO(jmesserly): this was factored out of |
| 6 // dart-lang/sdk/tools/testing/dart/multitest.dart | 6 // dart-lang/sdk/tools/testing/dart/multitest.dart |
| 7 library dev_compiler.test.tools.multitest; | 7 library dev_compiler.test.tools.multitest; |
| 8 | 8 |
| 9 final validMultitestOutcomes = new Set<String>.from([ | 9 final validMultitestOutcomes = new Set<String>.from([ |
| 10 'ok', | 10 'ok', |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // aaa | 71 // aaa |
| 72 // eee //# 10: ok | 72 // eee //# 10: ok |
| 73 // fff | 73 // fff |
| 74 // | 74 // |
| 75 // Note that it is possible to indicate more than one acceptable outcome | 75 // Note that it is possible to indicate more than one acceptable outcome |
| 76 // in the case of dynamic and static type warnings | 76 // in the case of dynamic and static type warnings |
| 77 // aaa | 77 // aaa |
| 78 // ddd //# 07: static type warning, dynamic type error | 78 // ddd //# 07: static type warning, dynamic type error |
| 79 // fff | 79 // fff |
| 80 | 80 |
| 81 void extractTestsFromMultitest(String filePath, String contents, | 81 void extractTestsFromMultitest( |
| 82 Map<String, String> tests, Map<String, Set<String>> outcomes) { | 82 String filePath, String contents, Map<String, String> tests) { |
| 83 int first_newline = contents.indexOf('\n'); | 83 int first_newline = contents.indexOf('\n'); |
| 84 final String line_separator = | 84 final String line_separator = |
| 85 (first_newline == 0 || contents[first_newline - 1] != '\r') | 85 (first_newline == 0 || contents[first_newline - 1] != '\r') |
| 86 ? '\n' | 86 ? '\n' |
| 87 : '\r\n'; | 87 : '\r\n'; |
| 88 List<String> lines = contents.split(line_separator); | 88 List<String> lines = contents.split(line_separator); |
| 89 if (lines.last == '') lines.removeLast(); | 89 if (lines.last == '') lines.removeLast(); |
| 90 contents = null; | 90 contents = null; |
| 91 | 91 |
| 92 // Create the set of multitests, which will have a new test added each | 92 // Create the set of multitests, which will have a new test added each |
| 93 // time we see a multitest line with a new key. | 93 // time we see a multitest line with a new key. |
| 94 Map<String, List<String>> testsAsLines = new Map<String, List<String>>(); | 94 var testsAsLines = new Map<String, List<String>>(); |
| 95 var outcomes = new Map<String, Set<String>>(); |
| 95 | 96 |
| 96 // Add the default case with key "none". | 97 // Add the default case with key "none". |
| 97 testsAsLines['none'] = new List<String>(); | 98 testsAsLines['none'] = new List<String>(); |
| 98 outcomes['none'] = new Set<String>(); | 99 outcomes['none'] = new Set<String>(); |
| 99 | 100 |
| 100 int lineCount = 0; | 101 int lineCount = 0; |
| 101 for (String line in lines) { | 102 for (String line in lines) { |
| 102 lineCount++; | 103 lineCount++; |
| 103 var annotation = new _Annotation.from(line); | 104 var annotation = new _Annotation.from(line); |
| 104 if (annotation != null) { | 105 if (annotation != null) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 179 } |
| 179 | 180 |
| 180 var annotation = new _Annotation(); | 181 var annotation = new _Annotation(); |
| 181 annotation.key = parts[0]; | 182 annotation.key = parts[0]; |
| 182 annotation.rest = parts[1]; | 183 annotation.rest = parts[1]; |
| 183 annotation.outcomesList = | 184 annotation.outcomesList = |
| 184 annotation.rest.split(',').map((s) => s.trim()).toList(); | 185 annotation.rest.split(',').map((s) => s.trim()).toList(); |
| 185 return annotation; | 186 return annotation; |
| 186 } | 187 } |
| 187 } | 188 } |
| OLD | NEW |