Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: tests/compiler/dart2js/setlet_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'package:compiler/src/util/setlet.dart'; 7 import 'package:compiler/src/util/setlet.dart';
8 8
9 main() { 9 main() {
10 for (int i = 1; i <= 32; i++) { 10 for (int i = 1; i <= 32; i++) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 Expect.equals(size, setlet.length); 69 Expect.equals(size, setlet.length);
70 Expect.isTrue(setlet.contains(i)); 70 Expect.isTrue(setlet.contains(i));
71 } 71 }
72 } 72 }
73 73
74 testAllLikeSet() { 74 testAllLikeSet() {
75 // For a variety of inputs and operations, test that Setlet behaves just like 75 // For a variety of inputs and operations, test that Setlet behaves just like
76 // Set. 76 // Set.
77 var samples = [ 77 var samples = [
78 [], [1], [1, 2], [2, 1], [1, 3], [3, 1], [1, 2, 3], [3, 1, 2], 78 [],
79 [1, 2, 3, 4, 5, 6, 7], 79 [1],
80 [1, 2, 3, 4, 5, 6, 7, 8, 9], 80 [1, 2],
81 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 81 [2, 1],
82 [1, 2, 3, 4, 5, 6, 7, 8, 9], 82 [1, 3],
83 [6, 7, 8, 9, 10, 11], 83 [3, 1],
84 [7, 8, 6, 5], 84 [1, 2, 3],
85 [3, 1, 2],
86 [1, 2, 3, 4, 5, 6, 7],
87 [1, 2, 3, 4, 5, 6, 7, 8, 9],
88 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
89 [1, 2, 3, 4, 5, 6, 7, 8, 9],
90 [6, 7, 8, 9, 10, 11],
91 [7, 8, 6, 5],
85 ]; 92 ];
86 93
87 for (var a in samples) { 94 for (var a in samples) {
88 for (var b in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) { 95 for (var b in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) {
89 testSetXElement('add', (s, e) => s.add(e), a, b); 96 testSetXElement('add', (s, e) => s.add(e), a, b);
90 testSetXElement('remove', (s, e) => s.remove(e), a, b); 97 testSetXElement('remove', (s, e) => s.remove(e), a, b);
91 testSetXElement('contains', (s, e) => s.contains(e), a, b); 98 testSetXElement('contains', (s, e) => s.contains(e), a, b);
92 testSetXElement('lookup', (s, e) => s.lookup(e), a, b); 99 testSetXElement('lookup', (s, e) => s.lookup(e), a, b);
93 } 100 }
94 } 101 }
95 102
96 for (var a in samples) { 103 for (var a in samples) {
97 for (var b in samples) { 104 for (var b in samples) {
98 testSetXSet('addAll', (s, t) => s.addAll(t), a, b); 105 testSetXSet('addAll', (s, t) => s.addAll(t), a, b);
99 testSetXSet('removeAll', (s, t) => s.removeAll(t), a, b); 106 testSetXSet('removeAll', (s, t) => s.removeAll(t), a, b);
100 testSetXSet('retainAll', (s, t) => s.retainAll(t), a, b); 107 testSetXSet('retainAll', (s, t) => s.retainAll(t), a, b);
101 testSetXSet('containsAll', (s, t) => s.containsAll(t), a, b); 108 testSetXSet('containsAll', (s, t) => s.containsAll(t), a, b);
102 testSetXSet('union', (s, t) => s.union(t), a, b); 109 testSetXSet('union', (s, t) => s.union(t), a, b);
103 testSetXSet('intersection', (s, t) => s.intersection(t), a, b); 110 testSetXSet('intersection', (s, t) => s.intersection(t), a, b);
104 testSetXSet('difference', (s, t) => s.difference(t), a, b); 111 testSetXSet('difference', (s, t) => s.difference(t), a, b);
105 } 112 }
106 } 113 }
107 } 114 }
108 115
109
110 testSetXElement(name, fn, a, b) { 116 testSetXElement(name, fn, a, b) {
111 var set1 = new LinkedHashSet.from(a); 117 var set1 = new LinkedHashSet.from(a);
112 var setlet1 = new Setlet.from(a); 118 var setlet1 = new Setlet.from(a);
113 119
114 var setResult = fn(set1, b); 120 var setResult = fn(set1, b);
115 var setletResult = fn(setlet1, b); 121 var setletResult = fn(setlet1, b);
116 122
117 var operationName = '$name $a $b'; 123 var operationName = '$name $a $b';
118 checkResult(operationName, setResult, setletResult); 124 checkResult(operationName, setResult, setletResult);
119 checkModifications(operationName, set1, setlet1); 125 checkModifications(operationName, set1, setlet1);
(...skipping 10 matching lines...) Expand all
130 136
131 var operationName = '$name $a $b'; 137 var operationName = '$name $a $b';
132 checkResult(operationName, setResult, setletResult); 138 checkResult(operationName, setResult, setletResult);
133 checkModifications(operationName, set1, setlet1); 139 checkModifications(operationName, set1, setlet1);
134 } 140 }
135 141
136 checkResult(operationName, setResult, setletResult) { 142 checkResult(operationName, setResult, setletResult) {
137 if (setResult == null || setResult is bool || setResult is num) { 143 if (setResult == null || setResult is bool || setResult is num) {
138 Expect.equals(setResult, setletResult, '$operationName'); 144 Expect.equals(setResult, setletResult, '$operationName');
139 } else if (setResult is Iterable) { 145 } else if (setResult is Iterable) {
140 Expect.isTrue(setletResult is Iterable, 146 Expect.isTrue(setletResult is Iterable, '$operationName: returns Iterable');
141 '$operationName: returns Iterable');
142 Expect.equals(setResult.isEmpty, setletResult.isEmpty, 147 Expect.equals(setResult.isEmpty, setletResult.isEmpty,
143 '$operationName: same isEmpty'); 148 '$operationName: same isEmpty');
144 Expect.equals(setResult.length, setletResult.length, 149 Expect.equals(
145 '$operationName: same length'); 150 setResult.length, setletResult.length, '$operationName: same length');
146 Expect.listEquals(setResult.toList(), setletResult.toList(), 151 Expect.listEquals(setResult.toList(), setletResult.toList(),
147 '$operationName: same toList() result'); 152 '$operationName: same toList() result');
148 } else { 153 } else {
149 Expect.isFalse(true, '$operationName: unexpected result type'); 154 Expect.isFalse(true, '$operationName: unexpected result type');
150 } 155 }
151 } 156 }
152 157
153 checkModifications(operationName, setReceiver, setletReceiver) { 158 checkModifications(operationName, setReceiver, setletReceiver) {
154 Expect.equals(setReceiver.length, setletReceiver.length, 159 Expect.equals(setReceiver.length, setletReceiver.length,
155 '$operationName: same post-operation receiver length'); 160 '$operationName: same post-operation receiver length');
156 Expect.listEquals(setReceiver.toList(), setletReceiver.toList(), 161 Expect.listEquals(setReceiver.toList(), setletReceiver.toList(),
157 '$operationName: same post-operation receiver contents'); 162 '$operationName: same post-operation receiver contents');
158 } 163 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/serialization/test_helper.dart ('k') | tests/compiler/dart2js/sha1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698