| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 buffer.write("Expected element named: "); | 53 buffer.write("Expected element named: "); |
| 54 buffer.write(elemName); | 54 buffer.write(elemName); |
| 55 buffer.write("\n but found: "); | 55 buffer.write("\n but found: "); |
| 56 for (Element elem in elements) { | 56 for (Element elem in elements) { |
| 57 buffer.write(elem.name); | 57 buffer.write(elem.name); |
| 58 buffer.write(", "); | 58 buffer.write(", "); |
| 59 } | 59 } |
| 60 fail(buffer.toString()); | 60 fail(buffer.toString()); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 assertLength(names.length, elements); | 63 expect(elements, hasLength(names.length)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 AnalysisContextImpl createAnalysisContext() { | 66 AnalysisContextImpl createAnalysisContext() { |
| 67 AnalysisContextImpl context = new AnalysisContextImpl(); | 67 AnalysisContextImpl context = new AnalysisContextImpl(); |
| 68 context.sourceFactory = new SourceFactory([]); | 68 context.sourceFactory = new SourceFactory([]); |
| 69 return context; | 69 return context; |
| 70 } | 70 } |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * Return the getter in the given type with the given name. Inherited getters
are ignored. | 73 * Return the getter in the given type with the given name. Inherited getters
are ignored. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 Token left = expectedStream; | 116 Token left = expectedStream; |
| 117 Token right = actualStream; | 117 Token right = actualStream; |
| 118 while (left.type != TokenType.EOF && right.type != TokenType.EOF) { | 118 while (left.type != TokenType.EOF && right.type != TokenType.EOF) { |
| 119 assertMatches(left, right); | 119 assertMatches(left, right); |
| 120 left = left.next; | 120 left = left.next; |
| 121 right = right.next; | 121 right = right.next; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * Assert that the given collection is non-`null` and has the expected number
of elements. | |
| 127 * | |
| 128 * @param expectedSize the expected number of elements | |
| 129 * @param c the collection being tested | |
| 130 * @throws AssertionFailedError if the list is `null` or does not have the exp
ected number | |
| 131 * of elements | |
| 132 */ | |
| 133 static void assertCollectionSize(int expectedSize, Iterable c) { | |
| 134 if (c == null) { | |
| 135 fail("Expected collection of size $expectedSize; found null"); | |
| 136 } else if (c.length != expectedSize) { | |
| 137 fail("Expected collection of size $expectedSize; contained ${c.length} ele
ments"); | |
| 138 } | |
| 139 } | |
| 140 | |
| 141 /** | |
| 142 * Assert that the given array is non-`null` and contains the expected element
s. The | 126 * Assert that the given array is non-`null` and contains the expected element
s. The |
| 143 * elements can appear in any order. | 127 * elements can appear in any order. |
| 144 * | 128 * |
| 145 * @param array the array being tested | 129 * @param array the array being tested |
| 146 * @param expectedElements the expected elements | 130 * @param expectedElements the expected elements |
| 147 * @throws AssertionFailedError if the array is `null` or does not contain the
expected | 131 * @throws AssertionFailedError if the array is `null` or does not contain the
expected |
| 148 * elements | 132 * elements |
| 149 */ | 133 */ |
| 150 static void assertContains(List<Object> array, | 134 static void assertContains(List<Object> array, |
| 151 List<Object> expectedElements) { | 135 List<Object> expectedElements) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 */ | 292 */ |
| 309 static Object assertInstanceOf(Predicate<Object> predicate, | 293 static Object assertInstanceOf(Predicate<Object> predicate, |
| 310 Type expectedClass, Object object) { | 294 Type expectedClass, Object object) { |
| 311 if (!predicate(object)) { | 295 if (!predicate(object)) { |
| 312 fail("Expected instance of $expectedClass, found ${object == null ? "null"
: object.runtimeType}"); | 296 fail("Expected instance of $expectedClass, found ${object == null ? "null"
: object.runtimeType}"); |
| 313 } | 297 } |
| 314 return object; | 298 return object; |
| 315 } | 299 } |
| 316 | 300 |
| 317 /** | 301 /** |
| 318 * Assert that the given array is non-`null` and has the expected number of el
ements. | |
| 319 * | |
| 320 * @param expectedLength the expected number of elements | |
| 321 * @param array the array being tested | |
| 322 * @throws AssertionFailedError if the array is `null` or does not have the ex
pected number | |
| 323 * of elements | |
| 324 */ | |
| 325 static void assertLength(int expectedLength, List<Object> array) { | |
| 326 if (array == null) { | |
| 327 fail("Expected array of length $expectedLength; found null"); | |
| 328 } else if (array.length != expectedLength) { | |
| 329 fail("Expected array of length $expectedLength; contained ${array.length}
elements"); | |
| 330 } | |
| 331 } | |
| 332 | |
| 333 /** | |
| 334 * Assert that the actual token has the same type and lexeme as the expected t
oken. Note that this | 302 * Assert that the actual token has the same type and lexeme as the expected t
oken. Note that this |
| 335 * does not assert anything about the offsets of the tokens (although the leng
ths will be equal). | 303 * does not assert anything about the offsets of the tokens (although the leng
ths will be equal). |
| 336 * | 304 * |
| 337 * @param expectedToken the token that was expected | 305 * @param expectedToken the token that was expected |
| 338 * @param actualToken the token that was found | 306 * @param actualToken the token that was found |
| 339 * @throws AssertionFailedError if the two tokens are not the same | 307 * @throws AssertionFailedError if the two tokens are not the same |
| 340 */ | 308 */ |
| 341 static void assertMatches(Token expectedToken, Token actualToken) { | 309 static void assertMatches(Token expectedToken, Token actualToken) { |
| 342 expect(actualToken.type, expectedToken.type); | 310 expect(actualToken.type, expectedToken.type); |
| 343 if (expectedToken is KeywordToken) { | 311 if (expectedToken is KeywordToken) { |
| 344 assertInstanceOf((obj) => obj is KeywordToken, KeywordToken, actualToken); | 312 assertInstanceOf((obj) => obj is KeywordToken, KeywordToken, actualToken); |
| 345 expect((actualToken as KeywordToken).keyword, expectedToken.keyword); | 313 expect((actualToken as KeywordToken).keyword, expectedToken.keyword); |
| 346 } else if (expectedToken is StringToken) { | 314 } else if (expectedToken is StringToken) { |
| 347 assertInstanceOf((obj) => obj is StringToken, StringToken, actualToken); | 315 assertInstanceOf((obj) => obj is StringToken, StringToken, actualToken); |
| 348 expect((actualToken as StringToken).lexeme, expectedToken.lexeme); | 316 expect((actualToken as StringToken).lexeme, expectedToken.lexeme); |
| 349 } | 317 } |
| 350 } | 318 } |
| 351 | 319 |
| 352 /** | |
| 353 * Assert that the given list is non-`null` and has the expected number of ele
ments. | |
| 354 * | |
| 355 * @param expectedSize the expected number of elements | |
| 356 * @param list the list being tested | |
| 357 * @throws AssertionFailedError if the list is `null` or does not have the exp
ected number | |
| 358 * of elements | |
| 359 */ | |
| 360 static void assertSizeOfList(int expectedSize, List list) { | |
| 361 if (list == null) { | |
| 362 fail("Expected list of size $expectedSize; found null"); | |
| 363 } else if (list.length != expectedSize) { | |
| 364 fail("Expected list of size $expectedSize; contained ${list.length} elemen
ts"); | |
| 365 } | |
| 366 } | |
| 367 | |
| 368 /** | |
| 369 * Assert that the given map is non-`null` and has the expected number of elem
ents. | |
| 370 * | |
| 371 * @param expectedSize the expected number of elements | |
| 372 * @param map the map being tested | |
| 373 * @throws AssertionFailedError if the map is `null` or does not have the expe
cted number of | |
| 374 * elements | |
| 375 */ | |
| 376 static void assertSizeOfMap(int expectedSize, Map map) { | |
| 377 if (map == null) { | |
| 378 fail("Expected map of size $expectedSize; found null"); | |
| 379 } else if (map.length != expectedSize) { | |
| 380 fail("Expected map of size $expectedSize; contained ${map.length} elements
"); | |
| 381 } | |
| 382 } | |
| 383 | |
| 384 /** | |
| 385 * Assert that the given set is non-`null` and has the expected number of elem
ents. | |
| 386 * | |
| 387 * @param expectedSize the expected number of elements | |
| 388 * @param set the set being tested | |
| 389 * @throws AssertionFailedError if the set is `null` or does not have the expe
cted number of | |
| 390 * elements | |
| 391 */ | |
| 392 static void assertSizeOfSet(int expectedSize, Set set) { | |
| 393 if (set == null) { | |
| 394 fail("Expected set of size $expectedSize; found null"); | |
| 395 } else if (set.length != expectedSize) { | |
| 396 fail("Expected set of size $expectedSize; contained ${set.length} elements
"); | |
| 397 } | |
| 398 } | |
| 399 | 320 |
| 400 /** | 321 /** |
| 401 * @return the [AstNode] with requested type at offset of the "prefix". | 322 * @return the [AstNode] with requested type at offset of the "prefix". |
| 402 */ | 323 */ |
| 403 static AstNode findNode(AstNode root, String code, String prefix, | 324 static AstNode findNode(AstNode root, String code, String prefix, |
| 404 Predicate<AstNode> predicate) { | 325 Predicate<AstNode> predicate) { |
| 405 int offset = code.indexOf(prefix); | 326 int offset = code.indexOf(prefix); |
| 406 if (offset == -1) { | 327 if (offset == -1) { |
| 407 throw new IllegalArgumentException("Not found '$prefix'."); | 328 throw new IllegalArgumentException("Not found '$prefix'."); |
| 408 } | 329 } |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 void getContentsToReceiver(Source_ContentReceiver receiver) { | 888 void getContentsToReceiver(Source_ContentReceiver receiver) { |
| 968 throw new UnsupportedOperationException(); | 889 throw new UnsupportedOperationException(); |
| 969 } | 890 } |
| 970 Source resolve(String uri) { | 891 Source resolve(String uri) { |
| 971 throw new UnsupportedOperationException(); | 892 throw new UnsupportedOperationException(); |
| 972 } | 893 } |
| 973 Uri resolveRelativeUri(Uri uri) { | 894 Uri resolveRelativeUri(Uri uri) { |
| 974 return new Uri(scheme: 'file', path: _name).resolveUri(uri); | 895 return new Uri(scheme: 'file', path: _name).resolveUri(uri); |
| 975 } | 896 } |
| 976 } | 897 } |
| OLD | NEW |