Skip to content

Commit c55962c

Browse files
committed
Fix indentation in tests and remove unrelated tests.
1 parent 9765858 commit c55962c

File tree

1 file changed

+24
-153
lines changed

1 file changed

+24
-153
lines changed

unittests/AST/IndexSubsetTests.cpp

Lines changed: 24 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "swift/AST/AutoDiff.h"
1413
#include "swift/AST/IndexSubset.h"
1514
#include "TestContext.h"
1615
#include "gtest/gtest.h"
@@ -49,58 +48,45 @@ TEST(IndexSubset, BitWordIndexAndOffset) {
4948

5049
TEST(IndexSubset, Equality) {
5150
TestContext ctx;
52-
EXPECT_EQ(IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
53-
/*indices*/ {0}),
54-
IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
55-
/*indices*/ {0}));
56-
EXPECT_EQ(IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
57-
/*indices*/ {0, 2, 4}),
58-
IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
59-
/*indices*/ {0, 2, 4}));
60-
EXPECT_EQ(IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
61-
/*indices*/ {}),
62-
IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
63-
/*indices*/ {}));
64-
EXPECT_NE(IndexSubset::get(ctx.Ctx, /*capacity*/ 1,
65-
/*indices*/ {}),
66-
IndexSubset::get(ctx.Ctx, /*capacity*/ 0,
67-
/*indices*/ {}));
68-
EXPECT_NE(IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
69-
/*indices*/ {0}),
70-
IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
71-
/*indices*/ {}));
51+
EXPECT_EQ(IndexSubset::get(ctx.Ctx, /*capacity*/ 5, /*indices*/ {0}),
52+
IndexSubset::get(ctx.Ctx, /*capacity*/ 5, /*indices*/ {0}));
53+
EXPECT_EQ(IndexSubset::get(ctx.Ctx, /*capacity*/ 5, /*indices*/ {0, 2, 4}),
54+
IndexSubset::get(ctx.Ctx, /*capacity*/ 5, /*indices*/ {0, 2, 4}));
55+
EXPECT_EQ(IndexSubset::get(ctx.Ctx, /*capacity*/ 5, /*indices*/ {}),
56+
IndexSubset::get(ctx.Ctx, /*capacity*/ 5, /*indices*/ {}));
57+
EXPECT_NE(IndexSubset::get(ctx.Ctx, /*capacity*/ 1, /*indices*/ {}),
58+
IndexSubset::get(ctx.Ctx, /*capacity*/ 0, /*indices*/ {}));
59+
EXPECT_NE(IndexSubset::get(ctx.Ctx, /*capacity*/ 5, /*indices*/ {0}),
60+
IndexSubset::get(ctx.Ctx, /*capacity*/ 5, /*indices*/ {}));
7261
}
7362

