selftest.h: Add ASSERT_TRUE_AT and ASSERT_FALSE_AT
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 4 Aug 2016 21:12:52 +0000 (21:12 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Thu, 4 Aug 2016 21:12:52 +0000 (21:12 +0000)
gcc/ChangeLog:
* selftest.h (ASSERT_TRUE): Reimplement in terms of...
(ASSERT_TRUE_AT): New macro.
(ASSERT_FALSE): Reimplement in terms of...
(ASSERT_FALSE_AT): New macro.
(ASSERT_STREQ_AT): Fix typo in comment.

From-SVN: r239151

gcc/ChangeLog
gcc/selftest.h

index 6c1e81692a9e0e6983e974f814b72602070345d6..025476c075900cba23901c1fe68493b660bd4f22 100644 (file)
@@ -1,3 +1,11 @@
+2016-08-04  David Malcolm  <dmalcolm@redhat.com>
+
+       * selftest.h (ASSERT_TRUE): Reimplement in terms of...
+       (ASSERT_TRUE_AT): New macro.
+       (ASSERT_FALSE): Reimplement in terms of...
+       (ASSERT_FALSE_AT): New macro.
+       (ASSERT_STREQ_AT): Fix typo in comment.
+
 2016-08-04  Patrick Palka  <ppalka@gcc.gnu.org>
 
        * gimple.c (preprocess_case_label_vec_for_gimple): When the case
index 0bee4764890d960d6d7b89fc62ec32104360b3ce..397e998048b9ac007701c1da13505211d9f16181 100644 (file)
@@ -104,13 +104,19 @@ extern int num_passes;
    ::selftest::fail if it false.  */
 
 #define ASSERT_TRUE(EXPR)                              \
+  ASSERT_TRUE_AT (SELFTEST_LOCATION, (EXPR))
+
+/* Like ASSERT_TRUE, but treat LOC as the effective location of the
+   selftest.  */
+
+#define ASSERT_TRUE_AT(LOC, EXPR)                      \
   SELFTEST_BEGIN_STMT                                  \
   const char *desc = "ASSERT_TRUE (" #EXPR ")";                \
   bool actual = (EXPR);                                        \
   if (actual)                                          \
-    ::selftest::pass (SELFTEST_LOCATION, desc);        \
+    ::selftest::pass ((LOC), desc);                    \
   else                                                 \
-    ::selftest::fail (SELFTEST_LOCATION, desc);                \
+    ::selftest::fail ((LOC), desc);                    \
   SELFTEST_END_STMT
 
 /* Evaluate EXPR and coerce to bool, calling
@@ -118,13 +124,19 @@ extern int num_passes;
    ::selftest::fail if it true.  */
 
 #define ASSERT_FALSE(EXPR)                                     \
+  ASSERT_FALSE_AT (SELFTEST_LOCATION, (EXPR))
+
+/* Like ASSERT_FALSE, but treat LOC as the effective location of the
+   selftest.  */
+
+#define ASSERT_FALSE_AT(LOC, EXPR)                             \
   SELFTEST_BEGIN_STMT                                          \
-  const char *desc = "ASSERT_FALSE (" #EXPR ")";               \
-  bool actual = (EXPR);                                        \
-  if (actual)                                                  \
-    ::selftest::fail (SELFTEST_LOCATION, desc);                                \
-  else                                                         \
-    ::selftest::pass (SELFTEST_LOCATION, desc);                                \
+  const char *desc = "ASSERT_FALSE (" #EXPR ")";                       \
+  bool actual = (EXPR);                                                        \
+  if (actual)                                                          \
+    ::selftest::fail ((LOC), desc);                    \
+  else                                                                 \
+    ::selftest::pass ((LOC), desc);                                    \
   SELFTEST_END_STMT
 
 /* Evaluate EXPECTED and ACTUAL and compare them with ==, calling
@@ -169,7 +181,7 @@ extern int num_passes;
                            (EXPECTED), (ACTUAL));                  \
   SELFTEST_END_STMT
 
-/* Like ASSERT_STREQ_AT, but treat LOC as the effective location of the
+/* Like ASSERT_STREQ, but treat LOC as the effective location of the
    selftest.  */
 
 #define ASSERT_STREQ_AT(LOC, EXPECTED, ACTUAL)                     \