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.utilities_test; | 8 library engine.utilities_test; |
9 | 9 |
10 import 'dart:collection'; | 10 import 'dart:collection'; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 @override | 54 @override |
55 bool isEqualTokens(Token first, Token second) { | 55 bool isEqualTokens(Token first, Token second) { |
56 if (expectTokensCopied && first != null && identical(first, second)) { | 56 if (expectTokensCopied && first != null && identical(first, second)) { |
57 fail('Failed to copy token: ${first.lexeme} (${first.offset})'); | 57 fail('Failed to copy token: ${first.lexeme} (${first.offset})'); |
58 return false; | 58 return false; |
59 } | 59 } |
60 return super.isEqualTokens(first, second); | 60 return super.isEqualTokens(first, second); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 @ReflectiveTestCase() | 64 @reflectiveTest |
65 class AstClonerTest extends EngineTestCase { | 65 class AstClonerTest extends EngineTestCase { |
66 void test_visitAdjacentStrings() { | 66 void test_visitAdjacentStrings() { |
67 _assertClone( | 67 _assertClone( |
68 AstFactory.adjacentStrings([AstFactory.string2("a"), AstFactory.string2(
"b")])); | 68 AstFactory.adjacentStrings([AstFactory.string2("a"), AstFactory.string2(
"b")])); |
69 } | 69 } |
70 | 70 |
71 void test_visitAnnotation_constant() { | 71 void test_visitAnnotation_constant() { |
72 _assertClone(AstFactory.annotation(AstFactory.identifier3("A"))); | 72 _assertClone(AstFactory.annotation(AstFactory.identifier3("A"))); |
73 } | 73 } |
74 | 74 |
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 } | 2046 } |
2047 | 2047 |
2048 clone = node.accept(new AstCloner(true)); | 2048 clone = node.accept(new AstCloner(true)); |
2049 comparitor = new AstCloneComparator(true); | 2049 comparitor = new AstCloneComparator(true); |
2050 if (!comparitor.isEqualNodes(node, clone)) { | 2050 if (!comparitor.isEqualNodes(node, clone)) { |
2051 fail("Failed to clone ${node.runtimeType.toString()}"); | 2051 fail("Failed to clone ${node.runtimeType.toString()}"); |
2052 } | 2052 } |
2053 } | 2053 } |
2054 } | 2054 } |
2055 | 2055 |
2056 @ReflectiveTestCase() | 2056 @reflectiveTest |
2057 class BooleanArrayTest { | 2057 class BooleanArrayTest { |
2058 void test_get_negative() { | 2058 void test_get_negative() { |
2059 try { | 2059 try { |
2060 BooleanArray.get(0, -1); | 2060 BooleanArray.get(0, -1); |
2061 fail("Expected "); | 2061 fail("Expected "); |
2062 } on RangeError catch (exception) { | 2062 } on RangeError catch (exception) { |
2063 // Expected | 2063 // Expected |
2064 } | 2064 } |
2065 } | 2065 } |
2066 | 2066 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2106 } | 2106 } |
2107 | 2107 |
2108 void test_set_valuePreserving() { | 2108 void test_set_valuePreserving() { |
2109 expect(BooleanArray.set(0, 0, false), 0); | 2109 expect(BooleanArray.set(0, 0, false), 0); |
2110 expect(BooleanArray.set(1, 0, true), 1); | 2110 expect(BooleanArray.set(1, 0, true), 1); |
2111 expect(BooleanArray.set(0, 30, false), 0); | 2111 expect(BooleanArray.set(0, 30, false), 0); |
2112 expect(BooleanArray.set(1 << 30, 30, true), 1 << 30); | 2112 expect(BooleanArray.set(1 << 30, 30, true), 1 << 30); |
2113 } | 2113 } |
2114 } | 2114 } |
2115 | 2115 |
2116 @ReflectiveTestCase() | 2116 @reflectiveTest |
2117 class DirectedGraphTest extends EngineTestCase { | 2117 class DirectedGraphTest extends EngineTestCase { |
2118 void test_addEdge() { | 2118 void test_addEdge() { |
2119 DirectedGraph<DirectedGraphTest_Node> graph = | 2119 DirectedGraph<DirectedGraphTest_Node> graph = |
2120 new DirectedGraph<DirectedGraphTest_Node>(); | 2120 new DirectedGraph<DirectedGraphTest_Node>(); |
2121 expect(graph.isEmpty, isTrue); | 2121 expect(graph.isEmpty, isTrue); |
2122 graph.addEdge(new DirectedGraphTest_Node(), new DirectedGraphTest_Node()); | 2122 graph.addEdge(new DirectedGraphTest_Node(), new DirectedGraphTest_Node()); |
2123 expect(graph.isEmpty, isFalse); | 2123 expect(graph.isEmpty, isFalse); |
2124 } | 2124 } |
2125 | 2125 |
2126 void test_addNode() { | 2126 void test_addNode() { |
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3244 @override | 3244 @override |
3245 TypeArgumentList get(TypedLiteral node) => node.typeArguments; | 3245 TypeArgumentList get(TypedLiteral node) => node.typeArguments; |
3246 } | 3246 } |
3247 | 3247 |
3248 class Getter_NodeReplacerTest_testUriBasedDirective implements | 3248 class Getter_NodeReplacerTest_testUriBasedDirective implements |
3249 NodeReplacerTest_Getter { | 3249 NodeReplacerTest_Getter { |
3250 @override | 3250 @override |
3251 StringLiteral get(UriBasedDirective node) => node.uri; | 3251 StringLiteral get(UriBasedDirective node) => node.uri; |
3252 } | 3252 } |
3253 | 3253 |
3254 @ReflectiveTestCase() | 3254 @reflectiveTest |
3255 class LineInfoTest { | 3255 class LineInfoTest { |
3256 void test_creation() { | 3256 void test_creation() { |
3257 expect(new LineInfo(<int>[0]), isNotNull); | 3257 expect(new LineInfo(<int>[0]), isNotNull); |
3258 } | 3258 } |
3259 | 3259 |
3260 void test_creation_empty() { | 3260 void test_creation_empty() { |
3261 try { | 3261 try { |
3262 new LineInfo(<int>[]); | 3262 new LineInfo(<int>[]); |
3263 fail("Expected IllegalArgumentException"); | 3263 fail("Expected IllegalArgumentException"); |
3264 } on IllegalArgumentException catch (exception) { | 3264 } on IllegalArgumentException catch (exception) { |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3556 } | 3556 } |
3557 | 3557 |
3558 class ListGetter_NodeReplacerTest_testSwitchMember_2 extends | 3558 class ListGetter_NodeReplacerTest_testSwitchMember_2 extends |
3559 NodeReplacerTest_ListGetter<SwitchMember, Statement> { | 3559 NodeReplacerTest_ListGetter<SwitchMember, Statement> { |
3560 ListGetter_NodeReplacerTest_testSwitchMember_2(int arg0) : super(arg0); | 3560 ListGetter_NodeReplacerTest_testSwitchMember_2(int arg0) : super(arg0); |
3561 | 3561 |
3562 @override | 3562 @override |
3563 NodeList<Statement> getList(SwitchMember node) => node.statements; | 3563 NodeList<Statement> getList(SwitchMember node) => node.statements; |
3564 } | 3564 } |
3565 | 3565 |
3566 @ReflectiveTestCase() | 3566 @reflectiveTest |
3567 class ListUtilitiesTest { | 3567 class ListUtilitiesTest { |
3568 void test_addAll_emptyToEmpty() { | 3568 void test_addAll_emptyToEmpty() { |
3569 List<String> list = new List<String>(); | 3569 List<String> list = new List<String>(); |
3570 List<String> elements = <String>[]; | 3570 List<String> elements = <String>[]; |
3571 ListUtilities.addAll(list, elements); | 3571 ListUtilities.addAll(list, elements); |
3572 expect(list.length, 0); | 3572 expect(list.length, 0); |
3573 } | 3573 } |
3574 | 3574 |
3575 void test_addAll_emptyToNonEmpty() { | 3575 void test_addAll_emptyToNonEmpty() { |
3576 List<String> list = new List<String>(); | 3576 List<String> list = new List<String>(); |
(...skipping 12 matching lines...) Expand all Loading... |
3589 | 3589 |
3590 void test_addAll_nonEmptyToNonEmpty() { | 3590 void test_addAll_nonEmptyToNonEmpty() { |
3591 List<String> list = new List<String>(); | 3591 List<String> list = new List<String>(); |
3592 list.add("a"); | 3592 list.add("a"); |
3593 List<String> elements = ["b", "c"]; | 3593 List<String> elements = ["b", "c"]; |
3594 ListUtilities.addAll(list, elements); | 3594 ListUtilities.addAll(list, elements); |
3595 expect(list.length, 3); | 3595 expect(list.length, 3); |
3596 } | 3596 } |
3597 } | 3597 } |
3598 | 3598 |
3599 @ReflectiveTestCase() | 3599 @reflectiveTest |
3600 class MultipleMapIteratorTest extends EngineTestCase { | 3600 class MultipleMapIteratorTest extends EngineTestCase { |
3601 void test_multipleMaps_firstEmpty() { | 3601 void test_multipleMaps_firstEmpty() { |
3602 Map<String, String> map1 = new HashMap<String, String>(); | 3602 Map<String, String> map1 = new HashMap<String, String>(); |
3603 Map<String, String> map2 = new HashMap<String, String>(); | 3603 Map<String, String> map2 = new HashMap<String, String>(); |
3604 map2["k2"] = "v2"; | 3604 map2["k2"] = "v2"; |
3605 Map<String, String> map3 = new HashMap<String, String>(); | 3605 Map<String, String> map3 = new HashMap<String, String>(); |
3606 map3["k3"] = "v3"; | 3606 map3["k3"] = "v3"; |
3607 MultipleMapIterator<String, String> iterator = | 3607 MultipleMapIterator<String, String> iterator = |
3608 _iterator([map1, map2, map3]); | 3608 _iterator([map1, map2, map3]); |
3609 expect(iterator.moveNext(), isTrue); | 3609 expect(iterator.moveNext(), isTrue); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3707 iterator.value = newValue; | 3707 iterator.value = newValue; |
3708 expect(iterator.value, same(newValue)); | 3708 expect(iterator.value, same(newValue)); |
3709 expect(iterator.moveNext(), isFalse); | 3709 expect(iterator.moveNext(), isFalse); |
3710 } | 3710 } |
3711 | 3711 |
3712 MultipleMapIterator<String, String> _iterator(List<Map> maps) { | 3712 MultipleMapIterator<String, String> _iterator(List<Map> maps) { |
3713 return new MultipleMapIterator<String, String>(maps); | 3713 return new MultipleMapIterator<String, String>(maps); |
3714 } | 3714 } |
3715 } | 3715 } |
3716 | 3716 |
3717 @ReflectiveTestCase() | 3717 @reflectiveTest |
3718 class NodeReplacerTest extends EngineTestCase { | 3718 class NodeReplacerTest extends EngineTestCase { |
3719 /** | 3719 /** |
3720 * An empty list of tokens. | 3720 * An empty list of tokens. |
3721 */ | 3721 */ |
3722 static const List<Token> EMPTY_TOKEN_LIST = const <Token>[]; | 3722 static const List<Token> EMPTY_TOKEN_LIST = const <Token>[]; |
3723 | 3723 |
3724 void test_adjacentStrings() { | 3724 void test_adjacentStrings() { |
3725 AdjacentStrings node = | 3725 AdjacentStrings node = |
3726 AstFactory.adjacentStrings([AstFactory.string2("a"), AstFactory.string2(
"b")]); | 3726 AstFactory.adjacentStrings([AstFactory.string2("a"), AstFactory.string2(
"b")]); |
3727 _assertReplace( | 3727 _assertReplace( |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4757 NodeList<C> list = getList(parent); | 4757 NodeList<C> list = getList(parent); |
4758 if (list.isEmpty) { | 4758 if (list.isEmpty) { |
4759 return null; | 4759 return null; |
4760 } | 4760 } |
4761 return list[_index]; | 4761 return list[_index]; |
4762 } | 4762 } |
4763 | 4763 |
4764 NodeList<C> getList(P parent); | 4764 NodeList<C> getList(P parent); |
4765 } | 4765 } |
4766 | 4766 |
4767 @ReflectiveTestCase() | 4767 @reflectiveTest |
4768 class SingleMapIteratorTest extends EngineTestCase { | 4768 class SingleMapIteratorTest extends EngineTestCase { |
4769 void test_empty() { | 4769 void test_empty() { |
4770 Map<String, String> map = new HashMap<String, String>(); | 4770 Map<String, String> map = new HashMap<String, String>(); |
4771 SingleMapIterator<String, String> iterator = | 4771 SingleMapIterator<String, String> iterator = |
4772 new SingleMapIterator<String, String>(map); | 4772 new SingleMapIterator<String, String>(map); |
4773 expect(iterator.moveNext(), isFalse); | 4773 expect(iterator.moveNext(), isFalse); |
4774 try { | 4774 try { |
4775 iterator.key; | 4775 iterator.key; |
4776 fail("Expected NoSuchElementException"); | 4776 fail("Expected NoSuchElementException"); |
4777 } on NoSuchElementException catch (exception) { | 4777 } on NoSuchElementException catch (exception) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4815 expect(iterator.moveNext(), isTrue); | 4815 expect(iterator.moveNext(), isTrue); |
4816 expect(iterator.key, same(key)); | 4816 expect(iterator.key, same(key)); |
4817 expect(iterator.value, same(value)); | 4817 expect(iterator.value, same(value)); |
4818 String newValue = "newValue"; | 4818 String newValue = "newValue"; |
4819 iterator.value = newValue; | 4819 iterator.value = newValue; |
4820 expect(iterator.value, same(newValue)); | 4820 expect(iterator.value, same(newValue)); |
4821 expect(iterator.moveNext(), isFalse); | 4821 expect(iterator.moveNext(), isFalse); |
4822 } | 4822 } |
4823 } | 4823 } |
4824 | 4824 |
4825 @ReflectiveTestCase() | 4825 @reflectiveTest |
4826 class SourceRangeTest { | 4826 class SourceRangeTest { |
4827 void test_access() { | 4827 void test_access() { |
4828 SourceRange r = new SourceRange(10, 1); | 4828 SourceRange r = new SourceRange(10, 1); |
4829 expect(r.offset, 10); | 4829 expect(r.offset, 10); |
4830 expect(r.length, 1); | 4830 expect(r.length, 1); |
4831 expect(r.end, 10 + 1); | 4831 expect(r.end, 10 + 1); |
4832 // to check | 4832 // to check |
4833 r.hashCode; | 4833 r.hashCode; |
4834 } | 4834 } |
4835 | 4835 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4965 expect(r.startsIn(new SourceRange(5, 1)), isTrue); | 4965 expect(r.startsIn(new SourceRange(5, 1)), isTrue); |
4966 expect(r.startsIn(new SourceRange(0, 20)), isTrue); | 4966 expect(r.startsIn(new SourceRange(0, 20)), isTrue); |
4967 } | 4967 } |
4968 | 4968 |
4969 void test_toString() { | 4969 void test_toString() { |
4970 SourceRange r = new SourceRange(10, 1); | 4970 SourceRange r = new SourceRange(10, 1); |
4971 expect(r.toString(), "[offset=10, length=1]"); | 4971 expect(r.toString(), "[offset=10, length=1]"); |
4972 } | 4972 } |
4973 } | 4973 } |
4974 | 4974 |
4975 @ReflectiveTestCase() | 4975 @reflectiveTest |
4976 class StringUtilitiesTest { | 4976 class StringUtilitiesTest { |
4977 void test_EMPTY() { | 4977 void test_EMPTY() { |
4978 expect(StringUtilities.EMPTY, ""); | 4978 expect(StringUtilities.EMPTY, ""); |
4979 expect(StringUtilities.EMPTY.isEmpty, isTrue); | 4979 expect(StringUtilities.EMPTY.isEmpty, isTrue); |
4980 } | 4980 } |
4981 | 4981 |
4982 void test_EMPTY_ARRAY() { | 4982 void test_EMPTY_ARRAY() { |
4983 expect(StringUtilities.EMPTY_ARRAY.length, 0); | 4983 expect(StringUtilities.EMPTY_ARRAY.length, 0); |
4984 } | 4984 } |
4985 | 4985 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5222 expect(StringUtilities.substringBeforeChar(null, 0x61), null); | 5222 expect(StringUtilities.substringBeforeChar(null, 0x61), null); |
5223 expect(StringUtilities.substringBeforeChar("", 0x61), ""); | 5223 expect(StringUtilities.substringBeforeChar("", 0x61), ""); |
5224 expect(StringUtilities.substringBeforeChar("abc", 0x61), ""); | 5224 expect(StringUtilities.substringBeforeChar("abc", 0x61), ""); |
5225 expect(StringUtilities.substringBeforeChar("abcba", 0x62), "a"); | 5225 expect(StringUtilities.substringBeforeChar("abcba", 0x62), "a"); |
5226 expect(StringUtilities.substringBeforeChar("abc", 0x63), "ab"); | 5226 expect(StringUtilities.substringBeforeChar("abc", 0x63), "ab"); |
5227 expect(StringUtilities.substringBeforeChar("abc", 0x64), "abc"); | 5227 expect(StringUtilities.substringBeforeChar("abc", 0x64), "abc"); |
5228 } | 5228 } |
5229 } | 5229 } |
5230 | 5230 |
5231 | 5231 |
5232 @ReflectiveTestCase() | 5232 @reflectiveTest |
5233 class TokenMapTest { | 5233 class TokenMapTest { |
5234 void test_creation() { | 5234 void test_creation() { |
5235 expect(new TokenMap(), isNotNull); | 5235 expect(new TokenMap(), isNotNull); |
5236 } | 5236 } |
5237 | 5237 |
5238 void test_get_absent() { | 5238 void test_get_absent() { |
5239 TokenMap tokenMap = new TokenMap(); | 5239 TokenMap tokenMap = new TokenMap(); |
5240 expect(tokenMap.get(TokenFactory.tokenFromType(TokenType.AT)), isNull); | 5240 expect(tokenMap.get(TokenFactory.tokenFromType(TokenType.AT)), isNull); |
5241 } | 5241 } |
5242 | 5242 |
5243 void test_get_added() { | 5243 void test_get_added() { |
5244 TokenMap tokenMap = new TokenMap(); | 5244 TokenMap tokenMap = new TokenMap(); |
5245 Token key = TokenFactory.tokenFromType(TokenType.AT); | 5245 Token key = TokenFactory.tokenFromType(TokenType.AT); |
5246 Token value = TokenFactory.tokenFromType(TokenType.AT); | 5246 Token value = TokenFactory.tokenFromType(TokenType.AT); |
5247 tokenMap.put(key, value); | 5247 tokenMap.put(key, value); |
5248 expect(tokenMap.get(key), same(value)); | 5248 expect(tokenMap.get(key), same(value)); |
5249 } | 5249 } |
5250 } | 5250 } |
OLD | NEW |