Chromium Code Reviews| 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'; |
| 11 | 11 |
| 12 import 'package:analyzer/src/generated/ast.dart'; | 12 import 'package:analyzer/src/generated/ast.dart'; |
| 13 import 'package:analyzer/src/generated/engine.dart'; | 13 import 'package:analyzer/src/generated/engine.dart'; |
| 14 import 'package:analyzer/src/generated/java_core.dart'; | 14 import 'package:analyzer/src/generated/java_core.dart'; |
| 15 import 'package:analyzer/src/generated/java_engine.dart'; | 15 import 'package:analyzer/src/generated/java_engine.dart'; |
| 16 import 'package:analyzer/src/generated/java_junit.dart'; | |
| 17 import 'package:analyzer/src/generated/scanner.dart'; | 16 import 'package:analyzer/src/generated/scanner.dart'; |
| 18 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
| 19 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 18 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 20 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 19 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
| 21 import 'package:analyzer/src/generated/utilities_collection.dart'; | 20 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 22 import 'package:unittest/unittest.dart' as _ut; | 21 import 'package:unittest/unittest.dart'; |
| 23 | 22 |
| 24 import '../reflective_tests.dart'; | 23 import '../reflective_tests.dart'; |
| 25 import 'test_support.dart'; | 24 import 'test_support.dart'; |
| 26 | 25 |
| 27 main() { | 26 main() { |
| 28 _ut.groupSep = ' | '; | 27 groupSep = ' | '; |
| 29 runReflectiveTests(AstClonerTest); | 28 runReflectiveTests(AstClonerTest); |
| 30 runReflectiveTests(NodeReplacerTest); | 29 runReflectiveTests(NodeReplacerTest); |
| 31 runReflectiveTests(LineInfoTest); | 30 runReflectiveTests(LineInfoTest); |
| 32 runReflectiveTests(SourceRangeTest); | 31 runReflectiveTests(SourceRangeTest); |
| 33 runReflectiveTests(BooleanArrayTest); | 32 runReflectiveTests(BooleanArrayTest); |
| 34 runReflectiveTests(DirectedGraphTest); | 33 runReflectiveTests(DirectedGraphTest); |
| 35 runReflectiveTests(ListUtilitiesTest); | 34 runReflectiveTests(ListUtilitiesTest); |
| 36 runReflectiveTests(MultipleMapIteratorTest); | 35 runReflectiveTests(MultipleMapIteratorTest); |
| 37 runReflectiveTests(SingleMapIteratorTest); | 36 runReflectiveTests(SingleMapIteratorTest); |
| 38 runReflectiveTests(TokenMapTest); | 37 runReflectiveTests(TokenMapTest); |
| (...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2043 * Assert that an `AstCloner` will produce the expected AST structure when | 2042 * Assert that an `AstCloner` will produce the expected AST structure when |
| 2044 * visiting the given [node]. | 2043 * visiting the given [node]. |
| 2045 * | 2044 * |
| 2046 * @param node the AST node being visited to produce the cloned structure | 2045 * @param node the AST node being visited to produce the cloned structure |
| 2047 * @throws AFE if the visitor does not produce the expected source for the giv en node | 2046 * @throws AFE if the visitor does not produce the expected source for the giv en node |
| 2048 */ | 2047 */ |
| 2049 void _assertClone(AstNode node) { | 2048 void _assertClone(AstNode node) { |
| 2050 AstNode clone = node.accept(new AstCloner()); | 2049 AstNode clone = node.accept(new AstCloner()); |
| 2051 AstCloneComparator comparitor = new AstCloneComparator(false); | 2050 AstCloneComparator comparitor = new AstCloneComparator(false); |
| 2052 if (!comparitor.isEqualNodes(node, clone)) { | 2051 if (!comparitor.isEqualNodes(node, clone)) { |
| 2053 JUnitTestCase.fail("Failed to clone ${node.runtimeType.toString()}"); | 2052 fail("Failed to clone ${node.runtimeType.toString()}"); |
| 2054 } | 2053 } |
| 2055 | 2054 |
| 2056 clone = node.accept(new AstCloner(true)); | 2055 clone = node.accept(new AstCloner(true)); |
| 2057 comparitor = new AstCloneComparator(true); | 2056 comparitor = new AstCloneComparator(true); |
| 2058 if (!comparitor.isEqualNodes(node, clone)) { | 2057 if (!comparitor.isEqualNodes(node, clone)) { |
| 2059 JUnitTestCase.fail("Failed to clone ${node.runtimeType.toString()}"); | 2058 fail("Failed to clone ${node.runtimeType.toString()}"); |
| 2060 } | 2059 } |
| 2061 } | 2060 } |
| 2062 } | 2061 } |
| 2063 | 2062 |
| 2064 class AstCloneComparator extends AstComparator { | 2063 class AstCloneComparator extends AstComparator { |
| 2065 final bool expectTokensCopied; | 2064 final bool expectTokensCopied; |
| 2066 | 2065 |
| 2067 AstCloneComparator(this.expectTokensCopied); | 2066 AstCloneComparator(this.expectTokensCopied); |
| 2068 | 2067 |
| 2069 @override | 2068 @override |
| 2070 bool isEqualNodes(AstNode first, AstNode second) { | 2069 bool isEqualNodes(AstNode first, AstNode second) { |
| 2071 if (first != null && identical(first, second)) { | 2070 if (first != null && identical(first, second)) { |
| 2072 JUnitTestCase.fail('Failed to copy node: $first (${first.offset})'); | 2071 fail('Failed to copy node: $first (${first.offset})'); |
| 2073 return false; | 2072 return false; |
| 2074 } | 2073 } |
| 2075 return super.isEqualNodes(first, second); | 2074 return super.isEqualNodes(first, second); |
| 2076 } | 2075 } |
| 2077 | 2076 |
| 2078 @override | 2077 @override |
| 2079 bool isEqualTokens(Token first, Token second) { | 2078 bool isEqualTokens(Token first, Token second) { |
| 2080 if (expectTokensCopied && first != null && identical(first, second)) { | 2079 if (expectTokensCopied && first != null && identical(first, second)) { |
| 2081 JUnitTestCase.fail('Failed to copy token: ${first.lexeme} (${first.offset} )'); | 2080 fail('Failed to copy token: ${first.lexeme} (${first.offset})'); |
| 2082 return false; | 2081 return false; |
| 2083 } | 2082 } |
| 2084 return super.isEqualTokens(first, second); | 2083 return super.isEqualTokens(first, second); |
| 2085 } | 2084 } |
| 2086 } | 2085 } |
| 2087 | 2086 |
| 2088 class BooleanArrayTest extends JUnitTestCase { | 2087 class BooleanArrayTest { |
| 2089 void test_get_negative() { | 2088 void test_get_negative() { |
| 2090 try { | 2089 try { |
| 2091 BooleanArray.get(0, -1); | 2090 BooleanArray.get(0, -1); |
| 2092 JUnitTestCase.fail("Expected "); | 2091 fail("Expected "); |
| 2093 } on RangeError catch (exception) { | 2092 } on RangeError catch (exception) { |
| 2094 // Expected | 2093 // Expected |
| 2095 } | 2094 } |
| 2096 } | 2095 } |
| 2097 | 2096 |
| 2098 void test_get_tooBig() { | 2097 void test_get_tooBig() { |
| 2099 try { | 2098 try { |
| 2100 BooleanArray.get(0, 31); | 2099 BooleanArray.get(0, 31); |
| 2101 JUnitTestCase.fail("Expected "); | 2100 fail("Expected "); |
| 2102 } on RangeError catch (exception) { | 2101 } on RangeError catch (exception) { |
| 2103 // Expected | 2102 // Expected |
| 2104 } | 2103 } |
| 2105 } | 2104 } |
| 2106 | 2105 |
| 2107 void test_get_valid() { | 2106 void test_get_valid() { |
| 2108 JUnitTestCase.assertEquals(false, BooleanArray.get(0, 0)); | 2107 expect(BooleanArray.get(0, 0), false); |
|
Brian Wilkerson
2014/10/27 23:13:29
Should these be isFalse and isTrue? When should we
scheglov
2014/10/28 00:01:06
The original Java source:
assertEquals(false, Boo
| |
| 2109 JUnitTestCase.assertEquals(true, BooleanArray.get(1, 0)); | 2108 expect(BooleanArray.get(1, 0), true); |
| 2110 JUnitTestCase.assertEquals(false, BooleanArray.get(0, 30)); | 2109 expect(BooleanArray.get(0, 30), false); |
| 2111 JUnitTestCase.assertEquals(true, BooleanArray.get(1 << 30, 30)); | 2110 expect(BooleanArray.get(1 << 30, 30), true); |
| 2112 } | 2111 } |
| 2113 | 2112 |
| 2114 void test_set_negative() { | 2113 void test_set_negative() { |
| 2115 try { | 2114 try { |
| 2116 BooleanArray.set(0, -1, true); | 2115 BooleanArray.set(0, -1, true); |
| 2117 JUnitTestCase.fail("Expected "); | 2116 fail("Expected "); |
| 2118 } on RangeError catch (exception) { | 2117 } on RangeError catch (exception) { |
| 2119 // Expected | 2118 // Expected |
| 2120 } | 2119 } |
| 2121 } | 2120 } |
| 2122 | 2121 |
| 2123 void test_set_tooBig() { | 2122 void test_set_tooBig() { |
| 2124 try { | 2123 try { |
| 2125 BooleanArray.set(0, 32, true); | 2124 BooleanArray.set(0, 32, true); |
| 2126 JUnitTestCase.fail("Expected "); | 2125 fail("Expected "); |
| 2127 } on RangeError catch (exception) { | 2126 } on RangeError catch (exception) { |
| 2128 // Expected | 2127 // Expected |
| 2129 } | 2128 } |
| 2130 } | 2129 } |
| 2131 | 2130 |
| 2132 void test_set_valueChanging() { | 2131 void test_set_valueChanging() { |
| 2133 JUnitTestCase.assertEquals(1, BooleanArray.set(0, 0, true)); | 2132 expect(BooleanArray.set(0, 0, true), 1); |
| 2134 JUnitTestCase.assertEquals(0, BooleanArray.set(1, 0, false)); | 2133 expect(BooleanArray.set(1, 0, false), 0); |
| 2135 JUnitTestCase.assertEquals(1 << 30, BooleanArray.set(0, 30, true)); | 2134 expect(BooleanArray.set(0, 30, true), 1 << 30); |
| 2136 JUnitTestCase.assertEquals(0, BooleanArray.set(1 << 30, 30, false)); | 2135 expect(BooleanArray.set(1 << 30, 30, false), 0); |
| 2137 } | 2136 } |
| 2138 | 2137 |
| 2139 void test_set_valuePreserving() { | 2138 void test_set_valuePreserving() { |
| 2140 JUnitTestCase.assertEquals(0, BooleanArray.set(0, 0, false)); | 2139 expect(BooleanArray.set(0, 0, false), 0); |
| 2141 JUnitTestCase.assertEquals(1, BooleanArray.set(1, 0, true)); | 2140 expect(BooleanArray.set(1, 0, true), 1); |
| 2142 JUnitTestCase.assertEquals(0, BooleanArray.set(0, 30, false)); | 2141 expect(BooleanArray.set(0, 30, false), 0); |
| 2143 JUnitTestCase.assertEquals(1 << 30, BooleanArray.set(1 << 30, 30, true)); | 2142 expect(BooleanArray.set(1 << 30, 30, true), 1 << 30); |
| 2144 } | 2143 } |
| 2145 } | 2144 } |
| 2146 | 2145 |
| 2147 class DirectedGraphTest extends EngineTestCase { | 2146 class DirectedGraphTest extends EngineTestCase { |
| 2148 void test_addEdge() { | 2147 void test_addEdge() { |
| 2149 DirectedGraph<DirectedGraphTest_Node> graph = | 2148 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2150 new DirectedGraph<DirectedGraphTest_Node>(); | 2149 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2151 JUnitTestCase.assertTrue(graph.isEmpty); | 2150 expect(graph.isEmpty, isTrue); |
| 2152 graph.addEdge(new DirectedGraphTest_Node(), new DirectedGraphTest_Node()); | 2151 graph.addEdge(new DirectedGraphTest_Node(), new DirectedGraphTest_Node()); |
| 2153 JUnitTestCase.assertFalse(graph.isEmpty); | 2152 expect(graph.isEmpty, isFalse); |
| 2154 } | 2153 } |
| 2155 | 2154 |
| 2156 void test_addNode() { | 2155 void test_addNode() { |
| 2157 DirectedGraph<DirectedGraphTest_Node> graph = | 2156 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2158 new DirectedGraph<DirectedGraphTest_Node>(); | 2157 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2159 JUnitTestCase.assertTrue(graph.isEmpty); | 2158 expect(graph.isEmpty, isTrue); |
| 2160 graph.addNode(new DirectedGraphTest_Node()); | 2159 graph.addNode(new DirectedGraphTest_Node()); |
| 2161 JUnitTestCase.assertFalse(graph.isEmpty); | 2160 expect(graph.isEmpty, isFalse); |
| 2162 } | 2161 } |
| 2163 | 2162 |
| 2164 void test_containsPath_noCycles() { | 2163 void test_containsPath_noCycles() { |
| 2165 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2164 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2166 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2165 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2167 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); | 2166 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); |
| 2168 DirectedGraph<DirectedGraphTest_Node> graph = | 2167 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2169 new DirectedGraph<DirectedGraphTest_Node>(); | 2168 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2170 graph.addEdge(node1, node2); | 2169 graph.addEdge(node1, node2); |
| 2171 graph.addEdge(node2, node3); | 2170 graph.addEdge(node2, node3); |
| 2172 JUnitTestCase.assertTrue(graph.containsPath(node1, node1)); | 2171 expect(graph.containsPath(node1, node1), isTrue); |
| 2173 JUnitTestCase.assertTrue(graph.containsPath(node1, node2)); | 2172 expect(graph.containsPath(node1, node2), isTrue); |
| 2174 JUnitTestCase.assertTrue(graph.containsPath(node1, node3)); | 2173 expect(graph.containsPath(node1, node3), isTrue); |
| 2175 JUnitTestCase.assertFalse(graph.containsPath(node2, node1)); | 2174 expect(graph.containsPath(node2, node1), isFalse); |
| 2176 JUnitTestCase.assertTrue(graph.containsPath(node2, node2)); | 2175 expect(graph.containsPath(node2, node2), isTrue); |
| 2177 JUnitTestCase.assertTrue(graph.containsPath(node2, node3)); | 2176 expect(graph.containsPath(node2, node3), isTrue); |
| 2178 JUnitTestCase.assertFalse(graph.containsPath(node3, node1)); | 2177 expect(graph.containsPath(node3, node1), isFalse); |
| 2179 JUnitTestCase.assertFalse(graph.containsPath(node3, node2)); | 2178 expect(graph.containsPath(node3, node2), isFalse); |
| 2180 JUnitTestCase.assertTrue(graph.containsPath(node3, node3)); | 2179 expect(graph.containsPath(node3, node3), isTrue); |
| 2181 } | 2180 } |
| 2182 | 2181 |
| 2183 void test_containsPath_withCycles() { | 2182 void test_containsPath_withCycles() { |
| 2184 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2183 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2185 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2184 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2186 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); | 2185 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); |
| 2187 DirectedGraphTest_Node node4 = new DirectedGraphTest_Node(); | 2186 DirectedGraphTest_Node node4 = new DirectedGraphTest_Node(); |
| 2188 DirectedGraph<DirectedGraphTest_Node> graph = | 2187 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2189 new DirectedGraph<DirectedGraphTest_Node>(); | 2188 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2190 graph.addEdge(node1, node2); | 2189 graph.addEdge(node1, node2); |
| 2191 graph.addEdge(node2, node1); | 2190 graph.addEdge(node2, node1); |
| 2192 graph.addEdge(node1, node3); | 2191 graph.addEdge(node1, node3); |
| 2193 graph.addEdge(node3, node4); | 2192 graph.addEdge(node3, node4); |
| 2194 graph.addEdge(node4, node3); | 2193 graph.addEdge(node4, node3); |
| 2195 JUnitTestCase.assertTrue(graph.containsPath(node1, node1)); | 2194 expect(graph.containsPath(node1, node1), isTrue); |
| 2196 JUnitTestCase.assertTrue(graph.containsPath(node1, node2)); | 2195 expect(graph.containsPath(node1, node2), isTrue); |
| 2197 JUnitTestCase.assertTrue(graph.containsPath(node1, node3)); | 2196 expect(graph.containsPath(node1, node3), isTrue); |
| 2198 JUnitTestCase.assertTrue(graph.containsPath(node1, node4)); | 2197 expect(graph.containsPath(node1, node4), isTrue); |
| 2199 JUnitTestCase.assertTrue(graph.containsPath(node2, node1)); | 2198 expect(graph.containsPath(node2, node1), isTrue); |
| 2200 JUnitTestCase.assertTrue(graph.containsPath(node2, node2)); | 2199 expect(graph.containsPath(node2, node2), isTrue); |
| 2201 JUnitTestCase.assertTrue(graph.containsPath(node2, node3)); | 2200 expect(graph.containsPath(node2, node3), isTrue); |
| 2202 JUnitTestCase.assertTrue(graph.containsPath(node2, node4)); | 2201 expect(graph.containsPath(node2, node4), isTrue); |
| 2203 JUnitTestCase.assertFalse(graph.containsPath(node3, node1)); | 2202 expect(graph.containsPath(node3, node1), isFalse); |
| 2204 JUnitTestCase.assertFalse(graph.containsPath(node3, node2)); | 2203 expect(graph.containsPath(node3, node2), isFalse); |
| 2205 JUnitTestCase.assertTrue(graph.containsPath(node3, node3)); | 2204 expect(graph.containsPath(node3, node3), isTrue); |
| 2206 JUnitTestCase.assertTrue(graph.containsPath(node3, node4)); | 2205 expect(graph.containsPath(node3, node4), isTrue); |
| 2207 JUnitTestCase.assertFalse(graph.containsPath(node4, node1)); | 2206 expect(graph.containsPath(node4, node1), isFalse); |
| 2208 JUnitTestCase.assertFalse(graph.containsPath(node4, node2)); | 2207 expect(graph.containsPath(node4, node2), isFalse); |
| 2209 JUnitTestCase.assertTrue(graph.containsPath(node4, node3)); | 2208 expect(graph.containsPath(node4, node3), isTrue); |
| 2210 JUnitTestCase.assertTrue(graph.containsPath(node4, node4)); | 2209 expect(graph.containsPath(node4, node4), isTrue); |
| 2211 } | 2210 } |
| 2212 | 2211 |
| 2213 void test_creation() { | 2212 void test_creation() { |
| 2214 JUnitTestCase.assertNotNull(new DirectedGraph<DirectedGraphTest_Node>()); | 2213 expect(new DirectedGraph<DirectedGraphTest_Node>(), isNotNull); |
| 2215 } | 2214 } |
| 2216 | 2215 |
| 2217 void test_findCycleContaining_complexCycle() { | 2216 void test_findCycleContaining_complexCycle() { |
| 2218 // Two overlapping loops: (1, 2, 3) and (3, 4, 5) | 2217 // Two overlapping loops: (1, 2, 3) and (3, 4, 5) |
| 2219 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2218 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2220 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2219 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2221 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); | 2220 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); |
| 2222 DirectedGraphTest_Node node4 = new DirectedGraphTest_Node(); | 2221 DirectedGraphTest_Node node4 = new DirectedGraphTest_Node(); |
| 2223 DirectedGraphTest_Node node5 = new DirectedGraphTest_Node(); | 2222 DirectedGraphTest_Node node5 = new DirectedGraphTest_Node(); |
| 2224 DirectedGraph<DirectedGraphTest_Node> graph = | 2223 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2225 new DirectedGraph<DirectedGraphTest_Node>(); | 2224 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2226 graph.addEdge(node1, node2); | 2225 graph.addEdge(node1, node2); |
| 2227 graph.addEdge(node2, node3); | 2226 graph.addEdge(node2, node3); |
| 2228 graph.addEdge(node3, node1); | 2227 graph.addEdge(node3, node1); |
| 2229 graph.addEdge(node3, node4); | 2228 graph.addEdge(node3, node4); |
| 2230 graph.addEdge(node4, node5); | 2229 graph.addEdge(node4, node5); |
| 2231 graph.addEdge(node5, node3); | 2230 graph.addEdge(node5, node3); |
| 2232 List<DirectedGraphTest_Node> cycle = graph.findCycleContaining(node1); | 2231 List<DirectedGraphTest_Node> cycle = graph.findCycleContaining(node1); |
| 2233 EngineTestCase.assertSizeOfList(5, cycle); | 2232 EngineTestCase.assertSizeOfList(5, cycle); |
| 2234 JUnitTestCase.assertTrue(cycle.contains(node1)); | 2233 expect(cycle.contains(node1), isTrue); |
| 2235 JUnitTestCase.assertTrue(cycle.contains(node2)); | 2234 expect(cycle.contains(node2), isTrue); |
| 2236 JUnitTestCase.assertTrue(cycle.contains(node3)); | 2235 expect(cycle.contains(node3), isTrue); |
| 2237 JUnitTestCase.assertTrue(cycle.contains(node4)); | 2236 expect(cycle.contains(node4), isTrue); |
| 2238 JUnitTestCase.assertTrue(cycle.contains(node5)); | 2237 expect(cycle.contains(node5), isTrue); |
| 2239 } | 2238 } |
| 2240 | 2239 |
| 2241 void test_findCycleContaining_cycle() { | 2240 void test_findCycleContaining_cycle() { |
| 2242 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2241 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2243 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2242 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2244 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); | 2243 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); |
| 2245 DirectedGraph<DirectedGraphTest_Node> graph = | 2244 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2246 new DirectedGraph<DirectedGraphTest_Node>(); | 2245 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2247 graph.addEdge(node1, node2); | 2246 graph.addEdge(node1, node2); |
| 2248 graph.addEdge(node2, node3); | 2247 graph.addEdge(node2, node3); |
| 2249 graph.addEdge(node2, new DirectedGraphTest_Node()); | 2248 graph.addEdge(node2, new DirectedGraphTest_Node()); |
| 2250 graph.addEdge(node3, node1); | 2249 graph.addEdge(node3, node1); |
| 2251 graph.addEdge(node3, new DirectedGraphTest_Node()); | 2250 graph.addEdge(node3, new DirectedGraphTest_Node()); |
| 2252 List<DirectedGraphTest_Node> cycle = graph.findCycleContaining(node1); | 2251 List<DirectedGraphTest_Node> cycle = graph.findCycleContaining(node1); |
| 2253 EngineTestCase.assertSizeOfList(3, cycle); | 2252 EngineTestCase.assertSizeOfList(3, cycle); |
| 2254 JUnitTestCase.assertTrue(cycle.contains(node1)); | 2253 expect(cycle.contains(node1), isTrue); |
| 2255 JUnitTestCase.assertTrue(cycle.contains(node2)); | 2254 expect(cycle.contains(node2), isTrue); |
| 2256 JUnitTestCase.assertTrue(cycle.contains(node3)); | 2255 expect(cycle.contains(node3), isTrue); |
| 2257 } | 2256 } |
| 2258 | 2257 |
| 2259 void test_findCycleContaining_notInGraph() { | 2258 void test_findCycleContaining_notInGraph() { |
| 2260 DirectedGraphTest_Node node = new DirectedGraphTest_Node(); | 2259 DirectedGraphTest_Node node = new DirectedGraphTest_Node(); |
| 2261 DirectedGraph<DirectedGraphTest_Node> graph = | 2260 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2262 new DirectedGraph<DirectedGraphTest_Node>(); | 2261 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2263 List<DirectedGraphTest_Node> cycle = graph.findCycleContaining(node); | 2262 List<DirectedGraphTest_Node> cycle = graph.findCycleContaining(node); |
| 2264 EngineTestCase.assertSizeOfList(1, cycle); | 2263 EngineTestCase.assertSizeOfList(1, cycle); |
| 2265 JUnitTestCase.assertEquals(node, cycle[0]); | 2264 expect(cycle[0], node); |
|
Brian Wilkerson
2014/10/27 23:13:29
When should we use a matcher like "equals(node)" r
scheglov
2014/10/28 00:01:06
expect() automatically wraps its expected value in
| |
| 2266 } | 2265 } |
| 2267 | 2266 |
| 2268 void test_findCycleContaining_null() { | 2267 void test_findCycleContaining_null() { |
| 2269 DirectedGraph<DirectedGraphTest_Node> graph = | 2268 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2270 new DirectedGraph<DirectedGraphTest_Node>(); | 2269 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2271 try { | 2270 try { |
| 2272 graph.findCycleContaining(null); | 2271 graph.findCycleContaining(null); |
| 2273 JUnitTestCase.fail("Expected IllegalArgumentException"); | 2272 fail("Expected IllegalArgumentException"); |
| 2274 } on IllegalArgumentException catch (exception) { | 2273 } on IllegalArgumentException catch (exception) { |
| 2275 // Expected | 2274 // Expected |
| 2276 } | 2275 } |
| 2277 } | 2276 } |
| 2278 | 2277 |
| 2279 void test_findCycleContaining_singleton() { | 2278 void test_findCycleContaining_singleton() { |
| 2280 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2279 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2281 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2280 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2282 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); | 2281 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); |
| 2283 DirectedGraph<DirectedGraphTest_Node> graph = | 2282 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2284 new DirectedGraph<DirectedGraphTest_Node>(); | 2283 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2285 graph.addEdge(node1, node2); | 2284 graph.addEdge(node1, node2); |
| 2286 graph.addEdge(node2, node3); | 2285 graph.addEdge(node2, node3); |
| 2287 List<DirectedGraphTest_Node> cycle = graph.findCycleContaining(node1); | 2286 List<DirectedGraphTest_Node> cycle = graph.findCycleContaining(node1); |
| 2288 EngineTestCase.assertSizeOfList(1, cycle); | 2287 EngineTestCase.assertSizeOfList(1, cycle); |
| 2289 JUnitTestCase.assertEquals(node1, cycle[0]); | 2288 expect(cycle[0], node1); |
| 2290 } | 2289 } |
| 2291 | 2290 |
| 2292 void test_getNodeCount() { | 2291 void test_getNodeCount() { |
| 2293 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2292 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2294 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2293 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2295 DirectedGraph<DirectedGraphTest_Node> graph = | 2294 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2296 new DirectedGraph<DirectedGraphTest_Node>(); | 2295 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2297 JUnitTestCase.assertEquals(0, graph.nodeCount); | 2296 expect(graph.nodeCount, 0); |
| 2298 graph.addNode(node1); | 2297 graph.addNode(node1); |
| 2299 JUnitTestCase.assertEquals(1, graph.nodeCount); | 2298 expect(graph.nodeCount, 1); |
| 2300 graph.addNode(node2); | 2299 graph.addNode(node2); |
| 2301 JUnitTestCase.assertEquals(2, graph.nodeCount); | 2300 expect(graph.nodeCount, 2); |
| 2302 graph.removeNode(node1); | 2301 graph.removeNode(node1); |
| 2303 JUnitTestCase.assertEquals(1, graph.nodeCount); | 2302 expect(graph.nodeCount, 1); |
| 2304 } | 2303 } |
| 2305 | 2304 |
| 2306 void test_getTails() { | 2305 void test_getTails() { |
| 2307 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2306 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2308 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2307 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2309 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); | 2308 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); |
| 2310 DirectedGraph<DirectedGraphTest_Node> graph = | 2309 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2311 new DirectedGraph<DirectedGraphTest_Node>(); | 2310 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2312 EngineTestCase.assertSizeOfSet(0, graph.getTails(node1)); | 2311 EngineTestCase.assertSizeOfSet(0, graph.getTails(node1)); |
| 2313 graph.addEdge(node1, node2); | 2312 graph.addEdge(node1, node2); |
| 2314 EngineTestCase.assertSizeOfSet(1, graph.getTails(node1)); | 2313 EngineTestCase.assertSizeOfSet(1, graph.getTails(node1)); |
| 2315 graph.addEdge(node1, node3); | 2314 graph.addEdge(node1, node3); |
| 2316 EngineTestCase.assertSizeOfSet(2, graph.getTails(node1)); | 2315 EngineTestCase.assertSizeOfSet(2, graph.getTails(node1)); |
| 2317 } | 2316 } |
| 2318 | 2317 |
| 2319 void test_removeAllNodes() { | 2318 void test_removeAllNodes() { |
| 2320 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2319 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2321 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2320 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2322 List<DirectedGraphTest_Node> nodes = new List<DirectedGraphTest_Node>(); | 2321 List<DirectedGraphTest_Node> nodes = new List<DirectedGraphTest_Node>(); |
| 2323 nodes.add(node1); | 2322 nodes.add(node1); |
| 2324 nodes.add(node2); | 2323 nodes.add(node2); |
| 2325 DirectedGraph<DirectedGraphTest_Node> graph = | 2324 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2326 new DirectedGraph<DirectedGraphTest_Node>(); | 2325 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2327 graph.addEdge(node1, node2); | 2326 graph.addEdge(node1, node2); |
| 2328 graph.addEdge(node2, node1); | 2327 graph.addEdge(node2, node1); |
| 2329 JUnitTestCase.assertFalse(graph.isEmpty); | 2328 expect(graph.isEmpty, isFalse); |
| 2330 graph.removeAllNodes(nodes); | 2329 graph.removeAllNodes(nodes); |
| 2331 JUnitTestCase.assertTrue(graph.isEmpty); | 2330 expect(graph.isEmpty, isTrue); |
| 2332 } | 2331 } |
| 2333 | 2332 |
| 2334 void test_removeEdge() { | 2333 void test_removeEdge() { |
| 2335 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2334 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2336 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2335 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2337 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); | 2336 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); |
| 2338 DirectedGraph<DirectedGraphTest_Node> graph = | 2337 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2339 new DirectedGraph<DirectedGraphTest_Node>(); | 2338 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2340 graph.addEdge(node1, node2); | 2339 graph.addEdge(node1, node2); |
| 2341 graph.addEdge(node1, node3); | 2340 graph.addEdge(node1, node3); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2356 graph.removeNode(node2); | 2355 graph.removeNode(node2); |
| 2357 EngineTestCase.assertSizeOfSet(1, graph.getTails(node1)); | 2356 EngineTestCase.assertSizeOfSet(1, graph.getTails(node1)); |
| 2358 } | 2357 } |
| 2359 | 2358 |
| 2360 void test_removeSink() { | 2359 void test_removeSink() { |
| 2361 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2360 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2362 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2361 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2363 DirectedGraph<DirectedGraphTest_Node> graph = | 2362 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2364 new DirectedGraph<DirectedGraphTest_Node>(); | 2363 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2365 graph.addEdge(node1, node2); | 2364 graph.addEdge(node1, node2); |
| 2366 JUnitTestCase.assertSame(node2, graph.removeSink()); | 2365 expect(graph.removeSink(), same(node2)); |
| 2367 JUnitTestCase.assertSame(node1, graph.removeSink()); | 2366 expect(graph.removeSink(), same(node1)); |
| 2368 JUnitTestCase.assertTrue(graph.isEmpty); | 2367 expect(graph.isEmpty, isTrue); |
| 2369 } | 2368 } |
| 2370 | 2369 |
| 2371 void test_topologicalSort_noCycles() { | 2370 void test_topologicalSort_noCycles() { |
| 2372 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2371 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2373 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2372 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2374 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); | 2373 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); |
| 2375 DirectedGraph<DirectedGraphTest_Node> graph = | 2374 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2376 new DirectedGraph<DirectedGraphTest_Node>(); | 2375 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2377 graph.addEdge(node1, node2); | 2376 graph.addEdge(node1, node2); |
| 2378 graph.addEdge(node1, node3); | 2377 graph.addEdge(node1, node3); |
| 2379 graph.addEdge(node2, node3); | 2378 graph.addEdge(node2, node3); |
| 2380 List<List<DirectedGraphTest_Node>> topologicalSort = | 2379 List<List<DirectedGraphTest_Node>> topologicalSort = |
| 2381 graph.computeTopologicalSort(); | 2380 graph.computeTopologicalSort(); |
| 2382 EngineTestCase.assertSizeOfList(3, topologicalSort); | 2381 EngineTestCase.assertSizeOfList(3, topologicalSort); |
| 2383 EngineTestCase.assertSizeOfList(1, topologicalSort[0]); | 2382 EngineTestCase.assertSizeOfList(1, topologicalSort[0]); |
| 2384 JUnitTestCase.assertEquals(node3, topologicalSort[0][0]); | 2383 expect(topologicalSort[0][0], node3); |
| 2385 EngineTestCase.assertSizeOfList(1, topologicalSort[1]); | 2384 EngineTestCase.assertSizeOfList(1, topologicalSort[1]); |
| 2386 JUnitTestCase.assertEquals(node2, topologicalSort[1][0]); | 2385 expect(topologicalSort[1][0], node2); |
| 2387 EngineTestCase.assertSizeOfList(1, topologicalSort[2]); | 2386 EngineTestCase.assertSizeOfList(1, topologicalSort[2]); |
| 2388 JUnitTestCase.assertEquals(node1, topologicalSort[2][0]); | 2387 expect(topologicalSort[2][0], node1); |
| 2389 } | 2388 } |
| 2390 | 2389 |
| 2391 void test_topologicalSort_withCycles() { | 2390 void test_topologicalSort_withCycles() { |
| 2392 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); | 2391 DirectedGraphTest_Node node1 = new DirectedGraphTest_Node(); |
| 2393 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); | 2392 DirectedGraphTest_Node node2 = new DirectedGraphTest_Node(); |
| 2394 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); | 2393 DirectedGraphTest_Node node3 = new DirectedGraphTest_Node(); |
| 2395 DirectedGraphTest_Node node4 = new DirectedGraphTest_Node(); | 2394 DirectedGraphTest_Node node4 = new DirectedGraphTest_Node(); |
| 2396 DirectedGraph<DirectedGraphTest_Node> graph = | 2395 DirectedGraph<DirectedGraphTest_Node> graph = |
| 2397 new DirectedGraph<DirectedGraphTest_Node>(); | 2396 new DirectedGraph<DirectedGraphTest_Node>(); |
| 2398 graph.addEdge(node1, node2); | 2397 graph.addEdge(node1, node2); |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3274 @override | 3273 @override |
| 3275 Expression get(WhileStatement node) => node.condition; | 3274 Expression get(WhileStatement node) => node.condition; |
| 3276 } | 3275 } |
| 3277 | 3276 |
| 3278 class Getter_NodeReplacerTest_test_whileStatement_2 implements | 3277 class Getter_NodeReplacerTest_test_whileStatement_2 implements |
| 3279 NodeReplacerTest_Getter { | 3278 NodeReplacerTest_Getter { |
| 3280 @override | 3279 @override |
| 3281 Statement get(WhileStatement node) => node.body; | 3280 Statement get(WhileStatement node) => node.body; |
| 3282 } | 3281 } |
| 3283 | 3282 |
| 3284 class LineInfoTest extends JUnitTestCase { | 3283 class LineInfoTest { |
| 3285 void test_creation() { | 3284 void test_creation() { |
| 3286 JUnitTestCase.assertNotNull(new LineInfo(<int>[0])); | 3285 expect(new LineInfo(<int>[0]), isNotNull); |
| 3287 } | 3286 } |
| 3288 | 3287 |
| 3289 void test_creation_empty() { | 3288 void test_creation_empty() { |
| 3290 try { | 3289 try { |
| 3291 new LineInfo(<int>[]); | 3290 new LineInfo(<int>[]); |
| 3292 JUnitTestCase.fail("Expected IllegalArgumentException"); | 3291 fail("Expected IllegalArgumentException"); |
| 3293 } on IllegalArgumentException catch (exception) { | 3292 } on IllegalArgumentException catch (exception) { |
| 3294 // Expected | 3293 // Expected |
| 3295 } | 3294 } |
| 3296 } | 3295 } |
| 3297 | 3296 |
| 3298 void test_creation_null() { | 3297 void test_creation_null() { |
| 3299 try { | 3298 try { |
| 3300 new LineInfo(null); | 3299 new LineInfo(null); |
| 3301 JUnitTestCase.fail("Expected IllegalArgumentException"); | 3300 fail("Expected IllegalArgumentException"); |
| 3302 } on IllegalArgumentException catch (exception) { | 3301 } on IllegalArgumentException catch (exception) { |
| 3303 // Expected | 3302 // Expected |
| 3304 } | 3303 } |
| 3305 } | 3304 } |
| 3306 | 3305 |
| 3307 void test_firstLine() { | 3306 void test_firstLine() { |
| 3308 LineInfo info = new LineInfo(<int>[0, 12, 34]); | 3307 LineInfo info = new LineInfo(<int>[0, 12, 34]); |
| 3309 LineInfo_Location location = info.getLocation(4); | 3308 LineInfo_Location location = info.getLocation(4); |
| 3310 JUnitTestCase.assertEquals(1, location.lineNumber); | 3309 expect(location.lineNumber, 1); |
| 3311 JUnitTestCase.assertEquals(5, location.columnNumber); | 3310 expect(location.columnNumber, 5); |
| 3312 } | 3311 } |
| 3313 | 3312 |
| 3314 void test_lastLine() { | 3313 void test_lastLine() { |
| 3315 LineInfo info = new LineInfo(<int>[0, 12, 34]); | 3314 LineInfo info = new LineInfo(<int>[0, 12, 34]); |
| 3316 LineInfo_Location location = info.getLocation(36); | 3315 LineInfo_Location location = info.getLocation(36); |
| 3317 JUnitTestCase.assertEquals(3, location.lineNumber); | 3316 expect(location.lineNumber, 3); |
| 3318 JUnitTestCase.assertEquals(3, location.columnNumber); | 3317 expect(location.columnNumber, 3); |
| 3319 } | 3318 } |
| 3320 | 3319 |
| 3321 void test_middleLine() { | 3320 void test_middleLine() { |
| 3322 LineInfo info = new LineInfo(<int>[0, 12, 34]); | 3321 LineInfo info = new LineInfo(<int>[0, 12, 34]); |
| 3323 LineInfo_Location location = info.getLocation(12); | 3322 LineInfo_Location location = info.getLocation(12); |
| 3324 JUnitTestCase.assertEquals(2, location.lineNumber); | 3323 expect(location.lineNumber, 2); |
| 3325 JUnitTestCase.assertEquals(1, location.columnNumber); | 3324 expect(location.columnNumber, 1); |
| 3326 } | 3325 } |
| 3327 } | 3326 } |
| 3328 | 3327 |
| 3329 class ListGetter_NodeReplacerTest_testAnnotatedNode extends | 3328 class ListGetter_NodeReplacerTest_testAnnotatedNode extends |
| 3330 NodeReplacerTest_ListGetter<AnnotatedNode, Annotation> { | 3329 NodeReplacerTest_ListGetter<AnnotatedNode, Annotation> { |
| 3331 ListGetter_NodeReplacerTest_testAnnotatedNode(int arg0) : super(arg0); | 3330 ListGetter_NodeReplacerTest_testAnnotatedNode(int arg0) : super(arg0); |
| 3332 | 3331 |
| 3333 @override | 3332 @override |
| 3334 NodeList<Annotation> getList(AnnotatedNode node) => node.metadata; | 3333 NodeList<Annotation> getList(AnnotatedNode node) => node.metadata; |
| 3335 } | 3334 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3585 } | 3584 } |
| 3586 | 3585 |
| 3587 class ListGetter_NodeReplacerTest_test_withClause extends | 3586 class ListGetter_NodeReplacerTest_test_withClause extends |
| 3588 NodeReplacerTest_ListGetter<WithClause, TypeName> { | 3587 NodeReplacerTest_ListGetter<WithClause, TypeName> { |
| 3589 ListGetter_NodeReplacerTest_test_withClause(int arg0) : super(arg0); | 3588 ListGetter_NodeReplacerTest_test_withClause(int arg0) : super(arg0); |
| 3590 | 3589 |
| 3591 @override | 3590 @override |
| 3592 NodeList<TypeName> getList(WithClause node) => node.mixinTypes; | 3591 NodeList<TypeName> getList(WithClause node) => node.mixinTypes; |
| 3593 } | 3592 } |
| 3594 | 3593 |
| 3595 class ListUtilitiesTest extends JUnitTestCase { | 3594 class ListUtilitiesTest { |
| 3596 void test_addAll_emptyToEmpty() { | 3595 void test_addAll_emptyToEmpty() { |
| 3597 List<String> list = new List<String>(); | 3596 List<String> list = new List<String>(); |
| 3598 List<String> elements = []; | 3597 List<String> elements = []; |
| 3599 ListUtilities.addAll(list, elements); | 3598 ListUtilities.addAll(list, elements); |
| 3600 JUnitTestCase.assertEquals(0, list.length); | 3599 expect(list.length, 0); |
| 3601 } | 3600 } |
| 3602 | 3601 |
| 3603 void test_addAll_emptyToNonEmpty() { | 3602 void test_addAll_emptyToNonEmpty() { |
| 3604 List<String> list = new List<String>(); | 3603 List<String> list = new List<String>(); |
| 3605 list.add("a"); | 3604 list.add("a"); |
| 3606 List<String> elements = []; | 3605 List<String> elements = []; |
| 3607 ListUtilities.addAll(list, elements); | 3606 ListUtilities.addAll(list, elements); |
| 3608 JUnitTestCase.assertEquals(1, list.length); | 3607 expect(list.length, 1); |
| 3609 } | 3608 } |
| 3610 | 3609 |
| 3611 void test_addAll_nonEmptyToEmpty() { | 3610 void test_addAll_nonEmptyToEmpty() { |
| 3612 List<String> list = new List<String>(); | 3611 List<String> list = new List<String>(); |
| 3613 List<String> elements = ["b", "c"]; | 3612 List<String> elements = ["b", "c"]; |
| 3614 ListUtilities.addAll(list, elements); | 3613 ListUtilities.addAll(list, elements); |
| 3615 JUnitTestCase.assertEquals(2, list.length); | 3614 expect(list.length, 2); |
| 3616 } | 3615 } |
| 3617 | 3616 |
| 3618 void test_addAll_nonEmptyToNonEmpty() { | 3617 void test_addAll_nonEmptyToNonEmpty() { |
| 3619 List<String> list = new List<String>(); | 3618 List<String> list = new List<String>(); |
| 3620 list.add("a"); | 3619 list.add("a"); |
| 3621 List<String> elements = ["b", "c"]; | 3620 List<String> elements = ["b", "c"]; |
| 3622 ListUtilities.addAll(list, elements); | 3621 ListUtilities.addAll(list, elements); |
| 3623 JUnitTestCase.assertEquals(3, list.length); | 3622 expect(list.length, 3); |
| 3624 } | 3623 } |
| 3625 } | 3624 } |
| 3626 | 3625 |
| 3627 class MultipleMapIteratorTest extends EngineTestCase { | 3626 class MultipleMapIteratorTest extends EngineTestCase { |
| 3628 void test_multipleMaps_firstEmpty() { | 3627 void test_multipleMaps_firstEmpty() { |
| 3629 Map<String, String> map1 = new HashMap<String, String>(); | 3628 Map<String, String> map1 = new HashMap<String, String>(); |
| 3630 Map<String, String> map2 = new HashMap<String, String>(); | 3629 Map<String, String> map2 = new HashMap<String, String>(); |
| 3631 map2["k2"] = "v2"; | 3630 map2["k2"] = "v2"; |
| 3632 Map<String, String> map3 = new HashMap<String, String>(); | 3631 Map<String, String> map3 = new HashMap<String, String>(); |
| 3633 map3["k3"] = "v3"; | 3632 map3["k3"] = "v3"; |
| 3634 MultipleMapIterator<String, String> iterator = | 3633 MultipleMapIterator<String, String> iterator = |
| 3635 _iterator([map1, map2, map3]); | 3634 _iterator([map1, map2, map3]); |
| 3636 JUnitTestCase.assertTrue(iterator.moveNext()); | 3635 expect(iterator.moveNext(), isTrue); |
| 3637 JUnitTestCase.assertTrue(iterator.moveNext()); | 3636 expect(iterator.moveNext(), isTrue); |
| 3638 JUnitTestCase.assertFalse(iterator.moveNext()); | 3637 expect(iterator.moveNext(), isFalse); |
| 3639 } | 3638 } |
| 3640 | 3639 |
| 3641 void test_multipleMaps_lastEmpty() { | 3640 void test_multipleMaps_lastEmpty() { |
| 3642 Map<String, String> map1 = new HashMap<String, String>(); | 3641 Map<String, String> map1 = new HashMap<String, String>(); |
| 3643 map1["k1"] = "v1"; | 3642 map1["k1"] = "v1"; |
| 3644 Map<String, String> map2 = new HashMap<String, String>(); | 3643 Map<String, String> map2 = new HashMap<String, String>(); |
| 3645 map2["k2"] = "v2"; | 3644 map2["k2"] = "v2"; |
| 3646 Map<String, String> map3 = new HashMap<String, String>(); | 3645 Map<String, String> map3 = new HashMap<String, String>(); |
| 3647 MultipleMapIterator<String, String> iterator = | 3646 MultipleMapIterator<String, String> iterator = |
| 3648 _iterator([map1, map2, map3]); | 3647 _iterator([map1, map2, map3]); |
| 3649 JUnitTestCase.assertTrue(iterator.moveNext()); | 3648 expect(iterator.moveNext(), isTrue); |
| 3650 JUnitTestCase.assertTrue(iterator.moveNext()); | 3649 expect(iterator.moveNext(), isTrue); |
| 3651 JUnitTestCase.assertFalse(iterator.moveNext()); | 3650 expect(iterator.moveNext(), isFalse); |
| 3652 } | 3651 } |
| 3653 | 3652 |
| 3654 void test_multipleMaps_middleEmpty() { | 3653 void test_multipleMaps_middleEmpty() { |
| 3655 Map<String, String> map1 = new HashMap<String, String>(); | 3654 Map<String, String> map1 = new HashMap<String, String>(); |
| 3656 map1["k1"] = "v1"; | 3655 map1["k1"] = "v1"; |
| 3657 Map<String, String> map2 = new HashMap<String, String>(); | 3656 Map<String, String> map2 = new HashMap<String, String>(); |
| 3658 Map<String, String> map3 = new HashMap<String, String>(); | 3657 Map<String, String> map3 = new HashMap<String, String>(); |
| 3659 map3["k3"] = "v3"; | 3658 map3["k3"] = "v3"; |
| 3660 MultipleMapIterator<String, String> iterator = | 3659 MultipleMapIterator<String, String> iterator = |
| 3661 _iterator([map1, map2, map3]); | 3660 _iterator([map1, map2, map3]); |
| 3662 JUnitTestCase.assertTrue(iterator.moveNext()); | 3661 expect(iterator.moveNext(), isTrue); |
| 3663 JUnitTestCase.assertTrue(iterator.moveNext()); | 3662 expect(iterator.moveNext(), isTrue); |
| 3664 JUnitTestCase.assertFalse(iterator.moveNext()); | 3663 expect(iterator.moveNext(), isFalse); |
| 3665 } | 3664 } |
| 3666 | 3665 |
| 3667 void test_multipleMaps_nonEmpty() { | 3666 void test_multipleMaps_nonEmpty() { |
| 3668 Map<String, String> map1 = new HashMap<String, String>(); | 3667 Map<String, String> map1 = new HashMap<String, String>(); |
| 3669 map1["k1"] = "v1"; | 3668 map1["k1"] = "v1"; |
| 3670 Map<String, String> map2 = new HashMap<String, String>(); | 3669 Map<String, String> map2 = new HashMap<String, String>(); |
| 3671 map2["k2"] = "v2"; | 3670 map2["k2"] = "v2"; |
| 3672 Map<String, String> map3 = new HashMap<String, String>(); | 3671 Map<String, String> map3 = new HashMap<String, String>(); |
| 3673 map3["k3"] = "v3"; | 3672 map3["k3"] = "v3"; |
| 3674 MultipleMapIterator<String, String> iterator = | 3673 MultipleMapIterator<String, String> iterator = |
| 3675 _iterator([map1, map2, map3]); | 3674 _iterator([map1, map2, map3]); |
| 3676 JUnitTestCase.assertTrue(iterator.moveNext()); | 3675 expect(iterator.moveNext(), isTrue); |
| 3677 JUnitTestCase.assertTrue(iterator.moveNext()); | 3676 expect(iterator.moveNext(), isTrue); |
| 3678 JUnitTestCase.assertTrue(iterator.moveNext()); | 3677 expect(iterator.moveNext(), isTrue); |
| 3679 JUnitTestCase.assertFalse(iterator.moveNext()); | 3678 expect(iterator.moveNext(), isFalse); |
| 3680 } | 3679 } |
| 3681 | 3680 |
| 3682 void test_noMap() { | 3681 void test_noMap() { |
| 3683 MultipleMapIterator<String, String> iterator = _iterator([]); | 3682 MultipleMapIterator<String, String> iterator = _iterator([]); |
| 3684 JUnitTestCase.assertFalse(iterator.moveNext()); | 3683 expect(iterator.moveNext(), isFalse); |
| 3685 JUnitTestCase.assertFalse(iterator.moveNext()); | 3684 expect(iterator.moveNext(), isFalse); |
| 3686 } | 3685 } |
| 3687 | 3686 |
| 3688 void test_singleMap_empty() { | 3687 void test_singleMap_empty() { |
| 3689 Map<String, String> map = new HashMap<String, String>(); | 3688 Map<String, String> map = new HashMap<String, String>(); |
| 3690 MultipleMapIterator<String, String> iterator = _iterator(<Map>[map]); | 3689 MultipleMapIterator<String, String> iterator = _iterator(<Map>[map]); |
| 3691 JUnitTestCase.assertFalse(iterator.moveNext()); | 3690 expect(iterator.moveNext(), isFalse); |
| 3692 try { | 3691 try { |
| 3693 iterator.key; | 3692 iterator.key; |
| 3694 JUnitTestCase.fail("Expected NoSuchElementException"); | 3693 fail("Expected NoSuchElementException"); |
| 3695 } on NoSuchElementException catch (exception) { | 3694 } on NoSuchElementException catch (exception) { |
| 3696 // Expected | 3695 // Expected |
| 3697 } | 3696 } |
| 3698 try { | 3697 try { |
| 3699 iterator.value; | 3698 iterator.value; |
| 3700 JUnitTestCase.fail("Expected NoSuchElementException"); | 3699 fail("Expected NoSuchElementException"); |
| 3701 } on NoSuchElementException catch (exception) { | 3700 } on NoSuchElementException catch (exception) { |
| 3702 // Expected | 3701 // Expected |
| 3703 } | 3702 } |
| 3704 try { | 3703 try { |
| 3705 iterator.value = "x"; | 3704 iterator.value = "x"; |
| 3706 JUnitTestCase.fail("Expected NoSuchElementException"); | 3705 fail("Expected NoSuchElementException"); |
| 3707 } on NoSuchElementException catch (exception) { | 3706 } on NoSuchElementException catch (exception) { |
| 3708 // Expected | 3707 // Expected |
| 3709 } | 3708 } |
| 3710 } | 3709 } |
| 3711 | 3710 |
| 3712 void test_singleMap_multiple() { | 3711 void test_singleMap_multiple() { |
| 3713 Map<String, String> map = new HashMap<String, String>(); | 3712 Map<String, String> map = new HashMap<String, String>(); |
| 3714 map["k1"] = "v1"; | 3713 map["k1"] = "v1"; |
| 3715 map["k2"] = "v2"; | 3714 map["k2"] = "v2"; |
| 3716 map["k3"] = "v3"; | 3715 map["k3"] = "v3"; |
| 3717 MultipleMapIterator<String, String> iterator = _iterator([map]); | 3716 MultipleMapIterator<String, String> iterator = _iterator([map]); |
| 3718 JUnitTestCase.assertTrue(iterator.moveNext()); | 3717 expect(iterator.moveNext(), isTrue); |
| 3719 JUnitTestCase.assertTrue(iterator.moveNext()); | 3718 expect(iterator.moveNext(), isTrue); |
| 3720 JUnitTestCase.assertTrue(iterator.moveNext()); | 3719 expect(iterator.moveNext(), isTrue); |
| 3721 JUnitTestCase.assertFalse(iterator.moveNext()); | 3720 expect(iterator.moveNext(), isFalse); |
| 3722 } | 3721 } |
| 3723 | 3722 |
| 3724 void test_singleMap_single() { | 3723 void test_singleMap_single() { |
| 3725 String key = "key"; | 3724 String key = "key"; |
| 3726 String value = "value"; | 3725 String value = "value"; |
| 3727 Map<String, String> map = new HashMap<String, String>(); | 3726 Map<String, String> map = new HashMap<String, String>(); |
| 3728 map[key] = value; | 3727 map[key] = value; |
| 3729 MultipleMapIterator<String, String> iterator = _iterator([map]); | 3728 MultipleMapIterator<String, String> iterator = _iterator([map]); |
| 3730 JUnitTestCase.assertTrue(iterator.moveNext()); | 3729 expect(iterator.moveNext(), isTrue); |
| 3731 JUnitTestCase.assertSame(key, iterator.key); | 3730 expect(iterator.key, same(key)); |
| 3732 JUnitTestCase.assertSame(value, iterator.value); | 3731 expect(iterator.value, same(value)); |
| 3733 String newValue = "newValue"; | 3732 String newValue = "newValue"; |
| 3734 iterator.value = newValue; | 3733 iterator.value = newValue; |
| 3735 JUnitTestCase.assertSame(newValue, iterator.value); | 3734 expect(iterator.value, same(newValue)); |
| 3736 JUnitTestCase.assertFalse(iterator.moveNext()); | 3735 expect(iterator.moveNext(), isFalse); |
| 3737 } | 3736 } |
| 3738 | 3737 |
| 3739 MultipleMapIterator<String, String> _iterator(List<Map> maps) { | 3738 MultipleMapIterator<String, String> _iterator(List<Map> maps) { |
| 3740 return new MultipleMapIterator<String, String>(maps); | 3739 return new MultipleMapIterator<String, String>(maps); |
| 3741 } | 3740 } |
| 3742 } | 3741 } |
| 3743 | 3742 |
| 3744 class NodeReplacerTest extends EngineTestCase { | 3743 class NodeReplacerTest extends EngineTestCase { |
| 3745 void test_adjacentStrings() { | 3744 void test_adjacentStrings() { |
| 3746 AdjacentStrings node = | 3745 AdjacentStrings node = |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4741 void test_withClause() { | 4740 void test_withClause() { |
| 4742 WithClause node = AstFactory.withClause([AstFactory.typeName4("M", [])]); | 4741 WithClause node = AstFactory.withClause([AstFactory.typeName4("M", [])]); |
| 4743 _assertReplace(node, new ListGetter_NodeReplacerTest_test_withClause(0)); | 4742 _assertReplace(node, new ListGetter_NodeReplacerTest_test_withClause(0)); |
| 4744 } | 4743 } |
| 4745 | 4744 |
| 4746 void _assertReplace(AstNode parent, NodeReplacerTest_Getter getter) { | 4745 void _assertReplace(AstNode parent, NodeReplacerTest_Getter getter) { |
| 4747 AstNode child = getter.get(parent); | 4746 AstNode child = getter.get(parent); |
| 4748 if (child != null) { | 4747 if (child != null) { |
| 4749 AstNode clone = child.accept(new AstCloner()); | 4748 AstNode clone = child.accept(new AstCloner()); |
| 4750 NodeReplacer.replace(child, clone); | 4749 NodeReplacer.replace(child, clone); |
| 4751 JUnitTestCase.assertEquals(clone, getter.get(parent)); | 4750 expect(getter.get(parent), clone); |
| 4752 JUnitTestCase.assertEquals(parent, clone.parent); | 4751 expect(clone.parent, parent); |
| 4753 } | 4752 } |
| 4754 } | 4753 } |
| 4755 | 4754 |
| 4756 void _testAnnotatedNode(AnnotatedNode node) { | 4755 void _testAnnotatedNode(AnnotatedNode node) { |
| 4757 _assertReplace(node, new Getter_NodeReplacerTest_testAnnotatedNode()); | 4756 _assertReplace(node, new Getter_NodeReplacerTest_testAnnotatedNode()); |
| 4758 _assertReplace(node, new ListGetter_NodeReplacerTest_testAnnotatedNode(0)); | 4757 _assertReplace(node, new ListGetter_NodeReplacerTest_testAnnotatedNode(0)); |
| 4759 } | 4758 } |
| 4760 | 4759 |
| 4761 void _testNamespaceDirective(NamespaceDirective node) { | 4760 void _testNamespaceDirective(NamespaceDirective node) { |
| 4762 _assertReplace( | 4761 _assertReplace( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4812 } | 4811 } |
| 4813 | 4812 |
| 4814 NodeList<C> getList(P parent); | 4813 NodeList<C> getList(P parent); |
| 4815 } | 4814 } |
| 4816 | 4815 |
| 4817 class SingleMapIteratorTest extends EngineTestCase { | 4816 class SingleMapIteratorTest extends EngineTestCase { |
| 4818 void test_empty() { | 4817 void test_empty() { |
| 4819 Map<String, String> map = new HashMap<String, String>(); | 4818 Map<String, String> map = new HashMap<String, String>(); |
| 4820 SingleMapIterator<String, String> iterator = | 4819 SingleMapIterator<String, String> iterator = |
| 4821 new SingleMapIterator<String, String>(map); | 4820 new SingleMapIterator<String, String>(map); |
| 4822 JUnitTestCase.assertFalse(iterator.moveNext()); | 4821 expect(iterator.moveNext(), isFalse); |
| 4823 try { | 4822 try { |
| 4824 iterator.key; | 4823 iterator.key; |
| 4825 JUnitTestCase.fail("Expected NoSuchElementException"); | 4824 fail("Expected NoSuchElementException"); |
| 4826 } on NoSuchElementException catch (exception) { | 4825 } on NoSuchElementException catch (exception) { |
| 4827 // Expected | 4826 // Expected |
| 4828 } | 4827 } |
| 4829 try { | 4828 try { |
| 4830 iterator.value; | 4829 iterator.value; |
| 4831 JUnitTestCase.fail("Expected NoSuchElementException"); | 4830 fail("Expected NoSuchElementException"); |
| 4832 } on NoSuchElementException catch (exception) { | 4831 } on NoSuchElementException catch (exception) { |
| 4833 // Expected | 4832 // Expected |
| 4834 } | 4833 } |
| 4835 try { | 4834 try { |
| 4836 iterator.value = "x"; | 4835 iterator.value = "x"; |
| 4837 JUnitTestCase.fail("Expected NoSuchElementException"); | 4836 fail("Expected NoSuchElementException"); |
| 4838 } on NoSuchElementException catch (exception) { | 4837 } on NoSuchElementException catch (exception) { |
| 4839 // Expected | 4838 // Expected |
| 4840 } | 4839 } |
| 4841 JUnitTestCase.assertFalse(iterator.moveNext()); | 4840 expect(iterator.moveNext(), isFalse); |
| 4842 } | 4841 } |
| 4843 | 4842 |
| 4844 void test_multiple() { | 4843 void test_multiple() { |
| 4845 Map<String, String> map = new HashMap<String, String>(); | 4844 Map<String, String> map = new HashMap<String, String>(); |
| 4846 map["k1"] = "v1"; | 4845 map["k1"] = "v1"; |
| 4847 map["k2"] = "v2"; | 4846 map["k2"] = "v2"; |
| 4848 map["k3"] = "v3"; | 4847 map["k3"] = "v3"; |
| 4849 SingleMapIterator<String, String> iterator = | 4848 SingleMapIterator<String, String> iterator = |
| 4850 new SingleMapIterator<String, String>(map); | 4849 new SingleMapIterator<String, String>(map); |
| 4851 JUnitTestCase.assertTrue(iterator.moveNext()); | 4850 expect(iterator.moveNext(), isTrue); |
| 4852 JUnitTestCase.assertTrue(iterator.moveNext()); | 4851 expect(iterator.moveNext(), isTrue); |
| 4853 JUnitTestCase.assertTrue(iterator.moveNext()); | 4852 expect(iterator.moveNext(), isTrue); |
| 4854 JUnitTestCase.assertFalse(iterator.moveNext()); | 4853 expect(iterator.moveNext(), isFalse); |
| 4855 } | 4854 } |
| 4856 | 4855 |
| 4857 void test_single() { | 4856 void test_single() { |
| 4858 String key = "key"; | 4857 String key = "key"; |
| 4859 String value = "value"; | 4858 String value = "value"; |
| 4860 Map<String, String> map = new HashMap<String, String>(); | 4859 Map<String, String> map = new HashMap<String, String>(); |
| 4861 map[key] = value; | 4860 map[key] = value; |
| 4862 SingleMapIterator<String, String> iterator = | 4861 SingleMapIterator<String, String> iterator = |
| 4863 new SingleMapIterator<String, String>(map); | 4862 new SingleMapIterator<String, String>(map); |
| 4864 JUnitTestCase.assertTrue(iterator.moveNext()); | 4863 expect(iterator.moveNext(), isTrue); |
| 4865 JUnitTestCase.assertSame(key, iterator.key); | 4864 expect(iterator.key, same(key)); |
| 4866 JUnitTestCase.assertSame(value, iterator.value); | 4865 expect(iterator.value, same(value)); |
| 4867 String newValue = "newValue"; | 4866 String newValue = "newValue"; |
| 4868 iterator.value = newValue; | 4867 iterator.value = newValue; |
| 4869 JUnitTestCase.assertSame(newValue, iterator.value); | 4868 expect(iterator.value, same(newValue)); |
| 4870 JUnitTestCase.assertFalse(iterator.moveNext()); | 4869 expect(iterator.moveNext(), isFalse); |
| 4871 } | 4870 } |
| 4872 } | 4871 } |
| 4873 | 4872 |
| 4874 class SourceRangeTest extends JUnitTestCase { | 4873 class SourceRangeTest { |
| 4875 void test_access() { | 4874 void test_access() { |
| 4876 SourceRange r = new SourceRange(10, 1); | 4875 SourceRange r = new SourceRange(10, 1); |
| 4877 JUnitTestCase.assertEquals(10, r.offset); | 4876 expect(r.offset, 10); |
| 4878 JUnitTestCase.assertEquals(1, r.length); | 4877 expect(r.length, 1); |
| 4879 JUnitTestCase.assertEquals(10 + 1, r.end); | 4878 expect(r.end, 10 + 1); |
| 4880 // to check | 4879 // to check |
| 4881 r.hashCode; | 4880 r.hashCode; |
| 4882 } | 4881 } |
| 4883 | 4882 |
| 4884 void test_contains() { | 4883 void test_contains() { |
| 4885 SourceRange r = new SourceRange(5, 10); | 4884 SourceRange r = new SourceRange(5, 10); |
| 4886 JUnitTestCase.assertTrue(r.contains(5)); | 4885 expect(r.contains(5), isTrue); |
| 4887 JUnitTestCase.assertTrue(r.contains(10)); | 4886 expect(r.contains(10), isTrue); |
| 4888 JUnitTestCase.assertTrue(r.contains(14)); | 4887 expect(r.contains(14), isTrue); |
| 4889 JUnitTestCase.assertFalse(r.contains(0)); | 4888 expect(r.contains(0), isFalse); |
| 4890 JUnitTestCase.assertFalse(r.contains(15)); | 4889 expect(r.contains(15), isFalse); |
| 4891 } | 4890 } |
| 4892 | 4891 |
| 4893 void test_containsExclusive() { | 4892 void test_containsExclusive() { |
| 4894 SourceRange r = new SourceRange(5, 10); | 4893 SourceRange r = new SourceRange(5, 10); |
| 4895 JUnitTestCase.assertFalse(r.containsExclusive(5)); | 4894 expect(r.containsExclusive(5), isFalse); |
| 4896 JUnitTestCase.assertTrue(r.containsExclusive(10)); | 4895 expect(r.containsExclusive(10), isTrue); |
| 4897 JUnitTestCase.assertTrue(r.containsExclusive(14)); | 4896 expect(r.containsExclusive(14), isTrue); |
| 4898 JUnitTestCase.assertFalse(r.containsExclusive(0)); | 4897 expect(r.containsExclusive(0), isFalse); |
| 4899 JUnitTestCase.assertFalse(r.containsExclusive(15)); | 4898 expect(r.containsExclusive(15), isFalse); |
| 4900 } | 4899 } |
| 4901 | 4900 |
| 4902 void test_coveredBy() { | 4901 void test_coveredBy() { |
| 4903 SourceRange r = new SourceRange(5, 10); | 4902 SourceRange r = new SourceRange(5, 10); |
| 4904 // ends before | 4903 // ends before |
| 4905 JUnitTestCase.assertFalse(r.coveredBy(new SourceRange(20, 10))); | 4904 expect(r.coveredBy(new SourceRange(20, 10)), isFalse); |
| 4906 // starts after | 4905 // starts after |
| 4907 JUnitTestCase.assertFalse(r.coveredBy(new SourceRange(0, 3))); | 4906 expect(r.coveredBy(new SourceRange(0, 3)), isFalse); |
| 4908 // only intersects | 4907 // only intersects |
| 4909 JUnitTestCase.assertFalse(r.coveredBy(new SourceRange(0, 10))); | 4908 expect(r.coveredBy(new SourceRange(0, 10)), isFalse); |
| 4910 JUnitTestCase.assertFalse(r.coveredBy(new SourceRange(10, 10))); | 4909 expect(r.coveredBy(new SourceRange(10, 10)), isFalse); |
| 4911 // covered | 4910 // covered |
| 4912 JUnitTestCase.assertTrue(r.coveredBy(new SourceRange(0, 20))); | 4911 expect(r.coveredBy(new SourceRange(0, 20)), isTrue); |
| 4913 JUnitTestCase.assertTrue(r.coveredBy(new SourceRange(5, 10))); | 4912 expect(r.coveredBy(new SourceRange(5, 10)), isTrue); |
| 4914 } | 4913 } |
| 4915 | 4914 |
| 4916 void test_covers() { | 4915 void test_covers() { |
| 4917 SourceRange r = new SourceRange(5, 10); | 4916 SourceRange r = new SourceRange(5, 10); |
| 4918 // ends before | 4917 // ends before |
| 4919 JUnitTestCase.assertFalse(r.covers(new SourceRange(0, 3))); | 4918 expect(r.covers(new SourceRange(0, 3)), isFalse); |
| 4920 // starts after | 4919 // starts after |
| 4921 JUnitTestCase.assertFalse(r.covers(new SourceRange(20, 3))); | 4920 expect(r.covers(new SourceRange(20, 3)), isFalse); |
| 4922 // only intersects | 4921 // only intersects |
| 4923 JUnitTestCase.assertFalse(r.covers(new SourceRange(0, 10))); | 4922 expect(r.covers(new SourceRange(0, 10)), isFalse); |
| 4924 JUnitTestCase.assertFalse(r.covers(new SourceRange(10, 10))); | 4923 expect(r.covers(new SourceRange(10, 10)), isFalse); |
| 4925 // covers | 4924 // covers |
| 4926 JUnitTestCase.assertTrue(r.covers(new SourceRange(5, 10))); | 4925 expect(r.covers(new SourceRange(5, 10)), isTrue); |
| 4927 JUnitTestCase.assertTrue(r.covers(new SourceRange(6, 9))); | 4926 expect(r.covers(new SourceRange(6, 9)), isTrue); |
| 4928 JUnitTestCase.assertTrue(r.covers(new SourceRange(6, 8))); | 4927 expect(r.covers(new SourceRange(6, 8)), isTrue); |
| 4929 } | 4928 } |
| 4930 | 4929 |
| 4931 void test_endsIn() { | 4930 void test_endsIn() { |
| 4932 SourceRange r = new SourceRange(5, 10); | 4931 SourceRange r = new SourceRange(5, 10); |
| 4933 // ends before | 4932 // ends before |
| 4934 JUnitTestCase.assertFalse(r.endsIn(new SourceRange(20, 10))); | 4933 expect(r.endsIn(new SourceRange(20, 10)), isFalse); |
| 4935 // starts after | 4934 // starts after |
| 4936 JUnitTestCase.assertFalse(r.endsIn(new SourceRange(0, 3))); | 4935 expect(r.endsIn(new SourceRange(0, 3)), isFalse); |
| 4937 // ends | 4936 // ends |
| 4938 JUnitTestCase.assertTrue(r.endsIn(new SourceRange(10, 20))); | 4937 expect(r.endsIn(new SourceRange(10, 20)), isTrue); |
| 4939 JUnitTestCase.assertTrue(r.endsIn(new SourceRange(0, 20))); | 4938 expect(r.endsIn(new SourceRange(0, 20)), isTrue); |
| 4940 } | 4939 } |
| 4941 | 4940 |
| 4942 void test_equals() { | 4941 void test_equals() { |
| 4943 SourceRange r = new SourceRange(10, 1); | 4942 SourceRange r = new SourceRange(10, 1); |
| 4944 JUnitTestCase.assertFalse(r == null); | 4943 expect(r == null, isFalse); |
| 4945 JUnitTestCase.assertFalse(r == this); | 4944 expect(r == this, isFalse); |
| 4946 JUnitTestCase.assertFalse(r == new SourceRange(20, 2)); | 4945 expect(r == new SourceRange(20, 2), isFalse); |
| 4947 JUnitTestCase.assertTrue(r == new SourceRange(10, 1)); | 4946 expect(r == new SourceRange(10, 1), isTrue); |
| 4948 JUnitTestCase.assertTrue(r == r); | 4947 expect(r == r, isTrue); |
| 4949 } | 4948 } |
| 4950 | 4949 |
| 4951 void test_getExpanded() { | 4950 void test_getExpanded() { |
| 4952 SourceRange r = new SourceRange(5, 3); | 4951 SourceRange r = new SourceRange(5, 3); |
| 4953 JUnitTestCase.assertEquals(r, r.getExpanded(0)); | 4952 expect(r.getExpanded(0), r); |
| 4954 JUnitTestCase.assertEquals(new SourceRange(3, 7), r.getExpanded(2)); | 4953 expect(r.getExpanded(2), new SourceRange(3, 7)); |
| 4955 JUnitTestCase.assertEquals(new SourceRange(6, 1), r.getExpanded(-1)); | 4954 expect(r.getExpanded(-1), new SourceRange(6, 1)); |
| 4956 } | 4955 } |
| 4957 | 4956 |
| 4958 void test_getMoveEnd() { | 4957 void test_getMoveEnd() { |
| 4959 SourceRange r = new SourceRange(5, 3); | 4958 SourceRange r = new SourceRange(5, 3); |
| 4960 JUnitTestCase.assertEquals(r, r.getMoveEnd(0)); | 4959 expect(r.getMoveEnd(0), r); |
| 4961 JUnitTestCase.assertEquals(new SourceRange(5, 6), r.getMoveEnd(3)); | 4960 expect(r.getMoveEnd(3), new SourceRange(5, 6)); |
| 4962 JUnitTestCase.assertEquals(new SourceRange(5, 2), r.getMoveEnd(-1)); | 4961 expect(r.getMoveEnd(-1), new SourceRange(5, 2)); |
| 4963 } | 4962 } |
| 4964 | 4963 |
| 4965 void test_getTranslated() { | 4964 void test_getTranslated() { |
| 4966 SourceRange r = new SourceRange(5, 3); | 4965 SourceRange r = new SourceRange(5, 3); |
| 4967 JUnitTestCase.assertEquals(r, r.getTranslated(0)); | 4966 expect(r.getTranslated(0), r); |
| 4968 JUnitTestCase.assertEquals(new SourceRange(7, 3), r.getTranslated(2)); | 4967 expect(r.getTranslated(2), new SourceRange(7, 3)); |
| 4969 JUnitTestCase.assertEquals(new SourceRange(4, 3), r.getTranslated(-1)); | 4968 expect(r.getTranslated(-1), new SourceRange(4, 3)); |
| 4970 } | 4969 } |
| 4971 | 4970 |
| 4972 void test_getUnion() { | 4971 void test_getUnion() { |
| 4973 JUnitTestCase.assertEquals( | 4972 expect(new SourceRange(10, 10).getUnion(new SourceRange(15, 10)), new Source Range(10, 15)); |
| 4974 new SourceRange(10, 15), | 4973 expect(new SourceRange(15, 10).getUnion(new SourceRange(10, 10)), new Source Range(10, 15)); |
| 4975 new SourceRange(10, 10).getUnion(new SourceRange(15, 10))); | |
| 4976 JUnitTestCase.assertEquals( | |
| 4977 new SourceRange(10, 15), | |
| 4978 new SourceRange(15, 10).getUnion(new SourceRange(10, 10))); | |
| 4979 // "other" is covered/covers | 4974 // "other" is covered/covers |
| 4980 JUnitTestCase.assertEquals( | 4975 expect(new SourceRange(10, 10).getUnion(new SourceRange(15, 2)), new SourceR ange(10, 10)); |
| 4981 new SourceRange(10, 10), | 4976 expect(new SourceRange(15, 2).getUnion(new SourceRange(10, 10)), new SourceR ange(10, 10)); |
| 4982 new SourceRange(10, 10).getUnion(new SourceRange(15, 2))); | |
| 4983 JUnitTestCase.assertEquals( | |
| 4984 new SourceRange(10, 10), | |
| 4985 new SourceRange(15, 2).getUnion(new SourceRange(10, 10))); | |
| 4986 } | 4977 } |
| 4987 | 4978 |
| 4988 void test_intersects() { | 4979 void test_intersects() { |
| 4989 SourceRange r = new SourceRange(5, 3); | 4980 SourceRange r = new SourceRange(5, 3); |
| 4990 // null | 4981 // null |
| 4991 JUnitTestCase.assertFalse(r.intersects(null)); | 4982 expect(r.intersects(null), isFalse); |
| 4992 // ends before | 4983 // ends before |
| 4993 JUnitTestCase.assertFalse(r.intersects(new SourceRange(0, 5))); | 4984 expect(r.intersects(new SourceRange(0, 5)), isFalse); |
| 4994 // begins after | 4985 // begins after |
| 4995 JUnitTestCase.assertFalse(r.intersects(new SourceRange(8, 5))); | 4986 expect(r.intersects(new SourceRange(8, 5)), isFalse); |
| 4996 // begins on same offset | 4987 // begins on same offset |
| 4997 JUnitTestCase.assertTrue(r.intersects(new SourceRange(5, 1))); | 4988 expect(r.intersects(new SourceRange(5, 1)), isTrue); |
| 4998 // begins inside, ends inside | 4989 // begins inside, ends inside |
| 4999 JUnitTestCase.assertTrue(r.intersects(new SourceRange(6, 1))); | 4990 expect(r.intersects(new SourceRange(6, 1)), isTrue); |
| 5000 // begins inside, ends after | 4991 // begins inside, ends after |
| 5001 JUnitTestCase.assertTrue(r.intersects(new SourceRange(6, 10))); | 4992 expect(r.intersects(new SourceRange(6, 10)), isTrue); |
| 5002 // begins before, ends after | 4993 // begins before, ends after |
| 5003 JUnitTestCase.assertTrue(r.intersects(new SourceRange(0, 10))); | 4994 expect(r.intersects(new SourceRange(0, 10)), isTrue); |
| 5004 } | 4995 } |
| 5005 | 4996 |
| 5006 void test_startsIn() { | 4997 void test_startsIn() { |
| 5007 SourceRange r = new SourceRange(5, 10); | 4998 SourceRange r = new SourceRange(5, 10); |
| 5008 // ends before | 4999 // ends before |
| 5009 JUnitTestCase.assertFalse(r.startsIn(new SourceRange(20, 10))); | 5000 expect(r.startsIn(new SourceRange(20, 10)), isFalse); |
| 5010 // starts after | 5001 // starts after |
| 5011 JUnitTestCase.assertFalse(r.startsIn(new SourceRange(0, 3))); | 5002 expect(r.startsIn(new SourceRange(0, 3)), isFalse); |
| 5012 // starts | 5003 // starts |
| 5013 JUnitTestCase.assertTrue(r.startsIn(new SourceRange(5, 1))); | 5004 expect(r.startsIn(new SourceRange(5, 1)), isTrue); |
| 5014 JUnitTestCase.assertTrue(r.startsIn(new SourceRange(0, 20))); | 5005 expect(r.startsIn(new SourceRange(0, 20)), isTrue); |
| 5015 } | 5006 } |
| 5016 | 5007 |
| 5017 void test_toString() { | 5008 void test_toString() { |
| 5018 SourceRange r = new SourceRange(10, 1); | 5009 SourceRange r = new SourceRange(10, 1); |
| 5019 JUnitTestCase.assertEquals("[offset=10, length=1]", r.toString()); | 5010 expect(r.toString(), "[offset=10, length=1]"); |
| 5020 } | 5011 } |
| 5021 } | 5012 } |
| 5022 | 5013 |
| 5023 class StringUtilitiesTest extends JUnitTestCase { | 5014 class StringUtilitiesTest { |
| 5024 void test_EMPTY() { | 5015 void test_EMPTY() { |
| 5025 JUnitTestCase.assertEquals("", StringUtilities.EMPTY); | 5016 expect(StringUtilities.EMPTY, ""); |
| 5026 JUnitTestCase.assertTrue(StringUtilities.EMPTY.isEmpty); | 5017 expect(StringUtilities.EMPTY.isEmpty, isTrue); |
| 5027 } | 5018 } |
| 5028 | 5019 |
| 5029 void test_EMPTY_ARRAY() { | 5020 void test_EMPTY_ARRAY() { |
| 5030 JUnitTestCase.assertEquals(0, StringUtilities.EMPTY_ARRAY.length); | 5021 expect(StringUtilities.EMPTY_ARRAY.length, 0); |
| 5031 } | 5022 } |
| 5032 | 5023 |
| 5033 void test_endsWith3() { | 5024 void test_endsWith3() { |
| 5034 JUnitTestCase.assertTrue( | 5025 expect(StringUtilities.endsWith3("abc", 0x61, 0x62, 0x63), isTrue); |
| 5035 StringUtilities.endsWith3("abc", 0x61, 0x62, 0x63)); | 5026 expect(StringUtilities.endsWith3("abcdefghi", 0x67, 0x68, 0x69), isTrue); |
| 5036 JUnitTestCase.assertTrue( | 5027 expect(StringUtilities.endsWith3("abcdefghi", 0x64, 0x65, 0x61), isFalse); |
| 5037 StringUtilities.endsWith3("abcdefghi", 0x67, 0x68, 0x69)); | |
| 5038 JUnitTestCase.assertFalse( | |
| 5039 StringUtilities.endsWith3("abcdefghi", 0x64, 0x65, 0x61)); | |
| 5040 // missing | 5028 // missing |
| 5041 } | 5029 } |
| 5042 | 5030 |
| 5043 void test_endsWithChar() { | 5031 void test_endsWithChar() { |
| 5044 JUnitTestCase.assertTrue(StringUtilities.endsWithChar("a", 0x61)); | 5032 expect(StringUtilities.endsWithChar("a", 0x61), isTrue); |
| 5045 JUnitTestCase.assertFalse(StringUtilities.endsWithChar("b", 0x61)); | 5033 expect(StringUtilities.endsWithChar("b", 0x61), isFalse); |
| 5046 JUnitTestCase.assertFalse(StringUtilities.endsWithChar("", 0x61)); | 5034 expect(StringUtilities.endsWithChar("", 0x61), isFalse); |
| 5047 } | 5035 } |
| 5048 | 5036 |
| 5049 void test_indexOf1() { | 5037 void test_indexOf1() { |
| 5050 JUnitTestCase.assertEquals(0, StringUtilities.indexOf1("a", 0, 0x61)); | 5038 expect(StringUtilities.indexOf1("a", 0, 0x61), 0); |
| 5051 JUnitTestCase.assertEquals(0, StringUtilities.indexOf1("abcdef", 0, 0x61)); | 5039 expect(StringUtilities.indexOf1("abcdef", 0, 0x61), 0); |
| 5052 JUnitTestCase.assertEquals(2, StringUtilities.indexOf1("abcdef", 0, 0x63)); | 5040 expect(StringUtilities.indexOf1("abcdef", 0, 0x63), 2); |
| 5053 JUnitTestCase.assertEquals(5, StringUtilities.indexOf1("abcdef", 0, 0x66)); | 5041 expect(StringUtilities.indexOf1("abcdef", 0, 0x66), 5); |
| 5054 JUnitTestCase.assertEquals(-1, StringUtilities.indexOf1("abcdef", 0, 0x7A)); | 5042 expect(StringUtilities.indexOf1("abcdef", 0, 0x7A), -1); |
| 5055 JUnitTestCase.assertEquals(-1, StringUtilities.indexOf1("abcdef", 1, 0x61)); | 5043 expect(StringUtilities.indexOf1("abcdef", 1, 0x61), -1); |
| 5056 // before start | 5044 // before start |
| 5057 } | 5045 } |
| 5058 | 5046 |
| 5059 void test_indexOf2() { | 5047 void test_indexOf2() { |
| 5060 JUnitTestCase.assertEquals( | 5048 expect(StringUtilities.indexOf2("ab", 0, 0x61, 0x62), 0); |
| 5061 0, | 5049 expect(StringUtilities.indexOf2("abcdef", 0, 0x61, 0x62), 0); |
| 5062 StringUtilities.indexOf2("ab", 0, 0x61, 0x62)); | 5050 expect(StringUtilities.indexOf2("abcdef", 0, 0x63, 0x64), 2); |
| 5063 JUnitTestCase.assertEquals( | 5051 expect(StringUtilities.indexOf2("abcdef", 0, 0x65, 0x66), 4); |
| 5064 0, | 5052 expect(StringUtilities.indexOf2("abcdef", 0, 0x64, 0x61), -1); |
| 5065 StringUtilities.indexOf2("abcdef", 0, 0x61, 0x62)); | 5053 expect(StringUtilities.indexOf2("abcdef", 1, 0x61, 0x62), -1); |
| 5066 JUnitTestCase.assertEquals( | |
| 5067 2, | |
| 5068 StringUtilities.indexOf2("abcdef", 0, 0x63, 0x64)); | |
| 5069 JUnitTestCase.assertEquals( | |
| 5070 4, | |
| 5071 StringUtilities.indexOf2("abcdef", 0, 0x65, 0x66)); | |
| 5072 JUnitTestCase.assertEquals( | |
| 5073 -1, | |
| 5074 StringUtilities.indexOf2("abcdef", 0, 0x64, 0x61)); | |
| 5075 JUnitTestCase.assertEquals( | |
| 5076 -1, | |
| 5077 StringUtilities.indexOf2("abcdef", 1, 0x61, 0x62)); | |
| 5078 // before start | 5054 // before start |
| 5079 } | 5055 } |
| 5080 | 5056 |
| 5081 void test_indexOf4() { | 5057 void test_indexOf4() { |
| 5082 JUnitTestCase.assertEquals( | 5058 expect(StringUtilities.indexOf4("abcd", 0, 0x61, 0x62, 0x63, 0x64), 0); |
| 5083 0, | 5059 expect(StringUtilities.indexOf4("abcdefghi", 0, 0x61, 0x62, 0x63, 0x64), 0); |
| 5084 StringUtilities.indexOf4("abcd", 0, 0x61, 0x62, 0x63, 0x64)); | 5060 expect(StringUtilities.indexOf4("abcdefghi", 0, 0x63, 0x64, 0x65, 0x66), 2); |
| 5085 JUnitTestCase.assertEquals( | 5061 expect(StringUtilities.indexOf4("abcdefghi", 0, 0x66, 0x67, 0x68, 0x69), 5); |
| 5086 0, | 5062 expect(StringUtilities.indexOf4("abcdefghi", 0, 0x64, 0x65, 0x61, 0x64), -1) ; |
| 5087 StringUtilities.indexOf4("abcdefghi", 0, 0x61, 0x62, 0x63, 0x64)); | 5063 expect(StringUtilities.indexOf4("abcdefghi", 1, 0x61, 0x62, 0x63, 0x64), -1) ; |
| 5088 JUnitTestCase.assertEquals( | |
| 5089 2, | |
| 5090 StringUtilities.indexOf4("abcdefghi", 0, 0x63, 0x64, 0x65, 0x66)); | |
| 5091 JUnitTestCase.assertEquals( | |
| 5092 5, | |
| 5093 StringUtilities.indexOf4("abcdefghi", 0, 0x66, 0x67, 0x68, 0x69)); | |
| 5094 JUnitTestCase.assertEquals( | |
| 5095 -1, | |
| 5096 StringUtilities.indexOf4("abcdefghi", 0, 0x64, 0x65, 0x61, 0x64)); | |
| 5097 JUnitTestCase.assertEquals( | |
| 5098 -1, | |
| 5099 StringUtilities.indexOf4("abcdefghi", 1, 0x61, 0x62, 0x63, 0x64)); | |
| 5100 // before start | 5064 // before start |
| 5101 } | 5065 } |
| 5102 | 5066 |
| 5103 void test_indexOf5() { | 5067 void test_indexOf5() { |
| 5104 JUnitTestCase.assertEquals( | 5068 expect(StringUtilities.indexOf5("abcde", 0, 0x61, 0x62, 0x63, 0x64, 0x65), 0 ); |
| 5105 0, | 5069 expect(StringUtilities.indexOf5("abcdefghi", 0, 0x61, 0x62, 0x63, 0x64, 0x65 ), 0); |
| 5106 StringUtilities.indexOf5("abcde", 0, 0x61, 0x62, 0x63, 0x64, 0x65)); | 5070 expect(StringUtilities.indexOf5("abcdefghi", 0, 0x63, 0x64, 0x65, 0x66, 0x67 ), 2); |
| 5107 JUnitTestCase.assertEquals( | 5071 expect(StringUtilities.indexOf5("abcdefghi", 0, 0x65, 0x66, 0x67, 0x68, 0x69 ), 4); |
| 5108 0, | 5072 expect(StringUtilities.indexOf5("abcdefghi", 0, 0x64, 0x65, 0x66, 0x69, 0x6E ), -1); |
| 5109 StringUtilities.indexOf5("abcdefghi", 0, 0x61, 0x62, 0x63, 0x64, 0x65)); | 5073 expect(StringUtilities.indexOf5("abcdefghi", 1, 0x61, 0x62, 0x63, 0x64, 0x65 ), -1); |
| 5110 JUnitTestCase.assertEquals( | |
| 5111 2, | |
| 5112 StringUtilities.indexOf5("abcdefghi", 0, 0x63, 0x64, 0x65, 0x66, 0x67)); | |
| 5113 JUnitTestCase.assertEquals( | |
| 5114 4, | |
| 5115 StringUtilities.indexOf5("abcdefghi", 0, 0x65, 0x66, 0x67, 0x68, 0x69)); | |
| 5116 JUnitTestCase.assertEquals( | |
| 5117 -1, | |
| 5118 StringUtilities.indexOf5("abcdefghi", 0, 0x64, 0x65, 0x66, 0x69, 0x6E)); | |
| 5119 JUnitTestCase.assertEquals( | |
| 5120 -1, | |
| 5121 StringUtilities.indexOf5("abcdefghi", 1, 0x61, 0x62, 0x63, 0x64, 0x65)); | |
| 5122 // before start | 5074 // before start |
| 5123 } | 5075 } |
| 5124 | 5076 |
| 5125 void test_isEmpty() { | 5077 void test_isEmpty() { |
| 5126 JUnitTestCase.assertTrue(StringUtilities.isEmpty("")); | 5078 expect(StringUtilities.isEmpty(""), isTrue); |
| 5127 JUnitTestCase.assertFalse(StringUtilities.isEmpty(" ")); | 5079 expect(StringUtilities.isEmpty(" "), isFalse); |
| 5128 JUnitTestCase.assertFalse(StringUtilities.isEmpty("a")); | 5080 expect(StringUtilities.isEmpty("a"), isFalse); |
| 5129 JUnitTestCase.assertTrue(StringUtilities.isEmpty(StringUtilities.EMPTY)); | 5081 expect(StringUtilities.isEmpty(StringUtilities.EMPTY), isTrue); |
| 5130 } | 5082 } |
| 5131 | 5083 |
| 5132 void test_isTagName() { | 5084 void test_isTagName() { |
| 5133 JUnitTestCase.assertFalse(StringUtilities.isTagName(null)); | 5085 expect(StringUtilities.isTagName(null), isFalse); |
| 5134 JUnitTestCase.assertFalse(StringUtilities.isTagName("")); | 5086 expect(StringUtilities.isTagName(""), isFalse); |
| 5135 JUnitTestCase.assertFalse(StringUtilities.isTagName("-")); | 5087 expect(StringUtilities.isTagName("-"), isFalse); |
| 5136 JUnitTestCase.assertFalse(StringUtilities.isTagName("0")); | 5088 expect(StringUtilities.isTagName("0"), isFalse); |
| 5137 JUnitTestCase.assertFalse(StringUtilities.isTagName("0a")); | 5089 expect(StringUtilities.isTagName("0a"), isFalse); |
| 5138 JUnitTestCase.assertFalse(StringUtilities.isTagName("a b")); | 5090 expect(StringUtilities.isTagName("a b"), isFalse); |
| 5139 JUnitTestCase.assertTrue(StringUtilities.isTagName("a0")); | 5091 expect(StringUtilities.isTagName("a0"), isTrue); |
| 5140 JUnitTestCase.assertTrue(StringUtilities.isTagName("a")); | 5092 expect(StringUtilities.isTagName("a"), isTrue); |
| 5141 JUnitTestCase.assertTrue(StringUtilities.isTagName("ab")); | 5093 expect(StringUtilities.isTagName("ab"), isTrue); |
| 5142 JUnitTestCase.assertTrue(StringUtilities.isTagName("a-b")); | 5094 expect(StringUtilities.isTagName("a-b"), isTrue); |
| 5143 } | 5095 } |
| 5144 | 5096 |
| 5145 void test_printListOfQuotedNames_empty() { | 5097 void test_printListOfQuotedNames_empty() { |
| 5146 try { | 5098 try { |
| 5147 StringUtilities.printListOfQuotedNames(new List<String>(0)); | 5099 StringUtilities.printListOfQuotedNames(new List<String>(0)); |
| 5148 JUnitTestCase.fail("Expected IllegalArgumentException"); | 5100 fail("Expected IllegalArgumentException"); |
| 5149 } on IllegalArgumentException catch (exception) { | 5101 } on IllegalArgumentException catch (exception) { |
| 5150 // Expected | 5102 // Expected |
| 5151 } | 5103 } |
| 5152 } | 5104 } |
| 5153 | 5105 |
| 5154 void test_printListOfQuotedNames_five() { | 5106 void test_printListOfQuotedNames_five() { |
| 5155 JUnitTestCase.assertEquals( | 5107 expect(StringUtilities.printListOfQuotedNames(<String>["a", "b", "c", "d", " e"]), "'a', 'b', 'c', 'd' and 'e'"); |
| 5156 "'a', 'b', 'c', 'd' and 'e'", | |
| 5157 StringUtilities.printListOfQuotedNames(<String>["a", "b", "c", "d", "e"] )); | |
| 5158 } | 5108 } |
| 5159 | 5109 |
| 5160 void test_printListOfQuotedNames_null() { | 5110 void test_printListOfQuotedNames_null() { |
| 5161 try { | 5111 try { |
| 5162 StringUtilities.printListOfQuotedNames(null); | 5112 StringUtilities.printListOfQuotedNames(null); |
| 5163 JUnitTestCase.fail("Expected IllegalArgumentException"); | 5113 fail("Expected IllegalArgumentException"); |
| 5164 } on IllegalArgumentException catch (exception) { | 5114 } on IllegalArgumentException catch (exception) { |
| 5165 // Expected | 5115 // Expected |
| 5166 } | 5116 } |
| 5167 } | 5117 } |
| 5168 | 5118 |
| 5169 void test_printListOfQuotedNames_one() { | 5119 void test_printListOfQuotedNames_one() { |
| 5170 try { | 5120 try { |
| 5171 StringUtilities.printListOfQuotedNames(<String>["a"]); | 5121 StringUtilities.printListOfQuotedNames(<String>["a"]); |
| 5172 JUnitTestCase.fail("Expected IllegalArgumentException"); | 5122 fail("Expected IllegalArgumentException"); |
| 5173 } on IllegalArgumentException catch (exception) { | 5123 } on IllegalArgumentException catch (exception) { |
| 5174 // Expected | 5124 // Expected |
| 5175 } | 5125 } |
| 5176 } | 5126 } |
| 5177 | 5127 |
| 5178 void test_printListOfQuotedNames_three() { | 5128 void test_printListOfQuotedNames_three() { |
| 5179 JUnitTestCase.assertEquals( | 5129 expect(StringUtilities.printListOfQuotedNames(<String>["a", "b", "c"]), "'a' , 'b' and 'c'"); |
| 5180 "'a', 'b' and 'c'", | |
| 5181 StringUtilities.printListOfQuotedNames(<String>["a", "b", "c"])); | |
| 5182 } | 5130 } |
| 5183 | 5131 |
| 5184 void test_printListOfQuotedNames_two() { | 5132 void test_printListOfQuotedNames_two() { |
| 5185 JUnitTestCase.assertEquals( | 5133 expect(StringUtilities.printListOfQuotedNames(<String>["a", "b"]), "'a' and 'b'"); |
| 5186 "'a' and 'b'", | |
| 5187 StringUtilities.printListOfQuotedNames(<String>["a", "b"])); | |
| 5188 } | 5134 } |
| 5189 | 5135 |
| 5190 void test_startsWith2() { | 5136 void test_startsWith2() { |
| 5191 JUnitTestCase.assertTrue(StringUtilities.startsWith2("ab", 0, 0x61, 0x62)); | 5137 expect(StringUtilities.startsWith2("ab", 0, 0x61, 0x62), isTrue); |
| 5192 JUnitTestCase.assertTrue( | 5138 expect(StringUtilities.startsWith2("abcdefghi", 0, 0x61, 0x62), isTrue); |
| 5193 StringUtilities.startsWith2("abcdefghi", 0, 0x61, 0x62)); | 5139 expect(StringUtilities.startsWith2("abcdefghi", 2, 0x63, 0x64), isTrue); |
| 5194 JUnitTestCase.assertTrue( | 5140 expect(StringUtilities.startsWith2("abcdefghi", 5, 0x66, 0x67), isTrue); |
| 5195 StringUtilities.startsWith2("abcdefghi", 2, 0x63, 0x64)); | 5141 expect(StringUtilities.startsWith2("abcdefghi", 0, 0x64, 0x64), isFalse); |
| 5196 JUnitTestCase.assertTrue( | |
| 5197 StringUtilities.startsWith2("abcdefghi", 5, 0x66, 0x67)); | |
| 5198 JUnitTestCase.assertFalse( | |
| 5199 StringUtilities.startsWith2("abcdefghi", 0, 0x64, 0x64)); | |
| 5200 // missing | 5142 // missing |
| 5201 } | 5143 } |
| 5202 | 5144 |
| 5203 void test_startsWith3() { | 5145 void test_startsWith3() { |
| 5204 JUnitTestCase.assertTrue( | 5146 expect(StringUtilities.startsWith3("abc", 0, 0x61, 0x62, 0x63), isTrue); |
| 5205 StringUtilities.startsWith3("abc", 0, 0x61, 0x62, 0x63)); | 5147 expect(StringUtilities.startsWith3("abcdefghi", 0, 0x61, 0x62, 0x63), isTrue ); |
| 5206 JUnitTestCase.assertTrue( | 5148 expect(StringUtilities.startsWith3("abcdefghi", 2, 0x63, 0x64, 0x65), isTrue ); |
| 5207 StringUtilities.startsWith3("abcdefghi", 0, 0x61, 0x62, 0x63)); | 5149 expect(StringUtilities.startsWith3("abcdefghi", 6, 0x67, 0x68, 0x69), isTrue ); |
| 5208 JUnitTestCase.assertTrue( | 5150 expect(StringUtilities.startsWith3("abcdefghi", 0, 0x64, 0x65, 0x61), isFals e); |
| 5209 StringUtilities.startsWith3("abcdefghi", 2, 0x63, 0x64, 0x65)); | |
| 5210 JUnitTestCase.assertTrue( | |
| 5211 StringUtilities.startsWith3("abcdefghi", 6, 0x67, 0x68, 0x69)); | |
| 5212 JUnitTestCase.assertFalse( | |
| 5213 StringUtilities.startsWith3("abcdefghi", 0, 0x64, 0x65, 0x61)); | |
| 5214 // missing | 5151 // missing |
| 5215 } | 5152 } |
| 5216 | 5153 |
| 5217 void test_startsWith4() { | 5154 void test_startsWith4() { |
| 5218 JUnitTestCase.assertTrue( | 5155 expect(StringUtilities.startsWith4("abcd", 0, 0x61, 0x62, 0x63, 0x64), isTru e); |
| 5219 StringUtilities.startsWith4("abcd", 0, 0x61, 0x62, 0x63, 0x64)); | 5156 expect(StringUtilities.startsWith4("abcdefghi", 0, 0x61, 0x62, 0x63, 0x64), isTrue); |
| 5220 JUnitTestCase.assertTrue( | 5157 expect(StringUtilities.startsWith4("abcdefghi", 2, 0x63, 0x64, 0x65, 0x66), isTrue); |
| 5221 StringUtilities.startsWith4("abcdefghi", 0, 0x61, 0x62, 0x63, 0x64)); | 5158 expect(StringUtilities.startsWith4("abcdefghi", 5, 0x66, 0x67, 0x68, 0x69), isTrue); |
| 5222 JUnitTestCase.assertTrue( | 5159 expect(StringUtilities.startsWith4("abcdefghi", 0, 0x64, 0x65, 0x61, 0x64), isFalse); |
| 5223 StringUtilities.startsWith4("abcdefghi", 2, 0x63, 0x64, 0x65, 0x66)); | |
| 5224 JUnitTestCase.assertTrue( | |
| 5225 StringUtilities.startsWith4("abcdefghi", 5, 0x66, 0x67, 0x68, 0x69)); | |
| 5226 JUnitTestCase.assertFalse( | |
| 5227 StringUtilities.startsWith4("abcdefghi", 0, 0x64, 0x65, 0x61, 0x64)); | |
| 5228 // missing | 5160 // missing |
| 5229 } | 5161 } |
| 5230 | 5162 |
| 5231 void test_startsWith5() { | 5163 void test_startsWith5() { |
| 5232 JUnitTestCase.assertTrue( | 5164 expect(StringUtilities.startsWith5("abcde", 0, 0x61, 0x62, 0x63, 0x64, 0x65) , isTrue); |
| 5233 StringUtilities.startsWith5("abcde", 0, 0x61, 0x62, 0x63, 0x64, 0x65)); | 5165 expect(StringUtilities.startsWith5("abcdefghi", 0, 0x61, 0x62, 0x63, 0x64, 0 x65), isTrue); |
| 5234 JUnitTestCase.assertTrue( | 5166 expect(StringUtilities.startsWith5("abcdefghi", 2, 0x63, 0x64, 0x65, 0x66, 0 x67), isTrue); |
| 5235 StringUtilities.startsWith5("abcdefghi", 0, 0x61, 0x62, 0x63, 0x64, 0x65 )); | 5167 expect(StringUtilities.startsWith5("abcdefghi", 4, 0x65, 0x66, 0x67, 0x68, 0 x69), isTrue); |
| 5236 JUnitTestCase.assertTrue( | 5168 expect(StringUtilities.startsWith5("abcdefghi", 0, 0x61, 0x62, 0x63, 0x62, 0 x61), isFalse); |
| 5237 StringUtilities.startsWith5("abcdefghi", 2, 0x63, 0x64, 0x65, 0x66, 0x67 )); | |
| 5238 JUnitTestCase.assertTrue( | |
| 5239 StringUtilities.startsWith5("abcdefghi", 4, 0x65, 0x66, 0x67, 0x68, 0x69 )); | |
| 5240 JUnitTestCase.assertFalse( | |
| 5241 StringUtilities.startsWith5("abcdefghi", 0, 0x61, 0x62, 0x63, 0x62, 0x61 )); | |
| 5242 // missing | 5169 // missing |
| 5243 } | 5170 } |
| 5244 | 5171 |
| 5245 void test_startsWith6() { | 5172 void test_startsWith6() { |
| 5246 JUnitTestCase.assertTrue( | 5173 expect(StringUtilities.startsWith6("abcdef", 0, 0x61, 0x62, 0x63, 0x64, 0x65 , 0x66), isTrue); |
| 5247 StringUtilities.startsWith6("abcdef", 0, 0x61, 0x62, 0x63, 0x64, 0x65, 0 x66)); | 5174 expect(StringUtilities.startsWith6( |
| 5248 JUnitTestCase.assertTrue( | |
| 5249 StringUtilities.startsWith6( | |
| 5250 "abcdefghi", | 5175 "abcdefghi", |
| 5251 0, | 5176 0, |
| 5252 0x61, | 5177 0x61, |
| 5253 0x62, | 5178 0x62, |
| 5254 0x63, | 5179 0x63, |
| 5255 0x64, | 5180 0x64, |
| 5256 0x65, | 5181 0x65, |
| 5257 0x66)); | 5182 0x66), isTrue); |
| 5258 JUnitTestCase.assertTrue( | 5183 expect(StringUtilities.startsWith6( |
| 5259 StringUtilities.startsWith6( | |
| 5260 "abcdefghi", | 5184 "abcdefghi", |
| 5261 2, | 5185 2, |
| 5262 0x63, | 5186 0x63, |
| 5263 0x64, | 5187 0x64, |
| 5264 0x65, | 5188 0x65, |
| 5265 0x66, | 5189 0x66, |
| 5266 0x67, | 5190 0x67, |
| 5267 0x68)); | 5191 0x68), isTrue); |
| 5268 JUnitTestCase.assertTrue( | 5192 expect(StringUtilities.startsWith6( |
| 5269 StringUtilities.startsWith6( | |
| 5270 "abcdefghi", | 5193 "abcdefghi", |
| 5271 3, | 5194 3, |
| 5272 0x64, | 5195 0x64, |
| 5273 0x65, | 5196 0x65, |
| 5274 0x66, | 5197 0x66, |
| 5275 0x67, | 5198 0x67, |
| 5276 0x68, | 5199 0x68, |
| 5277 0x69)); | 5200 0x69), isTrue); |
| 5278 JUnitTestCase.assertFalse( | 5201 expect(StringUtilities.startsWith6( |
| 5279 StringUtilities.startsWith6( | |
| 5280 "abcdefghi", | 5202 "abcdefghi", |
| 5281 0, | 5203 0, |
| 5282 0x61, | 5204 0x61, |
| 5283 0x62, | 5205 0x62, |
| 5284 0x63, | 5206 0x63, |
| 5285 0x64, | 5207 0x64, |
| 5286 0x65, | 5208 0x65, |
| 5287 0x67)); | 5209 0x67), isFalse); |
| 5288 // missing | 5210 // missing |
| 5289 } | 5211 } |
| 5290 | 5212 |
| 5291 void test_startsWithChar() { | 5213 void test_startsWithChar() { |
| 5292 JUnitTestCase.assertTrue(StringUtilities.startsWithChar("a", 0x61)); | 5214 expect(StringUtilities.startsWithChar("a", 0x61), isTrue); |
| 5293 JUnitTestCase.assertFalse(StringUtilities.startsWithChar("b", 0x61)); | 5215 expect(StringUtilities.startsWithChar("b", 0x61), isFalse); |
| 5294 JUnitTestCase.assertFalse(StringUtilities.startsWithChar("", 0x61)); | 5216 expect(StringUtilities.startsWithChar("", 0x61), isFalse); |
| 5295 } | 5217 } |
| 5296 | 5218 |
| 5297 void test_substringBefore() { | 5219 void test_substringBefore() { |
| 5298 JUnitTestCase.assertEquals(null, StringUtilities.substringBefore(null, "")); | 5220 expect(StringUtilities.substringBefore(null, ""), null); |
| 5299 JUnitTestCase.assertEquals( | 5221 expect(StringUtilities.substringBefore(null, "a"), null); |
| 5300 null, | 5222 expect(StringUtilities.substringBefore("", "a"), ""); |
| 5301 StringUtilities.substringBefore(null, "a")); | 5223 expect(StringUtilities.substringBefore("abc", "a"), ""); |
| 5302 JUnitTestCase.assertEquals("", StringUtilities.substringBefore("", "a")); | 5224 expect(StringUtilities.substringBefore("abcba", "b"), "a"); |
| 5303 JUnitTestCase.assertEquals("", StringUtilities.substringBefore("abc", "a")); | 5225 expect(StringUtilities.substringBefore("abc", "c"), "ab"); |
| 5304 JUnitTestCase.assertEquals( | 5226 expect(StringUtilities.substringBefore("abc", "d"), "abc"); |
| 5305 "a", | 5227 expect(StringUtilities.substringBefore("abc", ""), ""); |
| 5306 StringUtilities.substringBefore("abcba", "b")); | 5228 expect(StringUtilities.substringBefore("abc", null), "abc"); |
| 5307 JUnitTestCase.assertEquals( | |
| 5308 "ab", | |
| 5309 StringUtilities.substringBefore("abc", "c")); | |
| 5310 JUnitTestCase.assertEquals( | |
| 5311 "abc", | |
| 5312 StringUtilities.substringBefore("abc", "d")); | |
| 5313 JUnitTestCase.assertEquals("", StringUtilities.substringBefore("abc", "")); | |
| 5314 JUnitTestCase.assertEquals( | |
| 5315 "abc", | |
| 5316 StringUtilities.substringBefore("abc", null)); | |
| 5317 } | 5229 } |
| 5318 | 5230 |
| 5319 void test_substringBeforeChar() { | 5231 void test_substringBeforeChar() { |
| 5320 JUnitTestCase.assertEquals( | 5232 expect(StringUtilities.substringBeforeChar(null, 0x61), null); |
| 5321 null, | 5233 expect(StringUtilities.substringBeforeChar("", 0x61), ""); |
| 5322 StringUtilities.substringBeforeChar(null, 0x61)); | 5234 expect(StringUtilities.substringBeforeChar("abc", 0x61), ""); |
| 5323 JUnitTestCase.assertEquals( | 5235 expect(StringUtilities.substringBeforeChar("abcba", 0x62), "a"); |
| 5324 "", | 5236 expect(StringUtilities.substringBeforeChar("abc", 0x63), "ab"); |
| 5325 StringUtilities.substringBeforeChar("", 0x61)); | 5237 expect(StringUtilities.substringBeforeChar("abc", 0x64), "abc"); |
| 5326 JUnitTestCase.assertEquals( | |
| 5327 "", | |
| 5328 StringUtilities.substringBeforeChar("abc", 0x61)); | |
| 5329 JUnitTestCase.assertEquals( | |
| 5330 "a", | |
| 5331 StringUtilities.substringBeforeChar("abcba", 0x62)); | |
| 5332 JUnitTestCase.assertEquals( | |
| 5333 "ab", | |
| 5334 StringUtilities.substringBeforeChar("abc", 0x63)); | |
| 5335 JUnitTestCase.assertEquals( | |
| 5336 "abc", | |
| 5337 StringUtilities.substringBeforeChar("abc", 0x64)); | |
| 5338 } | 5238 } |
| 5339 } | 5239 } |
| 5340 | 5240 |
| 5341 /** | 5241 /** |
| 5342 * Instances of the class `TestLogger` implement a logger that can be used by te sts. | 5242 * Instances of the class `TestLogger` implement a logger that can be used by te sts. |
| 5343 */ | 5243 */ |
| 5344 class TestLogger implements Logger { | 5244 class TestLogger implements Logger { |
| 5345 /** | 5245 /** |
| 5346 * The number of error messages that were logged. | 5246 * The number of error messages that were logged. |
| 5347 */ | 5247 */ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5381 _infoCount++; | 5281 _infoCount++; |
| 5382 } | 5282 } |
| 5383 | 5283 |
| 5384 @override | 5284 @override |
| 5385 void logInformation2(String message, Exception exception) { | 5285 void logInformation2(String message, Exception exception) { |
| 5386 _infoCount++; | 5286 _infoCount++; |
| 5387 } | 5287 } |
| 5388 } | 5288 } |
| 5389 | 5289 |
| 5390 | 5290 |
| 5391 class TokenMapTest extends JUnitTestCase { | 5291 class TokenMapTest { |
| 5392 void test_creation() { | 5292 void test_creation() { |
| 5393 JUnitTestCase.assertNotNull(new TokenMap()); | 5293 expect(new TokenMap(), isNotNull); |
| 5394 } | 5294 } |
| 5395 | 5295 |
| 5396 void test_get_absent() { | 5296 void test_get_absent() { |
| 5397 TokenMap tokenMap = new TokenMap(); | 5297 TokenMap tokenMap = new TokenMap(); |
| 5398 JUnitTestCase.assertNull( | 5298 expect(tokenMap.get(TokenFactory.tokenFromType(TokenType.AT)), isNull); |
| 5399 tokenMap.get(TokenFactory.tokenFromType(TokenType.AT))); | |
| 5400 } | 5299 } |
| 5401 | 5300 |
| 5402 void test_get_added() { | 5301 void test_get_added() { |
| 5403 TokenMap tokenMap = new TokenMap(); | 5302 TokenMap tokenMap = new TokenMap(); |
| 5404 Token key = TokenFactory.tokenFromType(TokenType.AT); | 5303 Token key = TokenFactory.tokenFromType(TokenType.AT); |
| 5405 Token value = TokenFactory.tokenFromType(TokenType.AT); | 5304 Token value = TokenFactory.tokenFromType(TokenType.AT); |
| 5406 tokenMap.put(key, value); | 5305 tokenMap.put(key, value); |
| 5407 JUnitTestCase.assertSame(value, tokenMap.get(key)); | 5306 expect(tokenMap.get(key), same(value)); |
| 5408 } | 5307 } |
| 5409 } | 5308 } |
| OLD | NEW |