7463
TEST(IndexSubset, Initializers) {
7564
TestContext ctx;
7665
// Default init.
7766
EXPECT_EQ(IndexSubset::getDefault(ctx.Ctx, /*capacity*/ 5,
78-
/*includeAll*/ true),
67+
/*includeAll*/ true),
7968
IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
80-
/*indices*/ {0, 1, 2, 3, 4}));
69+
/*indices*/ {0, 1, 2, 3, 4}));
8170
EXPECT_EQ(IndexSubset::getDefault(ctx.Ctx, /*capacity*/ 5,
82-
/*includeAll*/ false),
71+
/*includeAll*/ false),
8372
IndexSubset::get(ctx.Ctx, /*capacity*/ 5, /*indices*/ {}));
8473
EXPECT_EQ(IndexSubset::getDefault(ctx.Ctx, /*capacity*/ 0,
85-
/*includeAll*/ true),
86-
IndexSubset::get(ctx.Ctx, /*capacity*/ 0,
87-
/*indices*/ {}));
74+
/*includeAll*/ true),
75+
IndexSubset::get(ctx.Ctx, /*capacity*/ 0, /*indices*/ {}));
8876
EXPECT_EQ(IndexSubset::getDefault(ctx.Ctx, /*capacity*/ 0,
89-
/*includeAll*/ false),
77+
/*includeAll*/ false),
9078
IndexSubset::get(ctx.Ctx, /*capacity*/ 0, /*indices*/ {}));
9179
// Bit vector init.
9280
{
9381
llvm::SmallBitVector bitVec(6);
9482
bitVec.set(1, 4);
9583
EXPECT_EQ(IndexSubset::get(ctx.Ctx, bitVec),
96-
IndexSubset::get(ctx.Ctx, /*capacity*/ 6,
97-
/*indices*/ {1, 2, 3}));
84+
IndexSubset::get(ctx.Ctx, /*capacity*/ 6, /*indices*/ {1, 2, 3}));
9885
}
9986
{
10087
llvm::SmallBitVector bitVec(0);
10188
EXPECT_EQ(IndexSubset::get(ctx.Ctx, bitVec),
102-
IndexSubset::get(ctx.Ctx, /*capacity*/ 0,
103-
/*indices*/ {}));
89+
IndexSubset::get(ctx.Ctx, /*capacity*/ 0, /*indices*/ {}));
10490
}
10591
// String init.
10692
EXPECT_EQ(IndexSubset::getFromString(ctx.Ctx, "SSSSS"),
@@ -118,7 +104,7 @@ TEST(IndexSubset, Initializers) {
118104
TEST(IndexSubset, Bits) {
119105
TestContext ctx;
120106
auto *indices1 = IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
121-
/*indices*/ {0, 2, 4});
107+
/*indices*/ {0, 2, 4});
122108
EXPECT_EQ(indices1->getNumBitWords(), 1u);
123109
EXPECT_EQ(indices1->getCapacity(), 5u);
124110
EXPECT_TRUE(indices1->contains(0));
@@ -128,7 +114,7 @@ TEST(IndexSubset, Bits) {
128114
EXPECT_TRUE(indices1->contains(4));
129115

130116
auto *indices2 = IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
131-
/*indices*/ {1, 3});
117+
/*indices*/ {1, 3});
132118
EXPECT_EQ(indices2->getNumBitWords(), 1u);
133119
EXPECT_EQ(indices2->getCapacity(), 5u);
134120
EXPECT_FALSE(indices2->contains(0));
@@ -143,7 +129,7 @@ TEST(IndexSubset, Iteration) {
143129
// Test 1
144130
{
145131
auto *indices1 = IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
146-
/*indices*/ {0, 2, 4});
132+
/*indices*/ {0, 2, 4});
147133
// Check forward iteration.
148134
EXPECT_EQ(indices1->findFirst(), 0);
149135
EXPECT_EQ(indices1->findNext(0), 2);
@@ -162,7 +148,7 @@ TEST(IndexSubset, Iteration) {
162148
// Test 2
163149
{
164150
auto *indices2 = IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
165-
/*indices*/ {1, 3});
151+
/*indices*/ {1, 3});
166152
// Check forward iteration.
167153
EXPECT_EQ(indices2->findFirst(), 1);
168154
EXPECT_EQ(indices2->findNext(1), 3);
@@ -181,11 +167,10 @@ TEST(IndexSubset, Iteration) {
181167
TEST(IndexSubset, SupersetAndSubset) {
182168
TestContext ctx;
183169
auto *indices1 = IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
184-
/*indices*/ {0, 2, 4});
170+
/*indices*/ {0, 2, 4});
185171
EXPECT_TRUE(indices1->isSupersetOf(indices1));
186172
EXPECT_TRUE(indices1->isSubsetOf(indices1));
187-
auto *indices2 = IndexSubset::get(ctx.Ctx, /*capacity*/ 5,
188-
/*indices*/ {2});
173+
auto *indices2 = IndexSubset::get(ctx.Ctx, /*capacity*/ 5, /*indices*/ {2});
189174
EXPECT_TRUE(indices2->isSupersetOf(indices2));
190175
EXPECT_TRUE(indices2->isSubsetOf(indices2));
191176

