mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Add variable read/write flag test for c++20 three-way comparison
This commit is contained in:
parent
a8b3401a47
commit
ae8da7ef88
2 changed files with 24 additions and 1 deletions
|
@ -539,7 +539,12 @@ public abstract class AST2TestBase extends SemanticTestBase {
|
|||
}
|
||||
|
||||
public AST2AssertionHelper(String contents, ParserLanguage lang) throws ParserException {
|
||||
super(contents, parse(contents, lang, ScannerKind.GNU, false));
|
||||
this(contents, lang, ScannerKind.GNU);
|
||||
}
|
||||
|
||||
public AST2AssertionHelper(String contents, ParserLanguage lang, ScannerKind scannerKind)
|
||||
throws ParserException {
|
||||
super(contents, parse(contents, lang, scannerKind, false));
|
||||
this.isCPP = lang.isCPP();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.io.IOException;
|
|||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVariableReadWriteFlags;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
@ -36,6 +37,10 @@ public class VariableReadWriteFlagsTest extends AST2TestBase {
|
|||
super(contents, isCPP);
|
||||
}
|
||||
|
||||
AssertionHelper(String contents, ParserLanguage lang, ScannerKind scannerKind) throws ParserException {
|
||||
super(contents, lang, scannerKind);
|
||||
}
|
||||
|
||||
void assertReadWriteFlags(String context, String name, Optional<Integer> expectedFlags) throws Exception {
|
||||
IASTName variable = findName(context, name);
|
||||
assertNotNull(variable);
|
||||
|
@ -95,6 +100,11 @@ public class VariableReadWriteFlagsTest extends AST2TestBase {
|
|||
return new AssertionHelper(code, true);
|
||||
}
|
||||
|
||||
protected AssertionHelper getCPP20AssertionHelper() throws ParserException, IOException {
|
||||
String code = getAboveComment();
|
||||
return new AssertionHelper(code, ParserLanguage.CPP, ScannerKind.STDCPP20);
|
||||
}
|
||||
|
||||
// int test(int a) {
|
||||
// a = 2;
|
||||
// a *= 3;
|
||||
|
@ -107,6 +117,14 @@ public class VariableReadWriteFlagsTest extends AST2TestBase {
|
|||
a.assertReadWriteFlags("a + 1", "a", READ);
|
||||
}
|
||||
|
||||
// auto test(int a) {
|
||||
// return a <=> 1;
|
||||
// }
|
||||
public void testThreeWayComparisonAccess() throws Exception {
|
||||
AssertionHelper a = getCPP20AssertionHelper();
|
||||
a.assertReadWriteFlags("a <=> 1", "a", READ);
|
||||
}
|
||||
|
||||
// class C {
|
||||
// public:
|
||||
// C(int);
|
||||
|
|
Loading…
Add table
Reference in a new issue