| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.test_support; | 8 library engine.test_support; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 * @param getterName the name of the getter to be returned | 72 * @param getterName the name of the getter to be returned |
| 73 * @return the property accessor element representing the getter with the give
n name | 73 * @return the property accessor element representing the getter with the give
n name |
| 74 */ | 74 */ |
| 75 PropertyAccessorElement getGetter(InterfaceType type, String getterName) { | 75 PropertyAccessorElement getGetter(InterfaceType type, String getterName) { |
| 76 for (PropertyAccessorElement accessor in type.element.accessors) { | 76 for (PropertyAccessorElement accessor in type.element.accessors) { |
| 77 if (accessor.isGetter && accessor.name == getterName) { | 77 if (accessor.isGetter && accessor.name == getterName) { |
| 78 return accessor; | 78 return accessor; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 JUnitTestCase.fail( | 81 JUnitTestCase.fail( |
| 82 "Could not find getter named ${getterName} in ${type.displayName}"); | 82 "Could not find getter named $getterName in ${type.displayName}"); |
| 83 return null; | 83 return null; |
| 84 } | 84 } |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * Return the method in the given type with the given name. Inherited methods
are ignored. | 87 * Return the method in the given type with the given name. Inherited methods
are ignored. |
| 88 * | 88 * |
| 89 * @param type the type in which the method is declared | 89 * @param type the type in which the method is declared |
| 90 * @param methodName the name of the method to be returned | 90 * @param methodName the name of the method to be returned |
| 91 * @return the method element representing the method with the given name | 91 * @return the method element representing the method with the given name |
| 92 */ | 92 */ |
| 93 MethodElement getMethod(InterfaceType type, String methodName) { | 93 MethodElement getMethod(InterfaceType type, String methodName) { |
| 94 for (MethodElement method in type.element.methods) { | 94 for (MethodElement method in type.element.methods) { |
| 95 if (method.name == methodName) { | 95 if (method.name == methodName) { |
| 96 return method; | 96 return method; |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 JUnitTestCase.fail( | 99 JUnitTestCase.fail( |
| 100 "Could not find method named ${methodName} in ${type.displayName}"); | 100 "Could not find method named $methodName in ${type.displayName}"); |
| 101 return null; | 101 return null; |
| 102 } | 102 } |
| 103 | 103 |
| 104 /** | 104 /** |
| 105 * Assert that the tokens in the actual stream of tokens have the same types a
nd lexemes as the | 105 * Assert that the tokens in the actual stream of tokens have the same types a
nd lexemes as the |
| 106 * tokens in the expected stream of tokens. Note that this does not assert any
thing about the | 106 * tokens in the expected stream of tokens. Note that this does not assert any
thing about the |
| 107 * offsets of the tokens (although the lengths will be equal). | 107 * offsets of the tokens (although the lengths will be equal). |
| 108 * | 108 * |
| 109 * @param expectedStream the head of the stream of tokens that were expected | 109 * @param expectedStream the head of the stream of tokens that were expected |
| 110 * @param actualStream the head of the stream of tokens that were actually fou
nd | 110 * @param actualStream the head of the stream of tokens that were actually fou
nd |
| (...skipping 13 matching lines...) Expand all Loading... |
| 124 * Assert that the given collection is non-`null` and has the expected number
of elements. | 124 * Assert that the given collection is non-`null` and has the expected number
of elements. |
| 125 * | 125 * |
| 126 * @param expectedSize the expected number of elements | 126 * @param expectedSize the expected number of elements |
| 127 * @param c the collection being tested | 127 * @param c the collection being tested |
| 128 * @throws AssertionFailedError if the list is `null` or does not have the exp
ected number | 128 * @throws AssertionFailedError if the list is `null` or does not have the exp
ected number |
| 129 * of elements | 129 * of elements |
| 130 */ | 130 */ |
| 131 static void assertCollectionSize(int expectedSize, Iterable c) { | 131 static void assertCollectionSize(int expectedSize, Iterable c) { |
| 132 if (c == null) { | 132 if (c == null) { |
| 133 JUnitTestCase.fail( | 133 JUnitTestCase.fail( |
| 134 "Expected collection of size ${expectedSize}; found null"); | 134 "Expected collection of size $expectedSize; found null"); |
| 135 } else if (c.length != expectedSize) { | 135 } else if (c.length != expectedSize) { |
| 136 JUnitTestCase.fail( | 136 JUnitTestCase.fail( |
| 137 "Expected collection of size ${expectedSize}; contained ${c.length} el
ements"); | 137 "Expected collection of size $expectedSize; contained ${c.length} elem
ents"); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * Assert that the given array is non-`null` and contains the expected element
s. The | 142 * Assert that the given array is non-`null` and contains the expected element
s. The |
| 143 * elements can appear in any order. | 143 * elements can appear in any order. |
| 144 * | 144 * |
| 145 * @param array the array being tested | 145 * @param array the array being tested |
| 146 * @param expectedElements the expected elements | 146 * @param expectedElements the expected elements |
| 147 * @throws AssertionFailedError if the array is `null` or does not contain the
expected | 147 * @throws AssertionFailedError if the array is `null` or does not contain the
expected |
| 148 * elements | 148 * elements |
| 149 */ | 149 */ |
| 150 static void assertContains(List<Object> array, | 150 static void assertContains(List<Object> array, |
| 151 List<Object> expectedElements) { | 151 List<Object> expectedElements) { |
| 152 int expectedSize = expectedElements.length; | 152 int expectedSize = expectedElements.length; |
| 153 if (array == null) { | 153 if (array == null) { |
| 154 JUnitTestCase.fail( | 154 JUnitTestCase.fail( |
| 155 "Expected array of length ${expectedSize}; found null"); | 155 "Expected array of length $expectedSize; found null"); |
| 156 } | 156 } |
| 157 if (array.length != expectedSize) { | 157 if (array.length != expectedSize) { |
| 158 JUnitTestCase.fail( | 158 JUnitTestCase.fail( |
| 159 "Expected array of length ${expectedSize}; contained ${array.length} e
lements"); | 159 "Expected array of length $expectedSize; contained ${array.length} ele
ments"); |
| 160 } | 160 } |
| 161 List<bool> found = new List<bool>.filled(expectedSize, false); | 161 List<bool> found = new List<bool>.filled(expectedSize, false); |
| 162 for (int i = 0; i < expectedSize; i++) { | 162 for (int i = 0; i < expectedSize; i++) { |
| 163 _privateAssertContains(array, found, expectedElements[i]); | 163 _privateAssertContains(array, found, expectedElements[i]); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 /** | 167 /** |
| 168 * Assert that a given String is equal to an expected value. | 168 * Assert that a given String is equal to an expected value. |
| 169 * | 169 * |
| 170 * @param expected the expected String value | 170 * @param expected the expected String value |
| 171 * @param actual the actual String value | 171 * @param actual the actual String value |
| 172 */ | 172 */ |
| 173 static void assertEqualString(String expected, String actual) { | 173 static void assertEqualString(String expected, String actual) { |
| 174 if (actual == null || expected == null) { | 174 if (actual == null || expected == null) { |
| 175 if (identical(actual, expected)) { | 175 if (identical(actual, expected)) { |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 if (actual == null) { | 178 if (actual == null) { |
| 179 JUnitTestCase.assertTrueMsg( | 179 JUnitTestCase.assertTrueMsg( |
| 180 "Content not as expected: is 'null' expected: ${expected}", | 180 "Content not as expected: is 'null' expected: $expected", |
| 181 false); | 181 false); |
| 182 } else { | 182 } else { |
| 183 JUnitTestCase.assertTrueMsg( | 183 JUnitTestCase.assertTrueMsg( |
| 184 "Content not as expected: expected 'null' is: ${actual}", | 184 "Content not as expected: expected 'null' is: $actual", |
| 185 false); | 185 false); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 int diffPos = _getDiffPos(expected, actual); | 188 int diffPos = _getDiffPos(expected, actual); |
| 189 if (diffPos != -1) { | 189 if (diffPos != -1) { |
| 190 int diffAhead = math.max(0, diffPos - _PRINT_RANGE); | 190 int diffAhead = math.max(0, diffPos - _PRINT_RANGE); |
| 191 int diffAfter = math.min(actual.length, diffPos + _PRINT_RANGE); | 191 int diffAfter = math.min(actual.length, diffPos + _PRINT_RANGE); |
| 192 String diffStr = | 192 String diffStr = |
| 193 "${actual.substring(diffAhead, diffPos)}^${actual.substring(diffPos, d
iffAfter)}"; | 193 "${actual.substring(diffAhead, diffPos)}^${actual.substring(diffPos, d
iffAfter)}"; |
| 194 // use detailed message | 194 // use detailed message |
| 195 String message = | 195 String message = |
| 196 "Content not as expected: is\n${actual}\nDiffers at pos ${diffPos}: ${
diffStr}\nexpected:\n${expected}"; | 196 "Content not as expected: is\n$actual\nDiffers at pos $diffPos: $diffS
tr\nexpected:\n$expected"; |
| 197 JUnitTestCase.assertEqualsMsg(message, expected, actual); | 197 JUnitTestCase.assertEqualsMsg(message, expected, actual); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 /** | 201 /** |
| 202 * Assert that the array of actual values contain exactly the same values as t
hose in the array of | 202 * Assert that the array of actual values contain exactly the same values as t
hose in the array of |
| 203 * expected value, with the exception that the order of the elements is not re
quired to be the | 203 * expected value, with the exception that the order of the elements is not re
quired to be the |
| 204 * same. | 204 * same. |
| 205 * | 205 * |
| 206 * @param expectedValues the values that are expected to be found | 206 * @param expectedValues the values that are expected to be found |
| (...skipping 11 matching lines...) Expand all Loading... |
| 218 for (Object actualValue in actualValues) { | 218 for (Object actualValue in actualValues) { |
| 219 bool wasExpected = false; | 219 bool wasExpected = false; |
| 220 for (int i = 0; i < expectedLength; i++) { | 220 for (int i = 0; i < expectedLength; i++) { |
| 221 if (!found[i] && expectedValues[i] == actualValue) { | 221 if (!found[i] && expectedValues[i] == actualValue) { |
| 222 found[i] = true; | 222 found[i] = true; |
| 223 wasExpected = true; | 223 wasExpected = true; |
| 224 break; | 224 break; |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 if (!wasExpected) { | 227 if (!wasExpected) { |
| 228 JUnitTestCase.fail("The actual value ${actualValue} was not expected"); | 228 JUnitTestCase.fail("The actual value $actualValue was not expected"); |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 /** | 233 /** |
| 234 * Assert that the given array is non-`null` and has exactly expected elements
. | 234 * Assert that the given array is non-`null` and has exactly expected elements
. |
| 235 * | 235 * |
| 236 * @param array the array being tested | 236 * @param array the array being tested |
| 237 * @param expectedElements the expected elements | 237 * @param expectedElements the expected elements |
| 238 * @throws AssertionFailedError if the array is `null` or does not have the ex
pected | 238 * @throws AssertionFailedError if the array is `null` or does not have the ex
pected |
| 239 * elements | 239 * elements |
| 240 */ | 240 */ |
| 241 static void assertExactElementsInArray(List<Object> array, | 241 static void assertExactElementsInArray(List<Object> array, |
| 242 List<Object> expectedElements) { | 242 List<Object> expectedElements) { |
| 243 int expectedSize = expectedElements.length; | 243 int expectedSize = expectedElements.length; |
| 244 if (array == null) { | 244 if (array == null) { |
| 245 JUnitTestCase.fail("Expected array of size ${expectedSize}; found null"); | 245 JUnitTestCase.fail("Expected array of size $expectedSize; found null"); |
| 246 } | 246 } |
| 247 if (array.length != expectedSize) { | 247 if (array.length != expectedSize) { |
| 248 JUnitTestCase.fail( | 248 JUnitTestCase.fail( |
| 249 "Expected array of size ${expectedSize}; contained ${array.length} ele
ments"); | 249 "Expected array of size $expectedSize; contained ${array.length} eleme
nts"); |
| 250 } | 250 } |
| 251 for (int i = 0; i < expectedSize; i++) { | 251 for (int i = 0; i < expectedSize; i++) { |
| 252 Object element = array[i]; | 252 Object element = array[i]; |
| 253 Object expectedElement = expectedElements[i]; | 253 Object expectedElement = expectedElements[i]; |
| 254 if (element != expectedElement) { | 254 if (element != expectedElement) { |
| 255 JUnitTestCase.fail( | 255 JUnitTestCase.fail( |
| 256 "Expected ${expectedElement} at [${i}]; found ${element}"); | 256 "Expected $expectedElement at [$i]; found $element"); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 /** | 261 /** |
| 262 * Assert that the given list is non-`null` and has exactly expected elements. | 262 * Assert that the given list is non-`null` and has exactly expected elements. |
| 263 * | 263 * |
| 264 * @param list the list being tested | 264 * @param list the list being tested |
| 265 * @param expectedElements the expected elements | 265 * @param expectedElements the expected elements |
| 266 * @throws AssertionFailedError if the list is `null` or does not have the exp
ected elements | 266 * @throws AssertionFailedError if the list is `null` or does not have the exp
ected elements |
| 267 */ | 267 */ |
| 268 static void assertExactElementsInList(List list, | 268 static void assertExactElementsInList(List list, |
| 269 List<Object> expectedElements) { | 269 List<Object> expectedElements) { |
| 270 int expectedSize = expectedElements.length; | 270 int expectedSize = expectedElements.length; |
| 271 if (list == null) { | 271 if (list == null) { |
| 272 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); | 272 JUnitTestCase.fail("Expected list of size $expectedSize; found null"); |
| 273 } | 273 } |
| 274 if (list.length != expectedSize) { | 274 if (list.length != expectedSize) { |
| 275 JUnitTestCase.fail( | 275 JUnitTestCase.fail( |
| 276 "Expected list of size ${expectedSize}; contained ${list.length} eleme
nts"); | 276 "Expected list of size $expectedSize; contained ${list.length} element
s"); |
| 277 } | 277 } |
| 278 for (int i = 0; i < expectedSize; i++) { | 278 for (int i = 0; i < expectedSize; i++) { |
| 279 Object element = list[i]; | 279 Object element = list[i]; |
| 280 Object expectedElement = expectedElements[i]; | 280 Object expectedElement = expectedElements[i]; |
| 281 if (element != expectedElement) { | 281 if (element != expectedElement) { |
| 282 JUnitTestCase.fail( | 282 JUnitTestCase.fail( |
| 283 "Expected ${expectedElement} at [${i}]; found ${element}"); | 283 "Expected $expectedElement at [$i]; found $element"); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 | 287 |
| 288 /** | 288 /** |
| 289 * Assert that the given list is non-`null` and has exactly expected elements. | 289 * Assert that the given list is non-`null` and has exactly expected elements. |
| 290 * | 290 * |
| 291 * @param set the list being tested | 291 * @param set the list being tested |
| 292 * @param expectedElements the expected elements | 292 * @param expectedElements the expected elements |
| 293 * @throws AssertionFailedError if the list is `null` or does not have the exp
ected elements | 293 * @throws AssertionFailedError if the list is `null` or does not have the exp
ected elements |
| 294 */ | 294 */ |
| 295 static void assertExactElementsInSet(Set set, List<Object> expectedElements) { | 295 static void assertExactElementsInSet(Set set, List<Object> expectedElements) { |
| 296 int expectedSize = expectedElements.length; | 296 int expectedSize = expectedElements.length; |
| 297 if (set == null) { | 297 if (set == null) { |
| 298 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); | 298 JUnitTestCase.fail("Expected list of size $expectedSize; found null"); |
| 299 } | 299 } |
| 300 if (set.length != expectedSize) { | 300 if (set.length != expectedSize) { |
| 301 JUnitTestCase.fail( | 301 JUnitTestCase.fail( |
| 302 "Expected list of size ${expectedSize}; contained ${set.length} elemen
ts"); | 302 "Expected list of size $expectedSize; contained ${set.length} elements
"); |
| 303 } | 303 } |
| 304 for (int i = 0; i < expectedSize; i++) { | 304 for (int i = 0; i < expectedSize; i++) { |
| 305 Object expectedElement = expectedElements[i]; | 305 Object expectedElement = expectedElements[i]; |
| 306 if (!set.contains(expectedElement)) { | 306 if (!set.contains(expectedElement)) { |
| 307 JUnitTestCase.fail("Expected ${expectedElement} in set${set}"); | 307 JUnitTestCase.fail("Expected $expectedElement in set$set"); |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 } | 310 } |
| 311 | 311 |
| 312 /** | 312 /** |
| 313 * Assert that the given object is an instance of the expected class. | 313 * Assert that the given object is an instance of the expected class. |
| 314 * | 314 * |
| 315 * @param expectedClass the class that the object is expected to be an instanc
e of | 315 * @param expectedClass the class that the object is expected to be an instanc
e of |
| 316 * @param object the object being tested | 316 * @param object the object being tested |
| 317 * @return the object that was being tested | 317 * @return the object that was being tested |
| (...skipping 12 matching lines...) Expand all Loading... |
| 330 * Assert that the given array is non-`null` and has the expected number of el
ements. | 330 * Assert that the given array is non-`null` and has the expected number of el
ements. |
| 331 * | 331 * |
| 332 * @param expectedLength the expected number of elements | 332 * @param expectedLength the expected number of elements |
| 333 * @param array the array being tested | 333 * @param array the array being tested |
| 334 * @throws AssertionFailedError if the array is `null` or does not have the ex
pected number | 334 * @throws AssertionFailedError if the array is `null` or does not have the ex
pected number |
| 335 * of elements | 335 * of elements |
| 336 */ | 336 */ |
| 337 static void assertLength(int expectedLength, List<Object> array) { | 337 static void assertLength(int expectedLength, List<Object> array) { |
| 338 if (array == null) { | 338 if (array == null) { |
| 339 JUnitTestCase.fail( | 339 JUnitTestCase.fail( |
| 340 "Expected array of length ${expectedLength}; found null"); | 340 "Expected array of length $expectedLength; found null"); |
| 341 } else if (array.length != expectedLength) { | 341 } else if (array.length != expectedLength) { |
| 342 JUnitTestCase.fail( | 342 JUnitTestCase.fail( |
| 343 "Expected array of length ${expectedLength}; contained ${array.length}
elements"); | 343 "Expected array of length $expectedLength; contained ${array.length} e
lements"); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 /** | 347 /** |
| 348 * Assert that the actual token has the same type and lexeme as the expected t
oken. Note that this | 348 * Assert that the actual token has the same type and lexeme as the expected t
oken. Note that this |
| 349 * does not assert anything about the offsets of the tokens (although the leng
ths will be equal). | 349 * does not assert anything about the offsets of the tokens (although the leng
ths will be equal). |
| 350 * | 350 * |
| 351 * @param expectedToken the token that was expected | 351 * @param expectedToken the token that was expected |
| 352 * @param actualToken the token that was found | 352 * @param actualToken the token that was found |
| 353 * @throws AssertionFailedError if the two tokens are not the same | 353 * @throws AssertionFailedError if the two tokens are not the same |
| (...skipping 16 matching lines...) Expand all Loading... |
| 370 /** | 370 /** |
| 371 * Assert that the given list is non-`null` and has the expected number of ele
ments. | 371 * Assert that the given list is non-`null` and has the expected number of ele
ments. |
| 372 * | 372 * |
| 373 * @param expectedSize the expected number of elements | 373 * @param expectedSize the expected number of elements |
| 374 * @param list the list being tested | 374 * @param list the list being tested |
| 375 * @throws AssertionFailedError if the list is `null` or does not have the exp
ected number | 375 * @throws AssertionFailedError if the list is `null` or does not have the exp
ected number |
| 376 * of elements | 376 * of elements |
| 377 */ | 377 */ |
| 378 static void assertSizeOfList(int expectedSize, List list) { | 378 static void assertSizeOfList(int expectedSize, List list) { |
| 379 if (list == null) { | 379 if (list == null) { |
| 380 JUnitTestCase.fail("Expected list of size ${expectedSize}; found null"); | 380 JUnitTestCase.fail("Expected list of size $expectedSize; found null"); |
| 381 } else if (list.length != expectedSize) { | 381 } else if (list.length != expectedSize) { |
| 382 JUnitTestCase.fail( | 382 JUnitTestCase.fail( |
| 383 "Expected list of size ${expectedSize}; contained ${list.length} eleme
nts"); | 383 "Expected list of size $expectedSize; contained ${list.length} element
s"); |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 | 386 |
| 387 /** | 387 /** |
| 388 * Assert that the given map is non-`null` and has the expected number of elem
ents. | 388 * Assert that the given map is non-`null` and has the expected number of elem
ents. |
| 389 * | 389 * |
| 390 * @param expectedSize the expected number of elements | 390 * @param expectedSize the expected number of elements |
| 391 * @param map the map being tested | 391 * @param map the map being tested |
| 392 * @throws AssertionFailedError if the map is `null` or does not have the expe
cted number of | 392 * @throws AssertionFailedError if the map is `null` or does not have the expe
cted number of |
| 393 * elements | 393 * elements |
| 394 */ | 394 */ |
| 395 static void assertSizeOfMap(int expectedSize, Map map) { | 395 static void assertSizeOfMap(int expectedSize, Map map) { |
| 396 if (map == null) { | 396 if (map == null) { |
| 397 JUnitTestCase.fail("Expected map of size ${expectedSize}; found null"); | 397 JUnitTestCase.fail("Expected map of size $expectedSize; found null"); |
| 398 } else if (map.length != expectedSize) { | 398 } else if (map.length != expectedSize) { |
| 399 JUnitTestCase.fail( | 399 JUnitTestCase.fail( |
| 400 "Expected map of size ${expectedSize}; contained ${map.length} element
s"); | 400 "Expected map of size $expectedSize; contained ${map.length} elements"
); |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 | 403 |
| 404 /** | 404 /** |
| 405 * Assert that the given set is non-`null` and has the expected number of elem
ents. | 405 * Assert that the given set is non-`null` and has the expected number of elem
ents. |
| 406 * | 406 * |
| 407 * @param expectedSize the expected number of elements | 407 * @param expectedSize the expected number of elements |
| 408 * @param set the set being tested | 408 * @param set the set being tested |
| 409 * @throws AssertionFailedError if the set is `null` or does not have the expe
cted number of | 409 * @throws AssertionFailedError if the set is `null` or does not have the expe
cted number of |
| 410 * elements | 410 * elements |
| 411 */ | 411 */ |
| 412 static void assertSizeOfSet(int expectedSize, Set set) { | 412 static void assertSizeOfSet(int expectedSize, Set set) { |
| 413 if (set == null) { | 413 if (set == null) { |
| 414 JUnitTestCase.fail("Expected set of size ${expectedSize}; found null"); | 414 JUnitTestCase.fail("Expected set of size $expectedSize; found null"); |
| 415 } else if (set.length != expectedSize) { | 415 } else if (set.length != expectedSize) { |
| 416 JUnitTestCase.fail( | 416 JUnitTestCase.fail( |
| 417 "Expected set of size ${expectedSize}; contained ${set.length} element
s"); | 417 "Expected set of size $expectedSize; contained ${set.length} elements"
); |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 /** | 421 /** |
| 422 * @return the [AstNode] with requested type at offset of the "prefix". | 422 * @return the [AstNode] with requested type at offset of the "prefix". |
| 423 */ | 423 */ |
| 424 static AstNode findNode(AstNode root, String code, String prefix, | 424 static AstNode findNode(AstNode root, String code, String prefix, |
| 425 Predicate<AstNode> predicate) { | 425 Predicate<AstNode> predicate) { |
| 426 int offset = code.indexOf(prefix); | 426 int offset = code.indexOf(prefix); |
| 427 if (offset == -1) { | 427 if (offset == -1) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 JUnitTestCase.fail("Does not contain null"); | 467 JUnitTestCase.fail("Does not contain null"); |
| 468 } else { | 468 } else { |
| 469 for (int i = 0; i < array.length; i++) { | 469 for (int i = 0; i < array.length; i++) { |
| 470 if (!found[i]) { | 470 if (!found[i]) { |
| 471 if (element == array[i]) { | 471 if (element == array[i]) { |
| 472 found[i] = true; | 472 found[i] = true; |
| 473 return; | 473 return; |
| 474 } | 474 } |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 JUnitTestCase.fail("Does not contain ${element}"); | 477 JUnitTestCase.fail("Does not contain $element"); |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 | 481 |
| 482 /** | 482 /** |
| 483 * Instances of the class `GatheringErrorListener` implement an error listener t
hat collects | 483 * Instances of the class `GatheringErrorListener` implement an error listener t
hat collects |
| 484 * all of the errors passed to it for later examination. | 484 * all of the errors passed to it for later examination. |
| 485 */ | 485 */ |
| 486 class GatheringErrorListener implements AnalysisErrorListener { | 486 class GatheringErrorListener implements AnalysisErrorListener { |
| 487 /** | 487 /** |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 for (AnalysisError error in _errors) { | 704 for (AnalysisError error in _errors) { |
| 705 if (error.errorCode.errorSeverity == ErrorSeverity.ERROR) { | 705 if (error.errorCode.errorSeverity == ErrorSeverity.ERROR) { |
| 706 actualErrorCount++; | 706 actualErrorCount++; |
| 707 } else { | 707 } else { |
| 708 actualWarningCount++; | 708 actualWarningCount++; |
| 709 } | 709 } |
| 710 } | 710 } |
| 711 if (expectedErrorCount != actualErrorCount || | 711 if (expectedErrorCount != actualErrorCount || |
| 712 expectedWarningCount != actualWarningCount) { | 712 expectedWarningCount != actualWarningCount) { |
| 713 JUnitTestCase.fail( | 713 JUnitTestCase.fail( |
| 714 "Expected ${expectedErrorCount} errors and ${expectedWarningCount} war
nings, found ${actualErrorCount} errors and ${actualWarningCount} warnings"); | 714 "Expected $expectedErrorCount errors and $expectedWarningCount warning
s, found $actualErrorCount errors and $actualWarningCount warnings"); |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 | 717 |
| 718 /** | 718 /** |
| 719 * Assert that no errors have been gathered. | 719 * Assert that no errors have been gathered. |
| 720 * | 720 * |
| 721 * @throws AssertionFailedError if any errors have been gathered | 721 * @throws AssertionFailedError if any errors have been gathered |
| 722 */ | 722 */ |
| 723 void assertNoErrors() { | 723 void assertNoErrors() { |
| 724 assertErrors(_NO_ERRORS); | 724 assertErrors(_NO_ERRORS); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 void getContentsToReceiver(Source_ContentReceiver receiver) { | 991 void getContentsToReceiver(Source_ContentReceiver receiver) { |
| 992 throw new UnsupportedOperationException(); | 992 throw new UnsupportedOperationException(); |
| 993 } | 993 } |
| 994 Source resolve(String uri) { | 994 Source resolve(String uri) { |
| 995 throw new UnsupportedOperationException(); | 995 throw new UnsupportedOperationException(); |
| 996 } | 996 } |
| 997 Uri resolveRelativeUri(Uri uri) { | 997 Uri resolveRelativeUri(Uri uri) { |
| 998 return new Uri(scheme: 'file', path: _name).resolveUri(uri); | 998 return new Uri(scheme: 'file', path: _name).resolveUri(uri); |
| 999 } | 999 } |
| 1000 } | 1000 } |
| OLD | NEW |