From 361fc44005be1173dc3f912b04188db73b10effa Mon Sep 17 00:00:00 2001 From: amai2012 Date: Fri, 19 Apr 2019 20:53:07 +0200 Subject: [PATCH] Adjust more test results for invalid code --- test/testastutils.cpp | 8 +++---- test/testsimplifytemplate.cpp | 2 +- test/testtokenize.cpp | 44 +++++++++++++++++------------------ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/test/testastutils.cpp b/test/testastutils.cpp index 1a396f9ad..49e66a542 100644 --- a/test/testastutils.cpp +++ b/test/testastutils.cpp @@ -143,10 +143,10 @@ private: void isVariableChanged() { // #8211 - no lhs for >> , do not crash - ASSERT_THROW(isVariableChanged("void f() {\n" - " int b;\n" - " if (b) { (int)((INTOF(8))result >> b); }\n" - "}", "if", "}"), InternalError);; + isVariableChanged("void f() {\n" + " int b;\n" + " if (b) { (int)((INTOF(8))result >> b); }\n" + "}", "if", "}"); } bool isVariableChangedByFunctionCall(const char code[], const char pattern[], bool *inconclusive) { diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 36f87c21c..4ce38708f 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -990,7 +990,7 @@ private: " return sizeof...(args);\n" " }();\n" "}"; - tok(code); + ASSERT_THROW(tok(code), InternalError); } void template43() { // #5097 - Assert due to '>>' in 'B>' not being treated as end of template instantiation diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 935c3ff01..3b93fcdda 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -1100,33 +1100,33 @@ private: // #4725 - ^{} void simplifyAsm2() { - ASSERT_EQUALS("void f ( ) { asm ( \"^{}\" ) ; }", tokenizeAndStringify("void f() { ^{} }")); - ASSERT_EQUALS("void f ( ) { x ( asm ( \"^{}\" ) ) ; }", tokenizeAndStringify("void f() { x(^{}); }")); - ASSERT_EQUALS("void f ( ) { foo ( A ( ) , asm ( \"^{bar();}\" ) ) ; }", tokenizeAndStringify("void f() { foo(A(), ^{ bar(); }); }")); - ASSERT_EQUALS("int f0 ( Args args ) { asm ( \"asm(\"return^{returnsizeof...(Args);}()\")+^{returnsizeof...(args);}()\" )\n" - "2:\n" - "|\n" - "5:\n" - "6: ;\n" - "} ;", tokenizeAndStringify("int f0(Args args) {\n" - " return ^{\n" - " return sizeof...(Args);\n" - " }() + ^ {\n" - " return sizeof...(args);\n" - " }();\n" - "};")); - ASSERT_EQUALS("int ( ^ block ) ( void ) = asm ( \"^{staticinttest=0;returntest;}\" )\n\n\n;", - tokenizeAndStringify("int(^block)(void) = ^{\n" + ASSERT_THROW(ASSERT_EQUALS("void f ( ) { asm ( \"^{}\" ) ; }", tokenizeAndStringify("void f() { ^{} }")), InternalError); + ASSERT_THROW(ASSERT_EQUALS("void f ( ) { x ( asm ( \"^{}\" ) ) ; }", tokenizeAndStringify("void f() { x(^{}); }")), InternalError); + ASSERT_THROW(ASSERT_EQUALS("void f ( ) { foo ( A ( ) , asm ( \"^{bar();}\" ) ) ; }", tokenizeAndStringify("void f() { foo(A(), ^{ bar(); }); }")), InternalError); + ASSERT_THROW(ASSERT_EQUALS("int f0 ( Args args ) { asm ( \"asm(\"return^{returnsizeof...(Args);}()\")+^{returnsizeof...(args);}()\" )\n" + "2:\n" + "|\n" + "5:\n" + "6: ;\n" + "} ;", tokenizeAndStringify("int f0(Args args) {\n" + " return ^{\n" + " return sizeof...(Args);\n" + " }() + ^ {\n" + " return sizeof...(args);\n" + " }();\n" + "};")), InternalError); + ASSERT_THROW(ASSERT_EQUALS("int ( ^ block ) ( void ) = asm ( \"^{staticinttest=0;returntest;}\" )\n\n\n;", + tokenizeAndStringify("int(^block)(void) = ^{\n" " static int test = 0;\n" " return test;\n" - "};")); + "};")), InternalError); - ASSERT_EQUALS("; return f ( a [ b = c ] , asm ( \"^{}\" ) ) ;", - tokenizeAndStringify("; return f(a[b=c],^{});")); // #7185 + ASSERT_THROW(ASSERT_EQUALS("; return f ( a [ b = c ] , asm ( \"^{}\" ) ) ;", + tokenizeAndStringify("; return f(a[b=c],^{});")), InternalError); // #7185 ASSERT_EQUALS("; return f ( asm ( \"^(void){somecode}\" ) ) ;", tokenizeAndStringify("; return f(^(void){somecode});")); - ASSERT_EQUALS("; asm ( \"a?(b?(c,asm(\"^{}\")):0):^{}\" ) ;", - tokenizeAndStringify(";a?(b?(c,^{}):0):^{};")); + ASSERT_THROW(ASSERT_EQUALS("; asm ( \"a?(b?(c,asm(\"^{}\")):0):^{}\" ) ;", + tokenizeAndStringify(";a?(b?(c,^{}):0):^{};")), InternalError); ASSERT_EQUALS("template < typename T > " "CImg < T > operator| ( const char * const expression , const CImg < T > & img ) { " "return img | expression ; "