This is an archive of the discontinued LLVM Phabricator instance.

[SyntaxTree] Split tests
ClosedPublic

Authored by eduucaldas on Aug 12 2020, 1:57 AM.

Details

Summary

We do that because:

  • Big tests generated big tree dumps that could hardly serve as documentation.
  • In most cases the tests didn't share setup, thus there was not much addition in lines of code.

Diff Detail

Event Timeline

eduucaldas created this revision.Aug 12 2020, 1:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2020, 1:57 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
eduucaldas requested review of this revision.Aug 12 2020, 1:57 AM

Before we had an UnqualifiedId test that tested for everything in the grammar. Now we just split this test and test the alternatives separately.

clang/unittests/Tooling/Syntax/TreeTest.cpp
635

It seems inappropriate to always repeat UnqualfiiedId, do you have any other suggestion?

Split tests for UserDefinedLiteral
Split tests for NumericUserDefinedLiteral
Split tests for NestedBinaryOperator
Split tests for UserDefinedBinaryOperator
Split tests for UserDefinedPrefixOperator

  • [SyntaxTree] Split tests for QualifiedId

Rename tests following TestSuite_TestCase

eduucaldas added inline comments.Aug 12 2020, 7:03 AM
clang/unittests/Tooling/Syntax/TreeTest.cpp
635

Last commit change names to TestSuite_TestCase

1153

Here I didn't merely split the tests, I also changed them a bit. PTAL.

1539–1541

Same setup for FloatUserDefinedLiteral. I think it is justified with the Annotations we can constraint the dump just to the expressions being tested

gribozavr2 accepted this revision.Aug 12 2020, 3:47 PM

Please also consider splitting the file into multiple.

clang/unittests/Tooling/Syntax/TreeTest.cpp
1202

Indent -2.

1310

For consistency with other test names: QualifiedId_DecltypeSpecifier

2437

BinaryOperator_NestedWithParenthesis

2494

BinaryOperator_Associativity

2538

BinaryOperator_Precedence

2558

UserDefinedOperator => OverloadedOperator?

"user-defined" seems to suggest that the operator was previously not a thing in C++.

2679

UserDefinedOperator_LeftShift

2713

UserDefinedOperator_PointerToMember

2790

PrefixIncrement

2848

UserDefinedOperator_Negation

2881

PostfixIncrement

Also, group it right after prefix increment?

This revision is now accepted and ready to land.Aug 12 2020, 3:47 PM
eduucaldas marked 11 inline comments as done.

Answer review comments

clang/unittests/Tooling/Syntax/TreeTest.cpp
2558

Actually it is a very good point! Thanks!

2881

I'm grouping together Prefix operators. But you're right it makes sense to put them close to each other. I've put PrefixIncrement as the last Prefix operator to achieve that

eduucaldas added inline comments.Aug 13 2020, 12:57 AM
clang/unittests/Tooling/Syntax/TreeTest.cpp
1539–1541

Taking account the Annotations change. Duplicating two lines of code between tests should be ok.

We'll split this file in a future change

This revision was landed with ongoing or failed builds.Aug 13 2020, 1:18 AM
This revision was automatically updated to reflect the committed changes.