• R/O
  • SSH
  • HTTPS

iutest: コミット


コミットメタ情報

リビジョン1350 (tree)
日時2018-10-17 23:57:34
作者srz_zumix

ログメッセージ

Merge remote-tracking branch 'origin/develop'

git@8b4dd7b36bde05b1dfe9f2eeb0a5fa14715a0c4a
https://github.com/srz-zumix/iutest/commit/8b4dd7b36bde05b1dfe9f2eeb0a5fa14715a0c4a

変更サマリ

差分

--- trunk/LICENSE (revision 1349)
+++ trunk/LICENSE (revision 1350)
@@ -1,3 +1,5 @@
1+BSD 3-Clause License
2+
13 Copyright (c) 2011-2018, Takazumi Shirayanagi
24 All rights reserved.
35
@@ -11,7 +13,7 @@
1113 this list of conditions and the following disclaimer in the documentation
1214 and/or other materials provided with the distribution.
1315
14-* Neither the name of iutest nor the names of its
16+* Neither the name of the copyright holder nor the names of its
1517 contributors may be used to endorse or promote products derived from
1618 this software without specific prior written permission.
1719
--- trunk/include/internal/iutest_compiler.hpp (revision 1349)
+++ trunk/include/internal/iutest_compiler.hpp (revision 1350)
@@ -175,7 +175,7 @@
175175 //! inline variable
176176 #if !defined(IUTEST_HAS_INLINE_VARIABLE)
177177 #if defined(__clang__)
178-# if (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 9)) && IUTEST_HAS_CXX1Z
178+# if IUTEST_HAS_CXX1Z && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 9))
179179 # define IUTEST_HAS_INLINE_VARIABLE 1
180180 # endif
181181 #endif
@@ -1099,7 +1099,7 @@
10991099 //! has __if_exists
11001100 #if !defined(IUTEST_HAS_IF_EXISTS)
11011101 # if defined(__clang__)
1102-# if (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 5) ) && IUTEST_HAS_MS_EXTENSIONS
1102+# if IUTEST_HAS_MS_EXTENSIONS && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 5) )
11031103 # define IUTEST_HAS_IF_EXISTS 1
11041104 # endif
11051105 # elif defined(_MSC_VER) && _MSC_VER >= 1310
@@ -1145,7 +1145,7 @@
11451145 # define IUTEST_HAS_MS_CXX_MODULE 0
11461146 #endif
11471147
1148-#if defined(IUTEST_MODULE_EXPORT)
1148+#if IUTEST_HAS_MS_CXX_MODULE
11491149 # define IUTEST_CXX_MODULE_EXPORT export
11501150 #else
11511151 # define IUTEST_CXX_MODULE_EXPORT
--- trunk/include/internal/iutest_core_impl.hpp (revision 1349)
+++ trunk/include/internal/iutest_core_impl.hpp (revision 1350)
@@ -141,7 +141,7 @@
141141 void TerminateImpl();
142142
143143 private:
144-#if IUTEST_HAS_EXCEPTIONS && (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(IUTEST_OS_WINDOWS_MOBILE)
144+#if IUTEST_HAS_INVALID_PARAMETER_HANDLER
145145
146146 IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN()
147147
--- trunk/include/internal/iutest_exception.hpp (revision 1349)
+++ trunk/include/internal/iutest_exception.hpp (revision 1350)
@@ -6,7 +6,7 @@
66 *
77 * @author t.shirayanagi
88 * @par copyright
9- * Copyright (C) 2011-2016, Takazumi Shirayanagi\n
9+ * Copyright (C) 2011-2018, Takazumi Shirayanagi\n
1010 * This software is released under the new BSD License,
1111 * see LICENSE
1212 */
@@ -48,7 +48,7 @@
4848 } // end of namespace detail
4949 } // end of namespace iutest
5050
51-#if IUTEST_HAS_EXCEPTIONS && IUTEST_HAS_SEH
51+#if IUTEST_HAS_SEH && IUTEST_HAS_EXCEPTIONS
5252 #include <iomanip>
5353
5454 namespace iutest {
--- trunk/include/internal/iutest_stdlib.hpp (revision 1349)
+++ trunk/include/internal/iutest_stdlib.hpp (revision 1350)
@@ -668,6 +668,17 @@
668668 # define IUTEST_HAS_STRSTREAM 0
669669 #endif
670670
671+//! _set_invalid_parameter_handler が使用可能かどうか
672+#if !defined(IUTEST_HAS_INVALID_PARAMETER_HANDLER)
673+# if IUTEST_HAS_EXCEPTIONS && (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(IUTEST_OS_WINDOWS_MOBILE)
674+# define IUTEST_HAS_INVALID_PARAMETER_HANDLER 1
675+# endif
676+#endif
677+
678+#if !defined(IUTEST_HAS_INVALID_PARAMETER_HANDLER)
679+# define IUTEST_HAS_INVALID_PARAMETER_HANDLER 0
680+#endif
681+
671682 namespace iutest {
672683 namespace detail
673684 {
--- trunk/include/internal/iutest_string.hpp (revision 1349)
+++ trunk/include/internal/iutest_string.hpp (revision 1350)
@@ -155,8 +155,8 @@
155155 */
156156 inline int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va)
157157 {
158-#if defined(__CYGWIN__) && defined(__STRICT_ANSI__) \
159- && (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) && (__cplusplus >= 201103L)
158+#if defined(__CYGWIN__) \
159+ && (defined(__STRICT_ANSI__) && (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) && (__cplusplus >= 201103L))
160160 return wrapper::iu_vsnprintf(dst, size, format, va);
161161 #elif (defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)) && defined(__STRICT_ANSI__)
162162 return wrapper::iu_vsnprintf(dst, size, format, va);
--- trunk/include/iutest_assertion.hpp (revision 1349)
+++ trunk/include/iutest_assertion.hpp (revision 1350)
@@ -6,7 +6,7 @@
66 *
77 * @author t.shirayanagi
88 * @par copyright
9- * Copyright (C) 2011-2017, Takazumi Shirayanagi\n
9+ * Copyright (C) 2011-2018, Takazumi Shirayanagi\n
1010 * This software is released under the new BSD License,
1111 * see LICENSE
1212 */
@@ -475,8 +475,8 @@
475475 IIUT_DECL_COMPARE_HELPER_(GE, >=)
476476 IIUT_DECL_COMPARE_HELPER_(GT, > )
477477
478-#undef DECL_COMPARE_HELPER_I_
479-#undef DECL_COMPARE_HELPER_
478+#undef IIUT_DECL_COMPARE_HELPER_I_
479+#undef IIUT_DECL_COMPARE_HELPER_
480480
481481 /**
482482 * @}
--- trunk/include/iutest_config.hpp (revision 1349)
+++ trunk/include/iutest_config.hpp (revision 1350)
@@ -329,7 +329,7 @@
329329
330330 #if !defined(IUTEST_HAS_CATCH_SEH_EXCEPTION_ASSERTION)
331331 //! 例外アサーションで SEH をキャッチ可能かどうか
332-# if IUTEST_HAS_LAMBDA_STATEMENTS && IUTEST_HAS_SEH
332+# if IUTEST_HAS_SEH && IUTEST_HAS_LAMBDA_STATEMENTS
333333 # define IUTEST_HAS_CATCH_SEH_EXCEPTION_ASSERTION 1
334334 # else
335335 # define IUTEST_HAS_CATCH_SEH_EXCEPTION_ASSERTION 0
--- trunk/include/iutest_core.hpp (revision 1349)
+++ trunk/include/iutest_core.hpp (revision 1350)
@@ -126,7 +126,7 @@
126126 int Run();
127127
128128 private:
129-#if IUTEST_HAS_EXCEPTIONS && IUTEST_HAS_SEH
129+#if IUTEST_HAS_SEH && IUTEST_HAS_EXCEPTIONS
130130 int RunOnMSC();
131131 #endif
132132 int RunImpl();
--- trunk/include/iutest_info.hpp (revision 1349)
+++ trunk/include/iutest_info.hpp (revision 1350)
@@ -182,7 +182,7 @@
182182 private:
183183 void RunImpl();
184184
185-#if IUTEST_HAS_EXCEPTIONS && IUTEST_HAS_SEH
185+#if IUTEST_HAS_SEH && IUTEST_HAS_EXCEPTIONS
186186 #if IUTEST_HAS_MINIDUMP
187187 void MiniDump(_EXCEPTION_POINTERS* ep);
188188 #endif
--- trunk/include/iutest_matcher.hpp (revision 1349)
+++ trunk/include/iutest_matcher.hpp (revision 1350)
@@ -84,7 +84,7 @@
8484 * @{
8585 */
8686
87-#define DECL_COMPARE_MATCHER(name, op) \
87+#define IIUT_DECL_COMPARE_MATCHER(name, op) \
8888 template<typename T>class IUTEST_PP_CAT(name, Matcher): public IMatcher{ \
8989 public: explicit IUTEST_PP_CAT(name, Matcher)(const T& v) : m_expected(v) {}\
9090 ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \
@@ -98,7 +98,7 @@
9898 private: const T& m_expected; \
9999 }
100100
101-#define DECL_COMPARE_MATCHER2(name, op) \
101+#define IIUT_DECL_COMPARE_MATCHER2(name, op) \
102102 class IUTEST_PP_CAT(Twofold, IUTEST_PP_CAT(name, Matcher)): public IMatcher{ \
103103 public: ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { return #name; } \
104104 template<typename T, typename U>AssertionResult operator () \
@@ -112,25 +112,25 @@
112112 IUTEST_PRAGMA_WARN_PUSH()
113113 IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE()
114114
115-DECL_COMPARE_MATCHER(Ne, !=);
116-DECL_COMPARE_MATCHER(Le, <=);
117-DECL_COMPARE_MATCHER(Lt, < );
118-DECL_COMPARE_MATCHER(Ge, >=);
119-DECL_COMPARE_MATCHER(Gt, > );
115+IIUT_DECL_COMPARE_MATCHER(Ne, !=);
116+IIUT_DECL_COMPARE_MATCHER(Le, <=);
117+IIUT_DECL_COMPARE_MATCHER(Lt, < );
118+IIUT_DECL_COMPARE_MATCHER(Ge, >=);
119+IIUT_DECL_COMPARE_MATCHER(Gt, > );
120120
121-DECL_COMPARE_MATCHER2(Eq, ==);
122-DECL_COMPARE_MATCHER2(Ne, !=);
123-DECL_COMPARE_MATCHER2(Le, <=);
124-DECL_COMPARE_MATCHER2(Lt, < );
125-DECL_COMPARE_MATCHER2(Ge, >=);
126-DECL_COMPARE_MATCHER2(Gt, > );
121+IIUT_DECL_COMPARE_MATCHER2(Eq, ==);
122+IIUT_DECL_COMPARE_MATCHER2(Ne, !=);
123+IIUT_DECL_COMPARE_MATCHER2(Le, <=);
124+IIUT_DECL_COMPARE_MATCHER2(Lt, < );
125+IIUT_DECL_COMPARE_MATCHER2(Ge, >=);
126+IIUT_DECL_COMPARE_MATCHER2(Gt, > );
127127
128128 IUTEST_PRAGMA_WARN_POP()
129129
130-#undef DECL_COMPARE_MATCHER
131-#undef DECL_COMPARE_MATCHER2
130+#undef IIUT_DECL_COMPARE_MATCHER
131+#undef IIUT_DECL_COMPARE_MATCHER2
132132
133-#define DECL_STR_COMPARE_MATCHER(name) \
133+#define IIUT_DECL_STR_COMPARE_MATCHER(name) \
134134 template<typename T>class IUTEST_PP_CAT(name, Matcher): public IMatcher { \
135135 public: IUTEST_PP_CAT(name, Matcher)(const T& value) : m_expected(value) {} \
136136 template<typename U>AssertionResult operator ()(const U& actual) const { \
@@ -146,12 +146,12 @@
146146 const T& m_expected; \
147147 }
148148
149-DECL_STR_COMPARE_MATCHER(StrEq);
150-DECL_STR_COMPARE_MATCHER(StrNe);
151-DECL_STR_COMPARE_MATCHER(StrCaseEq);
152-DECL_STR_COMPARE_MATCHER(StrCaseNe);
149+IIUT_DECL_STR_COMPARE_MATCHER(StrEq);
150+IIUT_DECL_STR_COMPARE_MATCHER(StrNe);
151+IIUT_DECL_STR_COMPARE_MATCHER(StrCaseEq);
152+IIUT_DECL_STR_COMPARE_MATCHER(StrCaseNe);
153153
154-#undef DECL_COMPARE_MATCHER
154+#undef IIUT_DECL_COMPARE_MATCHER
155155
156156 /**
157157 * @}
--- trunk/include/iutest_package.hpp (revision 1349)
+++ trunk/include/iutest_package.hpp (revision 1350)
@@ -31,11 +31,11 @@
3131
3232 #if IUTEST_HAS_PACKAGE
3333
34-#define IUTEST_CONCAT_PACKAGE_(testcase_name) IIUT_CONCAT_PACKAGE_I(testcase_name)
35-#define IIUT_CONCAT_PACKAGE_I(testcase_name) \
34+#define IUTEST_CONCAT_PACKAGE_(testcasename_) IIUT_CONCAT_PACKAGE_I(testcasename_)
35+#define IIUT_CONCAT_PACKAGE_I(testcasename_) \
3636 iuTest_ConcatTestCaseName( iuTest_GetTestCasePackageName( \
3737 static_cast<iuTest_TestCasePackage*>(NULL)) \
38- , #testcase_name)
38+ , #testcasename_)
3939
4040 #define IUTEST_GET_PACKAGENAME_() \
4141 iuTest_GetTestCasePackageName( static_cast<iuTest_TestCasePackage*>(NULL) )
@@ -100,8 +100,8 @@
100100
101101 #else
102102
103-#define IUTEST_CONCAT_PACKAGE_(testcase_name) IIUT_CONCAT_PACKAGE_I(testcase_name)
104-#define IIUT_CONCAT_PACKAGE_I(testcase_name) #testcase_name
103+#define IUTEST_CONCAT_PACKAGE_(testcasename_) IIUT_CONCAT_PACKAGE_I(testcasename_)
104+#define IIUT_CONCAT_PACKAGE_I(testcasename_) #testcasename_
105105 #define IIUT_PACKAGE_(name) namespace name
106106 #define IUTEST_GET_PACKAGENAME_() ""
107107
--- trunk/include/iutest_prod.hpp (revision 1349)
+++ trunk/include/iutest_prod.hpp (revision 1350)
@@ -20,8 +20,8 @@
2020 /**
2121 * @brief テストから見えるように fried 登録
2222 */
23-#define IUTEST_FRIEND_TEST(test_case_name, test_name) \
24- friend class IUTEST_TEST_CLASS_NAME_(test_case_name, test_name)
23+#define IUTEST_FRIEND_TEST(testcasename_, testname_) \
24+ friend class IUTEST_TEST_CLASS_NAME_(testcasename_, testname_)
2525
2626 #if !defined(_MSC_VER) || _MSC_VER > 1200
2727
@@ -30,8 +30,8 @@
3030 /**
3131 * @brief テストから見えるように fried 登録(IUTEST_TYPED_TEST 用)
3232 */
33-#define IUTEST_FRIEND_TYPED_TEST(test_case_name, test_name) \
34- template<typename T>IUTEST_FRIEND_TEST(test_case_name, test_name)
33+#define IUTEST_FRIEND_TYPED_TEST(testcasename_, testname_) \
34+ template<typename T>IUTEST_FRIEND_TEST(testcasename_, testname_)
3535
3636 #endif
3737
@@ -40,14 +40,14 @@
4040 /**
4141 * @brief テストから見えるように fried 登録するための宣言
4242 */
43-#define IUTEST_FRIEND_TYPED_TEST_P_DECLARATION(test_case_name, test_name) \
44- namespace IIUT_TYPED_TEST_P_NAMESPACE_(test_case_name) { template<typename T>class test_name; }
43+#define IUTEST_FRIEND_TYPED_TEST_P_DECLARATION(testcasename_, testname_) \
44+ namespace IIUT_TYPED_TEST_P_NAMESPACE_(testcasename_) { template<typename T>class testname_; }
4545
4646 /**
4747 * @brief テストから見えるように fried 登録(IUTEST_TYPED_TEST_P 用)
4848 */
49-#define IUTEST_FRIEND_TYPED_TEST_P(test_case_name, test_name) \
50- template<typename T>friend class IIUT_TYPED_TEST_P_NAMESPACE_(test_case_name)::test_name
49+#define IUTEST_FRIEND_TYPED_TEST_P(testcasename_, testname_) \
50+ template<typename T>friend class IIUT_TYPED_TEST_P_NAMESPACE_(testcasename_)::testname_
5151
5252 #endif
5353
@@ -172,7 +172,7 @@
172172 }
173173 #else
174174
175-#define PEEP_DECL_MEMBER_FUNC_(n) \
175+#define IIUT_DECL_PEEP_MEMBER_FUNC_(n) \
176176 template<IUTEST_PP_ENUM_PARAMS(n, typename T)>return_type operator () ( \
177177 IUTEST_PP_ENUM_BINARY_PARAMS(n, T, t)) { \
178178 return ((*m_ptr).*detail::peep_tag<peep_tag>::value)(IUTEST_PP_ENUM_PARAMS(n, t)); }
@@ -179,28 +179,28 @@
179179
180180 return_type operator () () { return ((*m_ptr).*detail::peep_tag<peep_tag>::value)(); }
181181
182- PEEP_DECL_MEMBER_FUNC_(1)
183- PEEP_DECL_MEMBER_FUNC_(2)
184- PEEP_DECL_MEMBER_FUNC_(3)
185- PEEP_DECL_MEMBER_FUNC_(4)
186- PEEP_DECL_MEMBER_FUNC_(5)
187- PEEP_DECL_MEMBER_FUNC_(6)
188- PEEP_DECL_MEMBER_FUNC_(7)
189- PEEP_DECL_MEMBER_FUNC_(8)
190- PEEP_DECL_MEMBER_FUNC_(9)
191- PEEP_DECL_MEMBER_FUNC_(10)
192- PEEP_DECL_MEMBER_FUNC_(11)
193- PEEP_DECL_MEMBER_FUNC_(12)
194- PEEP_DECL_MEMBER_FUNC_(13)
195- PEEP_DECL_MEMBER_FUNC_(14)
196- PEEP_DECL_MEMBER_FUNC_(15)
197- PEEP_DECL_MEMBER_FUNC_(16)
198- PEEP_DECL_MEMBER_FUNC_(17)
199- PEEP_DECL_MEMBER_FUNC_(18)
200- PEEP_DECL_MEMBER_FUNC_(19)
201- PEEP_DECL_MEMBER_FUNC_(20)
182+ IIUT_DECL_PEEP_MEMBER_FUNC_(1)
183+ IIUT_DECL_PEEP_MEMBER_FUNC_(2)
184+ IIUT_DECL_PEEP_MEMBER_FUNC_(3)
185+ IIUT_DECL_PEEP_MEMBER_FUNC_(4)
186+ IIUT_DECL_PEEP_MEMBER_FUNC_(5)
187+ IIUT_DECL_PEEP_MEMBER_FUNC_(6)
188+ IIUT_DECL_PEEP_MEMBER_FUNC_(7)
189+ IIUT_DECL_PEEP_MEMBER_FUNC_(8)
190+ IIUT_DECL_PEEP_MEMBER_FUNC_(9)
191+ IIUT_DECL_PEEP_MEMBER_FUNC_(10)
192+ IIUT_DECL_PEEP_MEMBER_FUNC_(11)
193+ IIUT_DECL_PEEP_MEMBER_FUNC_(12)
194+ IIUT_DECL_PEEP_MEMBER_FUNC_(13)
195+ IIUT_DECL_PEEP_MEMBER_FUNC_(14)
196+ IIUT_DECL_PEEP_MEMBER_FUNC_(15)
197+ IIUT_DECL_PEEP_MEMBER_FUNC_(16)
198+ IIUT_DECL_PEEP_MEMBER_FUNC_(17)
199+ IIUT_DECL_PEEP_MEMBER_FUNC_(18)
200+ IIUT_DECL_PEEP_MEMBER_FUNC_(19)
201+ IIUT_DECL_PEEP_MEMBER_FUNC_(20)
202202
203-#undef IUTEST_DECL_PEEP_MEMBER_FUNC_
203+#undef IIUT_DECL_PEEP_MEMBER_FUNC_
204204 #endif
205205 };
206206 template<typename U, typename Type, bool is_const>
--- trunk/include/iutest_ver.hpp (revision 1349)
+++ trunk/include/iutest_ver.hpp (revision 1350)
@@ -17,11 +17,11 @@
1717
1818 //======================================================================
1919 // define
20-#define IUTEST_VER 0x01169902u //!< iutest version 1.16.99.2
20+#define IUTEST_VER 0x01169903u //!< iutest version 1.16.99.3
2121 #define IUTEST_MAJORVER 0x01u //!< Major Version
2222 #define IUTEST_MINORVER 0x16u //!< Minor Version
2323 #define IUTEST_MICROVER 0x99u //!< Micro Version
24-#define IUTEST_REVISION 0x02u //!< Revision
24+#define IUTEST_REVISION 0x03u //!< Revision
2525
2626 #define IUTEST_BUILD IUTEST_MICROVER //!< @deprecated
2727
--- trunk/include/listener/iutest_default_printer.hpp (revision 1349)
+++ trunk/include/listener/iutest_default_printer.hpp (revision 1350)
@@ -6,7 +6,7 @@
66 *
77 * @author t.shirayanagi
88 * @par copyright
9- * Copyright (C) 2011-2016, Takazumi Shirayanagi\n
9+ * Copyright (C) 2011-2018, Takazumi Shirayanagi\n
1010 * This software is released under the new BSD License,
1111 * see LICENSE
1212 */
@@ -49,6 +49,9 @@
4949 virtual void OnTestIterationEnd(const UnitTest& test
5050 , int iteration) IUTEST_CXX_OVERRIDE;
5151 virtual void OnTestProgramEnd(const UnitTest& test) IUTEST_CXX_OVERRIDE;
52+
53+private:
54+ void PrintTestResult(const TestInfo& test_info) const;
5255 };
5356
5457 } // end of namespace iutest
--- trunk/include/util/iutest_util_assertion.hpp (revision 1349)
+++ trunk/include/util/iutest_util_assertion.hpp (revision 1350)
@@ -6,7 +6,7 @@
66 *
77 * @author t.shirayanagi
88 * @par copyright
9- * Copyright (C) 2012-2016, Takazumi Shirayanagi\n
9+ * Copyright (C) 2012-2018, Takazumi Shirayanagi\n
1010 * This software is released under the new BSD License,
1111 * see LICENSE
1212 */
@@ -391,6 +391,8 @@
391391 * @{
392392 */
393393
394+#ifndef IUTEST_NO_UTIL_ASSERTION_GTEST_COMPATIBLE
395+
394396 #define ASSERT_EQ_COLLECTIONS IUTEST_ASSERT_EQ_COLLECTIONS
395397 #define ASSERT_EQ_RANGE IUTEST_ASSERT_EQ_RANGE
396398 #define ASSERT_STRLNEQ IUTEST_ASSERT_STRLNEQ
@@ -439,6 +441,8 @@
439441
440442 #endif
441443
444+#endif
445+
442446 /**
443447 * @}
444448 */
@@ -916,20 +920,6 @@
916920
917921 #endif
918922
919-/**
920- * @private
921- * @{
922-*/
923-#define IIUT_COMPARE_HELPER_DEC_(name) struct name { \
924- template<typename T1, typename T2> \
925- static ::iutest::AssertionResult Comp(const char* expr1, const char* expr2, const T1& val1, const T2& val2) { \
926- return ::iutest::internal::CmpHelper##name(expr1, expr2, val1, val2); \
927- } \
928- }
929-/**
930- * @}
931-*/
932-
933923 } // end of namespace iuutil
934924
935925 #endif // INCG_IRIS_IUTEST_UTIL_ASSERTION_HPP_A45F8265_40E0_44F2_91C6_090B1778657C_
--- trunk/projects/android/iutest_sample/AndroidManifest.xml (revision 1349)
+++ trunk/projects/android/iutest_sample/AndroidManifest.xml (revision 1350)
@@ -3,6 +3,7 @@
33 package="jp.iutest_sample"
44 android:versionCode="1"
55 android:versionName="1.0">
6+ <uses-sdk android:minSdkVersion="21">
67 <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
78 <activity android:name="iutest_sample_activity"
89 android:label="@string/app_name">
--- trunk/tools/fused/.gitignore (nonexistent)
+++ trunk/tools/fused/.gitignore (revision 1350)
@@ -0,0 +1,2 @@
1+# execute files
2+*_test
--- trunk/tools/fused/Makefile (revision 1349)
+++ trunk/tools/fused/Makefile (revision 1350)
@@ -23,15 +23,49 @@
2323 # fused-src directory
2424 FUSED_DIR = $(IUTEST_DIR)/fused-src
2525
26+# fused src output
27+FUSED_TARGETS=iutest.hpp iutest.min.hpp
28+FUSED_WANDBOX_TARGET=iutest.wandbox.min.hpp
29+OUTPUTS_TARGETS=$(FUSED_TARGETS) $(FUSED_WANDBOX_TARGET)
30+OUTPUTS=$(OUTPUTS_TARGETS:%=$(FUSED_DIR)/%)
2631
27-default: $(FUSED_DIR) $(IUTEST_HEADERS) fused_iutest_files.py Makefile
32+default: fused wandbox
33+
34+fused: iutest.hpp iutest.min.hpp
35+
36+$(FUSED_TARGETS): fused_impl
37+
38+fused_impl: $(FUSED_DIR) $(IUTEST_HEADERS) fused_iutest_files.py Makefile
2839 python fused_iutest_files.py $(FUSED_DIR)
2940
30-min: default
41+min: fused
3142 mv $(FUSED_DIR)/iutest.min.hpp $(FUSED_DIR)/iutest.hpp
3243
44+wandbox: iutest.wandbox.min.hpp
45+
46+$(FUSED_WANDBOX_TARGET): fused
47+ python iuwandbox_pp.py
48+
49+wandbox_debug: fused
50+ python iuwandbox_pp.py debug
51+
52+ls:
53+ ls -lh ../../fused-src
54+
55+# tests
56+TEST_TARGETS=min_test wandbox_test
57+
58+min_test: fused
59+ g++ tests/test.min.cpp -o $@
60+ ./$@
61+
62+wandbox_test: wandbox
63+ g++ tests/test.wandbox.min.cpp -o $@
64+ ./$@
65+
3366 clean:
34- $(RM) -rf $(FUSED_DIR)
67+ $(RM) -rf $(OUTPUTS)
68+ $(RM) -rf $(TEST_TARGETS)
3569
3670 $(FUSED_DIR):
3771 @if [ ! -d $@ ]; then \
--- trunk/tools/fused/fused_iutest_files.py (revision 1349)
+++ trunk/tools/fused/fused_iutest_files.py (revision 1350)
@@ -184,6 +184,7 @@
184184
185185 find_ifdef = False
186186 fileset.add(path)
187+ # print(filename)
187188 for line in codecs.open(path, 'r', 'utf-8-sig'):
188189 line = re.sub('/\*.*?\*/', '', line)
189190 m = self.INCLUDE_REGEX.match(line)
--- trunk/tools/fused/iutest_pp_strip.py (nonexistent)
+++ trunk/tools/fused/iutest_pp_strip.py (revision 1350)
@@ -0,0 +1,625 @@
1+#!/usr/bin/env python
2+#
3+# iutest_pp_strip.py
4+#
5+# Copyright (C) 2018, Takazumi Shirayanagi
6+# This software is released under the new BSD License,
7+# see LICENSE
8+#
9+
10+import re
11+import collections
12+
13+RE_MACRO_SPLIT = re.compile('([\(\):;{} /%+\-=<>!&\|*#]+)')
14+RE_SPLIT_PAREN = re.compile('([\(\)])')
15+RE_FUNC_MACRO = re.compile('([\w_]+)\((.*?)\)')
16+RE_DEFINE = re.compile('#\s*define (\S+)\s*(.*)$')
17+RE_DEFINE_PARSE = re.compile('(.*)defined\((.*?)\)(.*)')
18+RE_HAS_INCLUDE = re.compile('(.*)__has_include\((.*?)\)(.*)')
19+RE_HAS_FEATURE = re.compile('(.*)__has_feature\((.*?)\)(.*)')
20+RE_SPLIT_OP = re.compile('(&&|\|\||!)')
21+RE_SYMBOLMARK = re.compile('([+\-=<>\(\)]+)')
22+RE_PPIF = re.compile('#\s*(ifdef|ifndef|if)\s*(.*)$')
23+RE_PPELIF = re.compile('#\s*elif\s*(.*)$')
24+RE_PPELSE = re.compile('#\s*else\s*$')
25+RE_PPENDIF = re.compile('#\s*endif')
26+RE_CPP_COMMENT = re.compile('^//.*')
27+RE_SYSTEM_INCLUDE_REGEX = re.compile(r'^\s*#\s*include\s*<(.*)>')
28+
29+RE_STRIP_INCG_REGEX = re.compile(r'^INCG_\S*_[IH]PP_\S+\Z')
30+
31+RE_EVAL_UNDEFINED_EXCEPTION = re.compile(r'^name \'(defined_.*)\' is not defined\Z')
32+
33+
34+class IutestPreprocessor:
35+ macros = {}
36+ depth_macros = [ {} ]
37+ expands_macros = []
38+ expand_function_macros = []
39+ iutest_config_macro = []
40+ included_path = [ [] ]
41+ has_include = {}
42+ has_features = {}
43+ unknowns = []
44+ depth = []
45+ brothers = []
46+ debug = False
47+ prev_line = None
48+
49+ def __init__(self
50+ , predefined_macros
51+ , iutest_config_macro
52+ , expand_function_macros
53+ , expands_macros
54+ , has_features
55+ , has_include):
56+ self.set_predefined_macros(predefined_macros)
57+ self.set_iutest_config_macro(iutest_config_macro)
58+ self.set_expand_function_macros(expand_function_macros)
59+ self.set_expands_macros(expands_macros)
60+ self.set_has_features(has_features)
61+ self.set_has_include(has_include)
62+
63+ def set_predefined_macros(self, predefined_macros):
64+ self.macros = predefined_macros
65+
66+ def set_iutest_config_macro(self, iutest_config_macro):
67+ self.iutest_config_macro = iutest_config_macro
68+ self.macros.update(iutest_config_macro)
69+
70+ def set_expands_macros(self, expands_macros):
71+ self.expands_macros = expands_macros
72+
73+ def set_expand_function_macros(self, expand_function_macros):
74+ self.expand_function_macros = expand_function_macros
75+
76+ def set_has_include(self, has_include):
77+ self.has_include = has_include
78+
79+ def set_has_features(self, has_features):
80+ self.has_features = has_features
81+
82+ def set_debug_flag(self, flag):
83+ self.debug = flag
84+
85+ def __expand_macro(self, line):
86+ dst = ""
87+ for s in RE_MACRO_SPLIT.split(line):
88+ if s in self.expands_macros:
89+ expand = self.__get_current_macro(s)
90+ if expand is not None:
91+ dst += expand
92+ continue
93+ dst += s
94+ return self.__expand_function_macro(dst)
95+
96+ def __expand_function_macro(self, line):
97+ dst = ""
98+ tokens = []
99+ prev = ""
100+ for s in RE_SPLIT_PAREN.split(line):
101+ if s == '(':
102+ tokens.append(prev)
103+ elif s == ')' and len(tokens) > 0:
104+ tokens[-1] += prev + s
105+ s = ""
106+ ss = tokens.pop()
107+ for m in RE_FUNC_MACRO.finditer(ss):
108+ d = m.group(1)
109+ if d in self.expand_function_macros:
110+ if d not in self.macros or self.macros[d] is None:
111+ ss = ss.replace(m.group(0), '')
112+ if len(tokens) > 0:
113+ tokens[-1] += ss
114+ else:
115+ dst += ss
116+ elif len(tokens) > 0:
117+ tokens[-1] += prev
118+ else:
119+ dst += prev
120+ prev = s
121+ for s in tokens:
122+ dst += s
123+ dst += prev
124+ return dst
125+
126+ def __has_current_macro(self, name):
127+ if name in self.macros:
128+ return True
129+ for m in self.depth_macros:
130+ if name in m:
131+ return True
132+ return False
133+
134+ def __get_current_macro(self, name):
135+ if name in self.macros:
136+ return self.macros[name]
137+ for m in self.depth_macros:
138+ if name in m:
139+ return m[name]
140+ return None
141+
142+ def __append_define(self, line):
143+ def append(d, v, depth, macros, unknowns, current):
144+ d = re.sub('\(.*\)', '', d)
145+ if len(v) == 0:
146+ if RE_STRIP_INCG_REGEX.match(d):
147+ self.expands_macros.append(d)
148+ v = 'defined'
149+ if any(x == -1 for x in depth):
150+ unknowns.append(d)
151+ current[d] = v
152+ else:
153+ macros[d] = v
154+ return d
155+ m = RE_DEFINE.match(line)
156+ if m:
157+ current_depth_macro = self.depth_macros[-1]
158+ return append(m.group(1), m.group(2), self.depth, self.macros, self.unknowns, current_depth_macro)
159+ return None
160+
161+ def __expand_ppif_macro(self, expr):
162+ expand = ""
163+ for s in RE_SPLIT_OP.split(expr):
164+ if s == '&&':
165+ expand += ' and '
166+ elif s == '||':
167+ expand += ' or '
168+ elif s == '!':
169+ expand += " not "
170+ else:
171+ m = RE_DEFINE_PARSE.match(s)
172+ if m:
173+ d = m.group(2)
174+ if self.__has_current_macro(d):
175+ expand += m.group(1)
176+ if self.__get_current_macro(d) is None:
177+ expand += ' (0) '
178+ else:
179+ expand += ' (1) '
180+ expand += m.group(3)
181+ elif d in self.unknowns:
182+ expand += s
183+ else:
184+ expand += s
185+ self.unknowns.append(d)
186+ continue
187+ m = RE_HAS_INCLUDE.match(s)
188+ if m:
189+ f = m.group(2)
190+ if f in self.has_include:
191+ expand += m.group(1) + self.has_include[f] + m.group(3)
192+ else:
193+ expand += s
194+ continue
195+ m = RE_HAS_FEATURE.match(s)
196+ if m:
197+ f = m.group(2)
198+ if f in self.has_features:
199+ expand += m.group(1) + self.has_features[f] + m.group(3)
200+ continue
201+ for w in RE_SYMBOLMARK.split(s.strip()):
202+ if RE_SYMBOLMARK.match(w) or w.isspace():
203+ expand += w
204+ elif len(w) > 0:
205+ if w in self.unknowns:
206+ expand += w
207+ elif w in self.macros:
208+ if self.macros[w] is None:
209+ expand += '0'
210+ else:
211+ expand += self.__expand_ppif_macro(self.macros[w])
212+ elif w.isdigit():
213+ expand += w
214+ else:
215+ expand += w
216+
217+ expand = expand.replace('0(0)', '(0)')
218+ expand = expand.replace('not =', '!=')
219+ expand = re.sub(r'not\s*\(0\)', '(1)', expand)
220+ return expand.strip()
221+
222+ def __eval_ppif_unknown_defined(self, expand):
223+ if 'defined' not in expand:
224+ return -1
225+ expand = re.sub(r'defined\((.*?)\)', 'defined_\\1', expand)
226+ try:
227+ r = eval(expand)
228+ except Exception as e:
229+ r = self.__eval_ppif_unknown_defined_(str(e), expand)
230+ return r
231+
232+ def __eval_ppif_unknown_defined_(self, exception_str, expand):
233+ def eval_x(d, x):
234+ try:
235+ expanded = expand.replace(d, str(x))
236+ return eval(expanded)
237+ except Exception:
238+ return -1
239+ m = RE_EVAL_UNDEFINED_EXCEPTION.match(exception_str)
240+ if m:
241+ d = m.group(1)
242+ r0 = eval_x(d, 0)
243+ r1 = eval_x(d, 1)
244+ if r0 == r1:
245+ return r0
246+ return -1
247+
248+ def __eval_ppif(self, expr):
249+ expand = self.__expand_ppif_macro(expr)
250+ expand_expr = re.sub(r'([0-9])+L', r'\1', expand)
251+ try:
252+ r = eval(expand_expr)
253+ if r:
254+ return (1, '1')
255+ else:
256+ return (0, '0')
257+ except Exception as e:
258+ r = -1
259+ if len(expand.split()) > 1:
260+ # r = self.__eval_ppif_unknown_defined(expand_expr)
261+ if r == -1:
262+ if self.debug:
263+ print(expr)
264+ print(expand)
265+ print(e)
266+ # strip fixed condition
267+ if '(0)' in expand or '(1)' in expand:
268+ expand = re.sub(r'\s*\(0\)\s*or\s*', '', expand)
269+ expand = re.sub(r'\s*or\s*\(0\)\s*', '', expand)
270+ expand = re.sub(r'\s*\(1\)\s*and\s*', '', expand)
271+ expand = re.sub(r'\s*and\s*\(1\)\s*', '', expand)
272+ expand = expand.replace('and', '&&')
273+ expand = expand.replace('or', '||')
274+ expand = expand.replace('not', '!')
275+ expand = expand.replace('(0)', '0')
276+ expand = expand.replace('(1)', '1')
277+ expand = expand.replace(' ', '')
278+ return (r, expand)
279+ return (r, None)
280+
281+ def __check_ppif(self, ins, expr):
282+ if ins == "if" or ins == "elif":
283+ return self.__eval_ppif(expr)
284+ else:
285+ def other():
286+ if ins == "ifdef":
287+ if expr in self.unknowns:
288+ return -1
289+ elif expr not in self.macros:
290+ return -1
291+ elif expr in self.macros:
292+ if self.macros[expr] is None:
293+ return 0
294+ return 1
295+ elif ins == "ifndef":
296+ if expr in self.unknowns:
297+ return -1
298+ elif expr in self.macros:
299+ if self.macros[expr] is None:
300+ return 1
301+ return 0
302+ elif expr in self.expands_macros:
303+ return 0
304+ else:
305+ return -1
306+ return -1
307+ return other(), None
308+
309+ # return line string or None
310+ def __check_pp(self, line):
311+ def ret(b):
312+ if b:
313+ return line
314+ return None
315+ m = RE_PPIF.match(line)
316+ if m:
317+ expr = m.group(2)
318+ f,expanded_expr = self.__check_ppif(m.group(1), expr)
319+ self.depth.append(f)
320+ self.depth_macros.append({})
321+ self.included_path.append([])
322+ self.brothers.append([])
323+ if expanded_expr is not None:
324+ line = line.replace(expr, expanded_expr)
325+ return ret(all(x != 0 for x in self.depth) and f == -1)
326+ m = RE_PPELIF.match(line)
327+ if m:
328+ brother = self.brothers[-1]
329+ prev_brother_f = self.depth[-1]
330+ if len(brother) == 0 and prev_brother_f == 0:
331+ # Convert to #if if the last is if and the result is False
332+ line = line.replace('#elif', '#if')
333+ else:
334+ brother.append(prev_brother_f)
335+ f = 0
336+ if not any(x == 1 for x in brother):
337+ expr = m.group(1)
338+ f,expanded_expr = self.__check_ppif("elif", expr)
339+ if expanded_expr is not None:
340+ line = line.replace(expr, expanded_expr)
341+ self.depth[-1] = f
342+ if all(x != 0 for x in self.depth):
343+ if f == -1 or any(x == -1 for x in brother):
344+ return line
345+ return None
346+ m = RE_PPELSE.match(line)
347+ if m:
348+ brother = self.brothers[-1]
349+ brother.append(self.depth[-1])
350+ f = -1
351+ if f == 1 or any(x == 1 for x in brother):
352+ f = 0
353+ elif all(x == 0 for x in brother):
354+ f = 1
355+ self.depth[-1] = f
356+ return ret(all(x != 0 for x in self.depth) and f == -1)
357+ if RE_PPENDIF.match(line):
358+ brother = self.brothers[-1]
359+ f = self.depth.pop()
360+ self.included_path.pop()
361+ poped_macros = self.depth_macros.pop()
362+ b1 = all(x != 0 for x in self.depth)
363+ b2 = any(x == -1 for x in brother)
364+ self.brothers.pop()
365+ need_endif = b1 and (f == -1 or b2)
366+ if need_endif:
367+ return line
368+ if len(self.depth_macros) > 0:
369+ current_depth_macros = self.depth_macros[-1]
370+ current_depth_macros.update(poped_macros)
371+ return None
372+ return ret(len(self.depth) == 0 or all(x != 0 for x in self.depth))
373+
374+ def __check_include(self, line):
375+ m = RE_SYSTEM_INCLUDE_REGEX.match(line)
376+ if m:
377+ path = m.group(1)
378+ if path in self.included_path[-1]:
379+ return False
380+ else:
381+ self.included_path[-1].append(path)
382+ return True
383+
384+ def __reduction(self, line):
385+ reduction_macros = {
386+ 'IP_INC': 'IP_I',
387+ 'IP_DEC': 'IP_D',
388+ 'IP_BOOL': 'IP_B',
389+ 'IP_ENUM': 'IP_E',
390+ 'IP_REPEAT': 'IP_R',
391+ 'IP_IS_EMPTY_': 'IP_IS_EMP_',
392+ 'IP_EMPTY_TAG': 'IP_EMP_T',
393+ 'IP_IS_BEGIN_PARENS': 'IP_IS_BGN_P',
394+ 'IP_E_PARAMS_MACRO_': 'IP_E_P_M_',
395+ 'IP_E_P_M_IN_BINARY_': 'IP_E_P_M_B_',
396+ 'IP_E_BINARY_PARAMS_': 'IP_E_B_P_',
397+ 'IP_E_B_P_MACRO_': 'IP_E_B_P_M_',
398+ 'IP_R_PARAMS_MACRO_': 'IP_R_P_M_',
399+ 'IP_R_P_M_IN_BINARY_': 'IP_R_P_M_B_',
400+ 'IP_R_BINARY_PARAMS_': 'IP_R_B_P_',
401+ 'IP_R_B_P_MACRO_': 'IP_R_B_P_M_',
402+ 'II_SHOW_MACRO': 'II_S_M',
403+ 'II_SHOW_ENABLE_MACRO': 'II_S_E_M',
404+ 'II_SHOW_DISABLE_MACRO': 'II_S_D_M',
405+ 'II_SHOW_FEATURE_MACROS': 'II_S_F_M',
406+ 'II_ELEMENTSARE': 'II_EA',
407+ 'II_EA_MATCHER_NAME': 'II_EA_M_N',
408+ 'II_ANYOF_AND_ALLOF_MATCHER_NAME': 'II_AAA_M_N',
409+ 'II_DECL_VALUEARRAY_': 'II_D_VA_',
410+ 'II_DECL_CARTESIAN_PRODUCT_': 'II_D_C_P_',
411+ 'II_DECL_PAIRWISE_': 'II_D_PW_',
412+ 'II_DECL_IS_FUNCTION_PTR_': 'II_D_IS_FP_',
413+ 'II_DECL_IS_MEMBER_FUNCTION_PTR_': 'II_D_IS_M_FP_',
414+ 'II_DECL_FUNCTION_RETURN_TYPE_': 'II_D_F_R_T_',
415+ 'II_DECL_EXPRESSION_': 'II_D_EP_',
416+ 'II_DECL_ELEMENTSARE': 'II_D_EA',
417+ 'II_DECL_TUPLE_PRINTTO': 'II_D_T_PT',
418+ 'II_DECL_ANYOF_AND_ALLOF': 'II_D_AAA',
419+ 'II_DECL_COMPARE_HELPER_': 'II_D_C_H_',
420+ 'II_DECL_COMBINE_': 'II_D_C_',
421+ 'II_DECL_VALUES_': 'II_D_V_',
422+ 'II_DECL_TYPES_': 'II_D_T_',
423+ 'II_DECL_TEMPLATES_': 'II_D_TPL_',
424+ 'II_DECL_TYPELIST_': 'II_D_TL_',
425+ 'II_DECL_TEMPLATETYPELIST_': 'II_D_TTL_',
426+ 'II_DECL_PEEP_MEMBER_FUNC_': 'II_D_PE_M_F_',
427+ 'II_DECL_COMPARE_MATCHER': 'II_D_COMP_M',
428+ 'II_DECL_STR_COMPARE_MATCHER': 'II_D_S_COMP_M',
429+ 'II_DECL_ALLOF_MATCHER': 'II_D_ALL_M',
430+ 'II_DECL_ANYOF_MATCHER': 'II_D_ANY_M',
431+ 'II_DECL_DEFAULT_ARG_': 'II_D_DEF_A_',
432+ 'II_DECL_SPEC_NONE_': 'II_D_S_NN_',
433+ 'II_SUCCEED': 'II_S',
434+ 'II_FAIL': 'II_F',
435+ 'II_ADD_FAILURE': 'II_ADD_F',
436+ 'II_SCOPED_MESSAGE': 'II_S_MSG',
437+ 'II_D_C_P_GENERATOR_': 'II_D_C_P_GEN_',
438+ 'II_D_C_P_HOLDER_': 'II_D_C_P_HLR_',
439+ 'II_D_PW_GENERATOR_': 'II_D_PW_GEN_',
440+ 'II_D_PW_HOLDER_': 'II_D_PW_HLR_',
441+ 'II_CONCAT_PACKAGE': 'II_CC_PKG',
442+ 'II_PACKAGE_': 'II_PKG_',
443+ 'II_PKG_CURRENT_NAMESPACE_': 'II_PKG_C_NS_',
444+ 'II_PKG_PARENT_NAMESPACE_': 'II_PKG_P_NS_',
445+ 'II_TEST_CLASS_NAME_': 'II_T_C_N_',
446+ 'II_TEST_INSTANCE_NAME_': 'II_T_INST_N_',
447+ 'II_TO_VARNAME_': 'II_TO_VN_',
448+ 'II_TO_NAME_': 'II_TO_N_',
449+ 'II_CHECK_TESTFIXTURE': 'II_CK_TF',
450+ 'II_PMZ_TEST_CLASS_NAME_': 'II_PMZ_T_C_N_',
451+ 'II_GETTESTCASEPATTERNHOLDER': 'II_GTCPH',
452+ 'II_INSTANTIATE_TEST_CASE_P_': 'II_INST_TC_P_',
453+ 'II_TEST_P_EVALGENERATOR_NAME_': 'II_T_P_EGEN_N_',
454+ 'II_TEST_P_PARAMGENERATOR_NAME_': 'II_T_P_PGEN_N_',
455+ 'II_TEST_P_INSTANTIATIONREGISTER_': 'II_T_P_INST_R_',
456+ 'II_TEST_P_FIXTURE_DECL_': 'II_T_P_FX_D_',
457+ 'II_TEST_P_BASE_FIXTURE': 'II_T_P_B_FX',
458+ 'II_T_P_INST_R_NAME_': 'II_T_P_INST_R_N_',
459+ 'II_ALIAS_TESTNAME_PP_': 'II_A_TN_PP_',
460+ 'II_TEST_EXPRESSION_': 'II_T_EXPR_',
461+ 'II_T_EXPR_EXPAND_EXPRESSION': 'II_T_EXPR_E_E',
462+ 'II_EXPRESSION_DECOMPOSE': 'II_EXPR_DEC',
463+ 'II_D_EP_RESULT_OP': 'II_D_EP_R_OP',
464+ 'II_TYPED_TEST_': 'II_T_T_',
465+ 'II_T_T_CASE_': 'II_T_TC_',
466+ 'II_T_TC_PSTATE_NAME_': 'II_T_TC_PS_N_',
467+ 'II_T_T_P_NAMESPACE_': 'II_T_T_P_NS_',
468+ 'II_T_T_P_ADDTESTNAME': 'II_T_T_P_ADD_TN',
469+ 'II_T_T_PARAMS_': 'II_T_T_PRMS_',
470+ 'II_REGISTER_TYPED_TEST_CASE_P_': 'II_R_T_TC_P_',
471+ 'II_INSTANTIATE_TYPED_TEST_CASE_P_': 'II_INST_T_TC_P_',
472+ 'II_PEEP_TAG_NAME_': 'II_PE_T_N_',
473+ 'II_PEEP_SETTER_NAME_': 'II_PE_S_N_',
474+ 'II_GeTypeNameSpecialization': 'II_GTNS',
475+ 'II_WORKAROUND_GENRAND': 'II_WA_GENRAND',
476+ }
477+ line = line.replace('IIUT_', 'II_')
478+ line = line.replace('II_PP_', 'IP_')
479+ line = line.replace('IUTEST_UNUSED_VAR', '(void)')
480+ line = line.replace('statement', 'st')
481+ line = line.replace('expected_exception', 'exp_e')
482+ line = line.replace('exp_e_value', 'exp_e_v')
483+ line = line.replace('expected_str', 'exp_s')
484+ line = line.replace('expected_value', 'exp_v')
485+ line = line.replace('actual_str', 'act_s')
486+ line = line.replace('regex_str', 'regex_s')
487+ line = line.replace('pred_formatter', 'pd_fmt')
488+ line = line.replace('on_failure', 'on_f')
489+ line = line.replace('testcasename_', 'tcn_')
490+ line = line.replace('testname_', 'tn_')
491+ line = line.replace('testfixture_', 'tf_')
492+ for k,v in reduction_macros.items():
493+ if collections.Counter(reduction_macros.values())[v] > 1:
494+ print('error: duplicated ' + v)
495+ continue
496+ line = line.replace(k, v)
497+ line = re.sub(r'(?<![\w\d_])NULL(?![\w\d_])', '0', line)
498+ # line = re.sub('\s+', ' ', line)
499+ line = re.sub('\s$', '', line)
500+ line = line.strip()
501+ return line
502+
503+ def __strip_namespace(self, line, ns):
504+ s = ""
505+ for n in ns:
506+ s += "namespace " + n + "{"
507+ e = ""
508+ for n in ns:
509+ e += "}"
510+ def __is_namespace_open_close_line(x):
511+ return x.startswith(s) and x.endswith(e)
512+ if __is_namespace_open_close_line(line) and __is_namespace_open_close_line(self.prev_line):
513+ self.prev_line = self.prev_line[:-len(e)]
514+ line = line[len(s):]
515+ return line
516+
517+ def __strip_namespace_iutest_detail(self, line):
518+ ns = ['iutest', 'detail']
519+ return self.__strip_namespace(line, ns)
520+
521+ def __strip_namespace_iutest(self, line):
522+ ns = ['iutest']
523+ return self.__strip_namespace(line, ns)
524+
525+ def __strip_namespaces(self, line):
526+ line = self.__strip_namespace_iutest_detail(line)
527+ line = self.__strip_namespace_iutest(line)
528+ return line
529+
530+ def preprocess(self, code, add_macros):
531+ if add_macros is not None:
532+ self.macros.update(add_macros)
533+ dst = ""
534+ for line in code.splitlines():
535+ # c++ comment
536+ if RE_CPP_COMMENT.match(line):
537+ continue
538+ # if/ifdef/ifndef/elif/endif
539+ line = self.__check_pp(line)
540+ if line:
541+ # include
542+ if not self.__check_include(line):
543+ continue
544+ # define
545+ d = self.__append_define(line)
546+ if d:
547+ # config macro insert
548+ if 'INCG_IRIS_IUTEST_CONFIG_HPP_' in d:
549+ dst += self.prev_line + '\n'
550+ self.prev_line = None
551+ for k,v in self.iutest_config_macro.items():
552+ dst += '#define ' + k + ' ' + str(v) + '\n'
553+ self.iutest_config_macro = []
554+ if d in self.expands_macros or d in self.expand_function_macros:
555+ continue
556+ if d in ['IUTEST_UNUSED_VAR']:
557+ continue
558+ line = self.__expand_macro(line)
559+ if len(line) > 0:
560+ line = self.__reduction(line)
561+ if self.prev_line is not None:
562+ line = self.__strip_namespaces(line)
563+ if self.prev_line.startswith('#'):
564+ self.prev_line += '\n'
565+ elif line.startswith('#'):
566+ self.prev_line += '\n'
567+ dst += self.prev_line
568+ self.prev_line = line
569+ dst += self.prev_line + '\n'
570+ return dst
571+
572+ def __get_ppif_type(self, line):
573+ if RE_PPIF.match(line):
574+ return 'if'
575+ elif RE_PPELIF.match(line):
576+ return 'elif'
577+ elif RE_PPELSE.match(line):
578+ return 'else'
579+ elif RE_PPENDIF.match(line):
580+ return 'endif'
581+ return None
582+
583+ def remove_empty_ppif(self, code):
584+ dst = ""
585+ prev = None
586+ cache_lines = []
587+ def cach_clear():
588+ ret = ""
589+ for s in cache_lines:
590+ if s is not None:
591+ ret += s
592+ del cache_lines[:]
593+ return ret
594+
595+ for line in code.splitlines():
596+ line += "\n"
597+ t = self.__get_ppif_type(line)
598+ if t == 'endif':
599+ if prev == 'if':
600+ if len(cache_lines) > 0:
601+ cache_lines = cache_lines[:-1]
602+ elif prev != 'endif':
603+ if len(cache_lines) > 0:
604+ cache_lines[-1] = line
605+ else:
606+ cache_lines.append(line)
607+ else:
608+ dst += cach_clear()
609+ dst += line
610+ elif t is not None:
611+ if prev is None:
612+ cache_lines.append(line)
613+ else:
614+ if t == 'else' and prev == 'elif':
615+ cache_lines[-1] = line
616+ elif t == 'elif' and prev == 'elif':
617+ cache_lines[-1] = line
618+ else:
619+ cache_lines.append(line)
620+ else:
621+ dst += cach_clear()
622+ dst += line
623+ prev = t
624+ dst += cach_clear()
625+ return dst
--- trunk/tools/fused/iuwandbox_pp.py (nonexistent)
+++ trunk/tools/fused/iuwandbox_pp.py (revision 1350)
@@ -0,0 +1,187 @@
1+#!/usr/bin/env python
2+#
3+# iuwandbox_pp.py
4+#
5+# Copyright (C) 2018, Takazumi Shirayanagi
6+# This software is released under the new BSD License,
7+# see LICENSE
8+#
9+
10+import os
11+import sys
12+import codecs
13+from iutest_pp_strip import IutestPreprocessor
14+
15+predefined_macros = {
16+ '__WANDBOX__': '1',
17+ 'NULL': '0',
18+ 'IUTEST_USE_GTEST': None,
19+ 'IUTEST_BUILD_DOXYGEN': None,
20+ '_IUTEST_DEBUG': None,
21+ '__CYGWIN__': None,
22+ 'IUTEST_OS_CYGWIN': None,
23+ '__MINGW__': None,
24+ '__MINGW32__': None,
25+ '__MINGW64__': None,
26+ '__arm__': None,
27+ 'IUTEST_OS_ARM': None,
28+ '__ARMCC_VERSION': None,
29+ '__AVR32__': None,
30+ '__avr32__': None,
31+ 'IUTEST_OS_AVR32': None,
32+ 'ANDROID': None,
33+ '__ANDROID__': None,
34+ 'IUTEST_OS_LINUX_ANDROID': None,
35+ '__APPLE__': None,
36+ 'IUTEST_OS_IOS': None,
37+ 'IUTEST_OS_MAC': None,
38+ '__INTEL_COMPILER': None,
39+ '__BORLANDC__': None,
40+ '__CUDACC__': None,
41+ '__IBMCPP__': None,
42+ 'COMPILER_ICC': None,
43+ '_MSC_VER': None,
44+ '_MSC_FULL_VER': None,
45+ '_WIN32': None,
46+ 'WIN32': None,
47+ '__WIN32__': None,
48+ 'WINAPI_FAMILY': None,
49+ '__AFX_H__': None,
50+ '__MWERKS__': None,
51+ 'IUTEST_OS_WINDOWS': None,
52+ 'IUTEST_OS_WINDOWS_MINGW': None,
53+ 'IUTEST_OS_WINDOWS_MOBILE': None,
54+ 'IUTEST_OS_WINDOWS_PHONE': None,
55+ 'IUTEST_OS_WINDOWS_RT': None,
56+ 'IUTEST_OS_WINDOWS_WINE': None,
57+ 'IUTEST_NO_UTIL_ASSERTION_GTEST_COMPATIBLE': '1',
58+ 'IUTEST_NO_TWO_PHASE_NAME_LOOKUP': None,
59+ 'IUTEST_NO_FUNCTION_TEMPLATE_ORDERING': None,
60+ 'IUTEST_NO_INCLASS_MEMBER_INITIALIZATION': None,
61+ 'IUTEST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS': None,
62+ 'IUTEST_NO_SFINAE': None,
63+ 'IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION': None,
64+ 'IUTEST_NO_TEMPLATE_TEMPLATES': None,
65+ 'IUTEST_NO_VOID_RETURNS': None,
66+ 'IUTEST_NO_ARGUMENT_DEPENDENT_LOOKUP': None,
67+ 'IUTEST_NO_PRIVATE_IN_AGGREGATE': None,
68+ 'IUTEST_NO_VARIADIC_MACROS': None,
69+ 'IUTEST_NO_UNITEST_AD_HOC_TEST_RESULT_ACCESSOR': None,
70+ 'IUTEST_NO_TESTCASE_AD_HOC_TEST_RESULT_ACCESSOR': None,
71+ 'IUTEST_NO_LAMBDA_SCOPE_RESOLUTION': None,
72+ 'IUTEST_NO_GETENV': None,
73+ 'IUTEST_NO_PUTENV': None,
74+ 'IUTEST_NO_SETENV': None,
75+ 'IUTEST_NO_GETCWD': None,
76+ 'IUTEST_NOT_SUPPORT_STOPWATCH': None,
77+ 'IUTEST_HAS_WANT_SECURE_LIB': '0',
78+ 'IUTEST_HAS_MS_EXTENSIONS': '0',
79+ 'IUTEST_HAS_MS_CXX_MODULE': '0',
80+ 'MS_CPP_UNITTESTFRAMEWORK': None,
81+ 'IUTEST_EXPLICIT_INSTANTIATION_ACCESS_PRIVATE_MEMBER_FUNCTION': '1',
82+ 'IUTEST_EXPLICIT_INSTANTIATION_ACCESS_PRIVATE_STATIC_MEMBER_FUNCTION': '1',
83+ '__native_client__': None,
84+ 'IUTEST_OS_NACL': None,
85+ 'IUTEST_HAS_INVALID_PARAMETER_HANDLER': '0',
86+}
87+
88+iutest_config_macro = {
89+ 'IUTEST_HAS_LIB': '0',
90+ 'IUTEST_HAS_TESTNAME_ALIAS_JP': '0',
91+ 'IUTEST_HAS_IF_EXISTS': '0',
92+ 'IUTEST_HAS_ANALYSIS_ASSUME': '0',
93+ 'IUTEST_HAS_IGNORE_TEST': '0',
94+ 'IUTEST_HAS_MINIDUMP': '0',
95+ 'IUTEST_HAS_STRSTREAM': '0',
96+ 'IUTEST_HAS_STRINGSTREAM': '1',
97+ 'IUTEST_HAS_CLASS_MEMBER_TEMPLATE_SPECIALIZATION': '0',
98+ 'IUTEST_HAS_GENERIC': '0',
99+ 'IUTEST_HAS_MEMORY_SANITIZER': '0',
100+ 'IUTEST_HAS_ADDRESS_SANITIZER': '0',
101+ 'IUTEST_HAS_THREAD_SANITIZER': '0',
102+ 'IUTEST_HAS_SEH': '0',
103+}
104+
105+expands_macros = [
106+ 'IUTEST_IPP_INLINE',
107+ 'IUTEST_ATTRIBUTE_DEPRECATED_',
108+ 'IUTEST_ATTRIBUTE_PURE_',
109+ 'IUTEST_ATTRIBUTE_INIT_PRIORITY_',
110+ 'IUTEST_HAS_ATTRIBUTE_DEPRECATED',
111+ 'IUTEST_CXX_MODULE_EXPORT',
112+ 'IUTEST_ATTRIBUTE_NO_SANITIZE_MEMORY',
113+ 'IUTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS',
114+ 'IUTEST_ATTRIBUTE_NO_SANITIZE_THREAD',
115+ 'IUTEST_ATTRIBUTE_NO_SANITIZE_ALL',
116+]
117+
118+# expand function macros
119+expand_function_macros = [
120+ 'IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN',
121+ 'IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END',
122+ 'IUTEST_PRAGMA_EXTERN_TEMPLATE_WARN_DISABLE_BEGIN',
123+ 'IUTEST_PRAGMA_EXTERN_TEMPLATE_WARN_DISABLE_END',
124+ 'IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_BEGIN',
125+ 'IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_END',
126+ 'IUTEST_PRAGMA_MSC_WARN_PUSH',
127+ 'IUTEST_PRAGMA_MSC_WARN_DISABLE',
128+ 'IUTEST_PRAGMA_MSC_WARN_POP',
129+ 'IUTEST_WORKAROUND_MSC_STLSTREAM_C4250',
130+ 'IUTEST_EXPLICIT_TEMPLATE_TYPE_',
131+ 'IUTEST_IF_EXISTS',
132+ 'IUTEST_IF_NOT_EXISTS',
133+ 'IUTEST_STATIC_EXISTS',
134+ 'IUTEST_STATIC_ASSERT_IF_EXISTS',
135+ 'IUTEST_STATIC_ASSERT_IF_NOT_EXISTS',
136+ 'IUTEST_ANALYSIS_ASSUME',
137+]
138+
139+#
140+has_features = {
141+}
142+
143+has_include = {
144+}
145+
146+debug = False
147+
148+class WandboxPreprocessor:
149+ pp = IutestPreprocessor(predefined_macros
150+ , iutest_config_macro
151+ , expand_function_macros
152+ , expands_macros
153+ , has_features
154+ , has_include)
155+
156+ def preprocess(self, code, add_macros):
157+ self.pp.set_debug_flag(debug)
158+ return self.pp.preprocess(code, add_macros)
159+
160+ def remove_empty_ppif(self, code):
161+ return self.pp.remove_empty_ppif(code)
162+
163+
164+def default_pp():
165+ output_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../fused-src")
166+ output = "iutest.wandbox.min.hpp"
167+ f = codecs.open(os.path.join(output_dir, "iutest.min.hpp"), 'r', 'utf-8-sig')
168+ code = f.read()
169+ f.close()
170+ output_file = codecs.open(os.path.join(output_dir, output), 'w', 'utf-8-sig')
171+ pp = WandboxPreprocessor()
172+ code = pp.preprocess(code, None)
173+ code = pp.remove_empty_ppif(code)
174+ output_file.write(code)
175+ output_file.close()
176+
177+
178+def main():
179+ global debug
180+ argc = len(sys.argv)
181+ if argc == 2:
182+ if sys.argv[1] == 'debug':
183+ debug = True
184+ default_pp()
185+
186+if __name__ == '__main__':
187+ main()
--- trunk/tools/fused/tests/test.min.cpp (nonexistent)
+++ trunk/tools/fused/tests/test.min.cpp (revision 1350)
@@ -0,0 +1,7 @@
1+#include "../../../fused-src/iutest.min.hpp"
2+
3+int main(int argc, char** argv)
4+{
5+ IUTEST_INIT(&argc, argv);
6+ return IUTEST_RUN_ALL_TESTS();
7+}
--- trunk/tools/fused/tests/test.wandbox.min.cpp (nonexistent)
+++ trunk/tools/fused/tests/test.wandbox.min.cpp (revision 1350)
@@ -0,0 +1,7 @@
1+#include "../../../fused-src/iutest.wandbox.min.hpp"
2+
3+int main(int argc, char** argv)
4+{
5+ IUTEST_INIT(&argc, argv);
6+ return IUTEST_RUN_ALL_TESTS();
7+}
--- trunk/tools/paiza.io/iupaizaio_pp.py (revision 1349)
+++ trunk/tools/paiza.io/iupaizaio_pp.py (revision 1350)
@@ -2,12 +2,15 @@
22 #
33 # iupaizaio_pp.py
44 #
5-# Copyright (C) 2015-2016, Takazumi Shirayanagi
5+# Copyright (C) 2015-2018, Takazumi Shirayanagi
66 # This software is released under the new BSD License,
77 # see LICENSE
88 #
99
10-import re
10+import os
11+import sys
12+sys.path.append(os.path.join(os.path.dirname(__file__), '../fused'))
13+from iutest_pp_strip import IutestPreprocessor
1114
1215 predefined_macros = {
1316 '__clang__': '1',
@@ -19,8 +22,8 @@
1922 '__has_include': None
2023 }
2124
22-#userdefined_macros = { '': '1'
23-#}
25+iutest_config_macro = {
26+}
2427
2528 expands_macros = [
2629 'IUTEST_IPP_INLINE',
@@ -98,225 +101,12 @@
98101 '<tr1/tuple>': '0'
99102 }
100103
101-RE_MACRO_SPLIT = re.compile('([\(\):;{} /%+\-=<>!&\|*#]+)')
102-RE_SPLIT_PAREN = re.compile('([\(\)])')
103-RE_FUNC_MACRO = re.compile('([\w_]+)\((.*?)\)')
104-RE_DEFINE = re.compile('#\s*define (\S+)\s*(.*)$')
105-RE_DEFINE_PARSE = re.compile('(.*)defined\((.*?)\)(.*)')
106-RE_HAS_INCLUDE = re.compile('(.*)__has_include\((.*?)\)(.*)')
107-RE_HAS_FEATURE = re.compile('(.*)__has_feature\((.*?)\)(.*)')
108-RE_SPLIT_OP = re.compile('(&&|\|\||!)')
109-RE_SYMBOLMARK = re.compile('([+\-=<>\(\)]+)')
110-RE_PPIF = re.compile('#\s*(ifdef|ifndef|if)\s*(.*)$')
111-RE_PPELIF = re.compile('#\s*elif(.*)$')
112-RE_PPELSE = re.compile('#\s*else\s*$')
113-RE_PPENDIF = re.compile('#\s*endif')
114-RE_CPP_COMMENT = re.compile('^//.*')
115-
116-
117104 class PaizaPreprocessor:
118- macros = predefined_macros
119- unkowns = []
120- depth = []
121- brothers = []
105+ pp = IutestPreprocessor(predefined_macros
106+ , expand_function_macros
107+ , expands_macros
108+ , clang_has_features
109+ , clang_has_include)
122110
123- def __expand_macro(self, line):
124- dst = ""
125- for s in RE_MACRO_SPLIT.split(line):
126- if s in expands_macros and s in self.macros:
127- if self.macros[s]:
128- dst += self.macros[s]
129- else:
130- dst += s
131- return self.__expand_function_macro(dst)
132-
133- def __expand_function_macro(self, line):
134- dst = ""
135- tokens = []
136- prev = ""
137- for s in RE_SPLIT_PAREN.split(line):
138- if s == '(':
139- tokens.append(prev)
140- elif s == ')' and len(tokens) > 0:
141- tokens[-1] += prev + s
142- s = ""
143- ss = tokens.pop()
144- for m in RE_FUNC_MACRO.finditer(ss):
145- d = m.group(1)
146- if d in expand_function_macros:
147- if d in self.macros and self.macros[d] is None:
148- ss = ss.replace(m.group(0), '')
149- if len(tokens) > 0:
150- tokens[-1] += ss
151- else:
152- dst += ss
153- elif len(tokens) > 0:
154- tokens[-1] += prev
155- else:
156- dst += prev
157- prev = s
158- for s in tokens:
159- dst += s
160- dst += prev
161- return dst
162-
163- def __append_define(self, line):
164- def append(d, v, depth, macros, unkowns):
165- d = re.sub('\(.*\)', '', d)
166- if any(x == -1 for x in depth):
167- unkowns.append(d)
168- else:
169- if len(v) == 0:
170- macros[d] = None
171- else:
172- macros[d] = v
173- return d
174- m = RE_DEFINE.match(line)
175- if m:
176- return append(m.group(1), m.group(2), self.depth, self.macros, self.unkowns)
177- return None
178-
179- def __expand_ppif_macro(self, expr):
180- expand = ""
181- for s in RE_SPLIT_OP.split(expr):
182- if s == '&&':
183- expand += ' and '
184- elif s == '||':
185- expand += ' or '
186- elif s == '!':
187- expand += " not "
188- else:
189- m = RE_DEFINE_PARSE.match(s)
190- if m:
191- d = m.group(2)
192- if d in self.unkowns:
193- expand += s
194- else:
195- f = d in self.macros
196- expand += m.group(1) + str(f) + m.group(3)
197- continue
198- m = RE_HAS_INCLUDE.match(s)
199- if m:
200- f = m.group(2)
201- if f in clang_has_include:
202- expand += m.group(1) + clang_has_include[f] + m.group(3)
203- else:
204- expand += s
205- continue
206- m = RE_HAS_FEATURE.match(s)
207- if m:
208- f = m.group(2)
209- if f in clang_has_features:
210- expand += m.group(1) + clang_has_features[f] + m.group(3)
211- continue
212- for w in RE_SYMBOLMARK.split(s):
213- if RE_SYMBOLMARK.match(w) or w.isspace():
214- expand += w
215- elif len(w) > 0:
216- if w in self.unkowns:
217- expand += s
218- elif w in self.macros:
219- expand += self.__expand_ppif_macro(self.macros[w])
220- elif w.isdigit():
221- expand += w
222- else:
223- expand += '0'
224-
225- expand = expand.replace('0(0)', '0')
226- expand = expand.replace('not =', '!=')
227- return expand
228-
229- def __eval_ppif(self, expr):
230- expand = self.__expand_ppif_macro(expr)
231- try:
232- if eval(expand):
233- return 1
234- else:
235- return 0
236- except Exception as e:
237- if not any(x in expand for x in self.unkowns):
238- if True:
239- print(expr)
240- print(expand)
241- print(e)
242- return -1
243-
244- def __check_ppif(self, ins, expr):
245- if ins == "if" or ins == "elif":
246- return self.__eval_ppif(expr)
247- elif ins == "ifdef":
248- if expr in self.unkowns:
249- return -1
250- if expr not in self.macros:
251- return 0
252- elif ins == "ifndef":
253- if expr in self.unkowns:
254- return -1
255- if expr in self.macros:
256- return 0
257- return 1
258-
259- def __check_pp(self, line):
260- m = RE_PPIF.match(line)
261- if m:
262- f = self.__check_ppif(m.group(1), m.group(2))
263- self.depth.append(f)
264- self.brothers.append([])
265- return all(x != 0 for x in self.depth) and f == -1
266- m = RE_PPELIF.match(line)
267- if m:
268- brother = self.brothers[-1]
269- brother.append(self.depth[-1])
270- f = 0
271- if not any(x == 1 for x in brother):
272- f = self.__check_ppif("elif", m.group(1))
273- self.depth[-1] = f
274- return all(x != 0 for x in self.depth) and any(x == -1 for x in brother)
275- m = RE_PPELSE.match(line)
276- if m:
277- brother = self.brothers[-1]
278- f = self.depth[-1]
279- if f == 1 or any(x == 1 for x in brother):
280- f = 0
281- elif f == 0:
282- f = 1
283- self.depth[-1] = f
284- return all(x != 0 for x in self.depth) and f == -1
285- if RE_PPENDIF.match(line):
286- brother = self.brothers[-1]
287- f = self.depth.pop()
288- b1 = all(x != 0 for x in self.depth)
289- b2 = any(x == -1 for x in brother)
290- self.brothers.pop()
291- return b1 and (f == -1 or b2)
292- return len(self.depth) == 0 or all(x != 0 for x in self.depth)
293-
294- def __reduction(self, line):
295- line = line.replace('IIUT_', 'II_')
296- line = line.replace('II_PP_', 'IP_')
297- line = line.replace('IUTEST_UNUSED_VAR', '(void)')
298- line = re.sub('\s+', ' ', line)
299- line = re.sub('\s$', '', line)
300- return line
301-
302111 def preprocess(self, code, add_macros):
303- self.macros = dict(self.macros.items() + add_macros.items())
304- dst = ""
305- for line in code.splitlines():
306- # c++ comment
307- if RE_CPP_COMMENT.match(line):
308- continue
309- # if/ifdef/ifndef/elif/endif
310- if self.__check_pp(line):
311- # define
312- d = self.__append_define(line)
313- if d:
314- if d in expands_macros or d in expand_function_macros:
315- continue
316- if d in ['IUTEST_UNUSED_VAR']:
317- continue
318- line = self.__expand_macro(line)
319- if len(line) > 0:
320- line = self.__reduction(line)
321- dst += line + "\n"
322- return dst
112+ return self.pp.preprocess(code, add_macros)
--- trunk/tools/wandbox/Makefile (revision 1349)
+++ trunk/tools/wandbox/Makefile (revision 1350)
@@ -39,6 +39,9 @@
3939 junit: ../../test/syntax_tests.cpp Makefile
4040 python iuwandbox.py $< -c $(WANDBOX_COMPILER) -f"-DIUTEST_USE_MAIN" --encoding utf-8-sig $(EXPAND_INCLUDE) --junit junit_test_result.xml
4141
42+experimental: ../../test/syntax_tests.cpp Makefile
43+ python iuwandbox.py $< -c $(WANDBOX_COMPILER) -f"-DIUTEST_USE_MAIN" --encoding utf-8-sig $(EXPAND_INCLUDE) --iutest-use-wandbox-min
44+
4245 test-gcc: ../../test/syntax_tests.cpp Makefile
4346 python iuwandbox.py $< -c gcc-head -f"-DIUTEST_USE_MAIN" -x "warning,gnu++1y" -f"-Wsuggest-override" --encoding utf-8-sig $(EXPAND_INCLUDE)
4447
--- trunk/tools/wandbox/iuwandbox.py (revision 1349)
+++ trunk/tools/wandbox/iuwandbox.py (revision 1350)
@@ -20,6 +20,7 @@
2020 from requests.exceptions import ConnectionError
2121
2222 IUTEST_FUSED_SRC = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../fused-src/iutest.min.hpp'))
23+IUTEST_WANDBOX_FUSED_SRC = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../fused-src/iutest.wandbox.min.hpp'))
2324 IUTEST_INCLUDE_PATH = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../include'))
2425 IUTEST_INCLUDE_REGEX = re.compile(r'^\s*#\s*include\s*".*(iutest|iutest_switch)\.hpp"')
2526 EXPAND_INCLUDE_REGEX = re.compile(r'^\s*#\s*include\s*"(.*?)"')
@@ -29,6 +30,7 @@
2930 workaround = True
3031 api_retries = 3
3132 api_retry_wait = 60
33+fused_src = IUTEST_FUSED_SRC
3234
3335
3436 # command line option
@@ -35,6 +37,7 @@
3537 def parse_command_line():
3638 global api_retries
3739 global api_retry_wait
40+ global fused_src
3841
3942 parser = ArgumentParser()
4043 parser.add_argument(
@@ -200,6 +203,11 @@
200203 help='define IUTEST_USE_MAIN.'
201204 )
202205 parser.add_argument(
206+ '--iutest-use-wandbox-min',
207+ action='store_true',
208+ help='use iutest.wandbox.min.hpp (experimental).'
209+ )
210+ parser.add_argument(
203211 '--verbose',
204212 action='store_true',
205213 help='verbose.'
@@ -218,6 +226,8 @@
218226 options = parser.parse_args()
219227 api_retries = options.retry
220228 api_retry_wait = options.retry_wait
229+ if options.iutest_use_wandbox_min:
230+ fused_src = IUTEST_WANDBOX_FUSED_SRC
221231 return options, parser
222232
223233
@@ -262,7 +272,7 @@
262272 code += '//origin>> ' + line
263273 if 'iutest.hpp' not in includes:
264274 try:
265- f = codecs.open(IUTEST_FUSED_SRC, 'r', 'utf-8-sig')
275+ f = codecs.open(fused_src, 'r', 'utf-8-sig')
266276 iutest_src = f.read()
267277 f.close()
268278 includes['iutest.hpp'] = iutest_src
@@ -269,7 +279,7 @@
269279 global iutest_incg_list
270280 iutest_incg_list = IUTEST_INCG_REGEX.findall(iutest_src)
271281 except:
272- print('{0} is not found...'.format(IUTEST_FUSED_SRC))
282+ print('{0} is not found...'.format(fused_src))
273283 print('please try \"make fused\"')
274284 exit(1)
275285 else:
--- trunk/tools/wandbox/tests/test_iuwandbox.py (revision 1349)
+++ trunk/tools/wandbox/tests/test_iuwandbox.py (revision 1350)
@@ -16,7 +16,7 @@
1616 import unittest
1717 import iuwandbox
1818 import fused_iutest_files
19-import shutil
19+import iuwandbox_pp
2020
2121 try:
2222 from StringIO import StringIO
@@ -26,7 +26,7 @@
2626 root = os.path.normpath(os.path.dirname(os.path.abspath(__file__)) + '/../../../')
2727 fused_src = root + '/fused-src'
2828 test_src = root + '/test/syntax_tests.cpp'
29-test_opt_default = ['--encoding', 'utf-8-sig']
29+test_opt_default = ['--encoding', 'utf-8-sig', '--iutest-use-wandbox-min']
3030 test_opt_nomain = test_opt_default
3131 test_opt = ['-f"-DIUTEST_USE_MAIN"']
3232 test_opt.extend(test_opt_default)
@@ -57,6 +57,7 @@
5757 def dump(self):
5858 value = self.capture.getvalue()
5959 eprint(value)
60+ return value
6061
6162
6263 class nofused_iuwandbox_test(iuwandbox_test_base):
@@ -63,13 +64,14 @@
6364 def setUp(self):
6465 if 'SCRUTINIZER' in os.environ:
6566 self.skipTest('this test is not run on SCRUTINIZER.')
66- if os.path.exists(fused_src):
67- try:
68- shutil.rmtree(fused_src)
69- except:
70- pass
71- if os.path.exists(os.path.join(fused_src, 'iutest.min.hpp')):
72- self.skipTest('fused-src is exists')
67+ for f in ['iutest.hpp', 'iutest.min.hpp', 'iutest.wandbox.min.hpp']:
68+ if os.path.exists(os.path.join(fused_src, f)):
69+ try:
70+ os.remove(os.path.join(fused_src, f))
71+ except Exception as e:
72+ self.skipTest('fused-src/' + f + ' remove failed... : ' + str(e))
73+ if os.path.exists(os.path.join(fused_src, f)):
74+ self.skipTest('fused-src/' + f + ' is exists')
7375 return super(nofused_iuwandbox_test, self).setUp()
7476
7577 def test_nofused(self):
@@ -78,15 +80,21 @@
7880 with self.assertRaises(SystemExit) as cm:
7981 iuwandbox.main()
8082 self.dump()
81- self.assertEqual(cm.exception.code, 1, self.capture.getvalue())
82- self.assertRegex(self.capture.getvalue(), '.*please try \"make fused\".*')
83+ output = self.capture.getvalue()
84+ self.assertEqual(cm.exception.code, 1, output)
85+ self.assertRegex(output, '.*please try \"make fused\".*')
8386
8487
8588 class iuwandbox_test(iuwandbox_test_base):
8689 def setUp(self):
87- if not os.path.exists(fused_src):
90+ need_make_fused = False
91+ for f in ['iutest.hpp', 'iutest.min.hpp', 'iutest.wandbox.min.hpp']:
92+ if not os.path.exists(os.path.join(fused_src, f)):
93+ need_make_fused = True
94+ if need_make_fused:
8895 try:
8996 fused_iutest_files.FusedAll(fused_iutest_files.IUTEST_INCLUDE_DIR, fused_src)
97+ iuwandbox_pp.default_pp()
9098 # os.system('python ' + root + '/tools/fused/fused_iutest_files.py ' + fused_src)
9199 except:
92100 pass
@@ -99,10 +107,10 @@
99107 sys.argv.extend(test_opt_nomain)
100108 with self.assertRaises(SystemExit) as cm:
101109 iuwandbox.main()
102- self.dump()
103- self.assertEqual(cm.exception.code, 1, self.capture.getvalue())
104- self.assertRegex(self.capture.getvalue(), '.*hint:.*')
105- self.assertRegex(self.capture.getvalue(), '.*In "iutest" you can omit the definition of the main function, please define IUTEST_USE_MAIN. (--iutest-use-main or -f"-DIUTEST_USE_MAIN")*')
110+ output = self.dump()
111+ self.assertEqual(cm.exception.code, 1, output)
112+ self.assertRegex(output, '.*hint:.*')
113+ self.assertRegex(output, '.*In "iutest" you can omit the definition of the main function, please define IUTEST_USE_MAIN. (--iutest-use-main or -f"-DIUTEST_USE_MAIN")*')
106114
107115 def test_use_main(self):
108116 sys.argv[1:] = [test_src]
@@ -110,9 +118,9 @@
110118 sys.argv.append('--iutest-use-main')
111119 with self.assertRaises(SystemExit) as cm:
112120 iuwandbox.main()
113- self.dump()
114- self.assertEqual(cm.exception.code, 0, self.capture.getvalue())
115- self.assertRegex(self.capture.getvalue(), '.*OK.*')
121+ output = self.dump()
122+ self.assertEqual(cm.exception.code, 0, output)
123+ self.assertRegex(output, '.*OK.*')
116124
117125 def test_define_wandbox(self):
118126 sys.argv[1:] = [test_src]
@@ -122,10 +130,10 @@
122130 sys.argv.append('-f"-DTEST"')
123131 with self.assertRaises(SystemExit) as cm:
124132 iuwandbox.main()
125- self.dump()
126- self.assertEqual(cm.exception.code, 0, self.capture.getvalue())
127- self.assertRegex(self.capture.getvalue(), '.*-D__WANDBOX__.*')
128- self.assertRegex(self.capture.getvalue(), '.*-DTEST.*')
133+ output = self.dump()
134+ self.assertEqual(cm.exception.code, 0, output)
135+ self.assertRegex(output, '.*-D__WANDBOX__.*')
136+ self.assertRegex(output, '.*-DTEST.*')
129137
130138 def test_boosttest_workarround(self):
131139 sys.argv[1:] = [test_src]
@@ -133,10 +141,10 @@
133141 sys.argv.extend(['--boost', '1.65.0'])
134142 with self.assertRaises(SystemExit) as cm:
135143 iuwandbox.main()
136- self.dump()
137- self.assertEqual(cm.exception.code, 1, self.capture.getvalue())
138- self.assertRegex(self.capture.getvalue(), '.*hint:.*')
139- self.assertRegex(self.capture.getvalue(), '.*If you do not use boost test, please specify the file with the main function first..*')
144+ output = self.dump()
145+ self.assertEqual(cm.exception.code, 1, output)
146+ self.assertRegex(output, '.*hint:.*')
147+ self.assertRegex(output, '.*If you do not use boost test, please specify the file with the main function first..*')
140148
141149 def test_run(self):
142150 sys.argv[1:] = [test_src]
@@ -144,9 +152,10 @@
144152 print(sys.argv)
145153 with self.assertRaises(SystemExit) as cm:
146154 iuwandbox.main()
147- self.dump()
148- self.assertEqual(cm.exception.code, 0, self.capture.getvalue())
149- self.assertRegex(self.capture.getvalue(), '.*OK.*')
155+ output = self.dump()
156+ self.assertEqual(cm.exception.code, 0, output)
157+ self.assertRegex(output, '\[ \s+OK \]')
158+ self.assertFalse('-Wmisleading-indentation' in output)
150159
151160 def test_same_filename(self):
152161 sys.argv[1:] = ['src/main.cpp', 'src/A/sample.cpp', 'src/B/sample.cpp']
@@ -154,9 +163,9 @@
154163 print(sys.argv)
155164 with self.assertRaises(SystemExit) as cm:
156165 iuwandbox.main()
157- self.dump()
158- self.assertEqual(cm.exception.code, 0, self.capture.getvalue())
159- self.assertRegex(self.capture.getvalue(), '.*OK.*')
166+ output = self.dump()
167+ self.assertEqual(cm.exception.code, 0, output)
168+ self.assertRegex(output, '.*OK.*')
160169
161170
162171 if __name__ == "__main__":
旧リポジトリブラウザで表示