Skip to content

Commit

Permalink
TestAstUtils: changed a few isSameExpressionTest() asserts to TODO …
Browse files Browse the repository at this point in the history
…/ added some TODOs about missing test coverage
  • Loading branch information
firewave committed Dec 4, 2023
1 parent 3707019 commit 6944e25
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/testastutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,13 @@ class TestAstUtils : public TestFixture {
Library library;
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); // TODO: test with C
const Token * const tok1 = Token::findsimplematch(tokenizer.tokens(), tokStr1, strlen(tokStr1));
const Token * const tok2 = Token::findsimplematch(tok1->next(), tokStr2, strlen(tokStr2));
return (isSameExpression)(false, tok1, tok2, library, false, true, nullptr);
}

// TODO: we used to tokenize this as C++ but check the expressions forcefully as C
void isSameExpressionTest() {
ASSERT_EQUALS(true, isSameExpression("x = 1 + 1;", "1", "1"));
ASSERT_EQUALS(false, isSameExpression("x = 1 + 1u;", "1", "1u"));
Expand All @@ -196,11 +197,11 @@ class TestAstUtils : public TestFixture {
ASSERT_EQUALS(false, isSameExpression("x < y;", "x", "y"));
ASSERT_EQUALS(true, isSameExpression("(x + 1) < (x + 1);", "+", "+"));
ASSERT_EQUALS(false, isSameExpression("(x + 1) < (x + 1L);", "+", "+"));
ASSERT_EQUALS(true, isSameExpression("(1 + x) < (x + 1);", "+", "+"));
TODO_ASSERT_EQUALS(true, false, isSameExpression("(1 + x) < (x + 1);", "+", "+"));
ASSERT_EQUALS(false, isSameExpression("(1.0l + x) < (1.0 + x);", "+", "+"));
ASSERT_EQUALS(true, isSameExpression("(0.0 + x) < (x + 0x0p+0);", "+", "+"));
TODO_ASSERT_EQUALS(true, false, isSameExpression("(0.0 + x) < (x + 0x0p+0);", "+", "+"));
ASSERT_EQUALS(true, isSameExpression("void f() {double y = 1e1; (x + y) < (x + 10.0); } ", "+", "+"));
ASSERT_EQUALS(true, isSameExpression("void f() {double y = 1e1; (x + 10.0) < (y + x); } ", "+", "+"));
TODO_ASSERT_EQUALS(true, false, isSameExpression("void f() {double y = 1e1; (x + 10.0) < (y + x); } ", "+", "+"));
ASSERT_EQUALS(true, isSameExpression("void f() {double y = 1e1; double z = 10.0; (x + y) < (x + z); } ", "+", "+"));
ASSERT_EQUALS(true, isSameExpression("A + A", "A", "A"));

Expand All @@ -217,7 +218,7 @@ class TestAstUtils : public TestFixture {
const Settings settings;
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); // TODO: test with C
const Token * const tok1 = Token::findsimplematch(tokenizer.tokens(), startPattern, strlen(startPattern));
const Token * const tok2 = Token::findsimplematch(tokenizer.tokens(), endPattern, strlen(endPattern));
return (isVariableChanged)(tok1, tok2, 1, false, &settings);
Expand Down Expand Up @@ -393,7 +394,7 @@ class TestAstUtils : public TestFixture {
const Settings settings = settingsBuilder().library("std.cfg").build();
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); // TODO: test with C
const Token* const start = Token::findsimplematch(tokenizer.tokens(), startPattern, strlen(startPattern));
const Token* const end = Token::findsimplematch(start, endPattern, strlen(endPattern));
const Token* const expr = Token::findsimplematch(tokenizer.tokens(), var, strlen(var));
Expand Down

0 comments on commit 6944e25

Please sign in to comment.