@@ -202,117 +187,3 @@ TEST(IndexSubset, Insertion) {
202187
EXPECT_EQ(indices1->adding(3, ctx.Ctx),
203188
IndexSubset::get(ctx.Ctx, 5, {0, 2, 3, 4}));
204189
}
205-
206-
TEST(IndexSubset, Lowering) {
207-
TestContext testCtx;
208-
auto &C = testCtx.Ctx;
209-
// ((T, T)) -> ()
210-
EXPECT_EQ(
211-
autodiff::getLoweredParameterIndices(
212-
IndexSubset::get(C, 1, {0}),
213-
FunctionType::get({
214-
FunctionType::Param(
215-
TupleType::get({C.TheAnyType, C.TheAnyType}, C))},
216-
C.TheEmptyTupleType)),
217-
IndexSubset::get(C, 2, {0, 1}));
218-
// ((), (T, T)) -> ()
219-
EXPECT_EQ(
220-
autodiff::getLoweredParameterIndices(
221-
IndexSubset::get(C, 2, {1}),
222-
FunctionType::get({
223-
FunctionType::Param(C.TheEmptyTupleType),
224-
FunctionType::Param(
225-
TupleType::get({C.TheAnyType, C.TheAnyType}, C))},
226-
C.TheEmptyTupleType)),
227-
IndexSubset::get(C, 2, {0, 1}));
228-
// (T, (T, T)) -> ()
229-
EXPECT_EQ(
230-
autodiff::getLoweredParameterIndices(
231-
IndexSubset::get(C, 2, {1}),
232-
FunctionType::get({
233-
FunctionType::Param(C.TheAnyType),
234-
FunctionType::Param(
235-
TupleType::get({C.TheAnyType, C.TheAnyType}, C))},
236-
C.TheEmptyTupleType)),
237-
IndexSubset::get(C, 3, {1, 2}));
238-
// (T, (T, T)) -> ()
239-
EXPECT_EQ(
240-
autodiff::getLoweredParameterIndices(
241-
IndexSubset::get(C, 2, {0, 1}),
242-
FunctionType::get({
243-
FunctionType::Param(C.TheAnyType),
244-
FunctionType::Param(
245-
TupleType::get({C.TheAnyType, C.TheAnyType}, C))},
246-
C.TheEmptyTupleType)),
247-
IndexSubset::get(C, 3, {0, 1, 2}));
248-
// (T, ((T, T)), (T, T), T) -> ()
249-
EXPECT_EQ(
250-
autodiff::getLoweredParameterIndices(
251-
IndexSubset::get(C, 4, {0, 1, 3}),
252-
FunctionType::get({
253-
FunctionType::Param(C.TheAnyType),
254-
FunctionType::Param(
255-
TupleType::get({
256-
TupleType::get({C.TheAnyType, C.TheAnyType}, C)}, C)),
257-
FunctionType::Param(
258-
TupleType::get({C.TheAnyType, C.TheAnyType}, C)),
259-
FunctionType::Param(C.TheAnyType)},
260-
C.TheEmptyTupleType)),
261-
IndexSubset::get(C, 6, {0, 1, 2, 5}));
262-
// Method (T) -> ((T, T), (T, T), T) -> ()
263-
// TODO(TF-874): Fix this unit test.
264-
// The current actual result is:
265-
// `(autodiff_index_subset capacity=6 indices=(0, 1, 4))`.
266-
#if 0
267-
EXPECT_EQ(
268-
autodiff::getLoweredParameterIndices(
269-
IndexSubset::get(C, 4, {0, 1, 3}),
270-
FunctionType::get(
271-
{FunctionType::Param(C.TheAnyType)},
272-
FunctionType::get({
273-
FunctionType::Param(
274-
TupleType::get({C.TheAnyType, C.TheAnyType}, C)),
275-
FunctionType::Param(
276-
TupleType::get({C.TheAnyType, C.TheAnyType}, C)),
277-
FunctionType::Param(C.TheAnyType)},
278-
C.TheEmptyTupleType)->withExtInfo(
279-
FunctionType::ExtInfo().withSILRepresentation(
280-
SILFunctionTypeRepresentation::Method)))),
281-
IndexSubset::get(C, 6, {0, 1, 4, 5}));
282-
#endif
283-
}
284-
285-
TEST(IndexSubset, GetSubsetParameterTypes) {
286-
TestContext testCtx;
287-
auto &C = testCtx.Ctx;
288-
// (T, T) -> ()
289-
{
290-
SmallVector<Type, 8> subset;
291-
autodiff::getSubsetParameterTypes(
292-
IndexSubset::get(C, 1, {0}),
293-
FunctionType::get(
294-
{FunctionType::Param(C.TheAnyType),
295-
FunctionType::Param(C.TheAnyType)},
296-
C.TheEmptyTupleType),
297-
subset);
298-
Type expected[] = {C.TheAnyType};
299-
EXPECT_TRUE(std::equal(subset.begin(), subset.end(), expected,
300-
[](Type ty1, Type ty2) { return ty1->isEqual(ty2); }));
301-
}
302-
// (T) -> (T, T) -> ()
303-
{
304-
SmallVector<Type, 8> subset;
305-
autodiff::getSubsetParameterTypes(
306-
IndexSubset::get(C, 3, {0, 1, 2}),
307-
FunctionType::get(
308-
{FunctionType::Param(C.TheIEEE16Type)},
309-
FunctionType::get(
310-
{FunctionType::Param(C.TheAnyType),
311-
FunctionType::Param(C.TheAnyType)},
312-
C.TheEmptyTupleType)),
313-
subset);
314-
Type expected[] = {C.TheIEEE16Type, C.TheAnyType, C.TheAnyType};
315-
EXPECT_TRUE(std::equal(subset.begin(), subset.end(), expected,
316-
[](Type ty1, Type ty2) { return ty1->isEqual(ty2); }));
317-
}
318-
}

0 commit comments

Comments
 (0)