OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef CCTEST_H_ | 28 #ifndef CCTEST_H_ |
29 #define CCTEST_H_ | 29 #define CCTEST_H_ |
30 | 30 |
31 #ifndef TEST | 31 #ifndef TEST |
32 #define TEST(Name) \ | 32 #define TEST(Name) \ |
33 static void Test##Name(); \ | 33 static void Test##Name(); \ |
34 CcTest register_test_##Name(Test##Name, __FILE__, #Name, true); \ | 34 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true); \ |
| 35 static void Test##Name() |
| 36 #endif |
| 37 |
| 38 #ifndef DEPENDENT_TEST |
| 39 #define DEPENDENT_TEST(Name, Dep) \ |
| 40 static void Test##Name(); \ |
| 41 CcTest register_test_##Name(Test##Name, __FILE__, #Name, #Dep, true); \ |
35 static void Test##Name() | 42 static void Test##Name() |
36 #endif | 43 #endif |
37 | 44 |
38 #ifndef DISABLED_TEST | 45 #ifndef DISABLED_TEST |
39 #define DISABLED_TEST(Name) \ | 46 #define DISABLED_TEST(Name) \ |
40 static void Test##Name(); \ | 47 static void Test##Name(); \ |
41 CcTest register_test_##Name(Test##Name, __FILE__, #Name, false); \ | 48 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false); \ |
42 static void Test##Name() | 49 static void Test##Name() |
43 #endif | 50 #endif |
44 | 51 |
45 class CcTest { | 52 class CcTest { |
46 public: | 53 public: |
47 typedef void (TestFunction)(); | 54 typedef void (TestFunction)(); |
48 CcTest(TestFunction* callback, const char* file, const char* name, | 55 CcTest(TestFunction* callback, const char* file, const char* name, |
49 bool enabled); | 56 const char* dependency, bool enabled); |
50 void Run() { callback_(); } | 57 void Run() { callback_(); } |
51 static int test_count(); | 58 static int test_count(); |
52 static CcTest* last() { return last_; } | 59 static CcTest* last() { return last_; } |
53 CcTest* prev() { return prev_; } | 60 CcTest* prev() { return prev_; } |
54 const char* file() { return file_; } | 61 const char* file() { return file_; } |
55 const char* name() { return name_; } | 62 const char* name() { return name_; } |
| 63 const char* dependency() { return dependency_; } |
56 bool enabled() { return enabled_; } | 64 bool enabled() { return enabled_; } |
57 private: | 65 private: |
58 TestFunction* callback_; | 66 TestFunction* callback_; |
59 const char* file_; | 67 const char* file_; |
60 const char* name_; | 68 const char* name_; |
| 69 const char* dependency_; |
61 bool enabled_; | 70 bool enabled_; |
62 static CcTest* last_; | 71 static CcTest* last_; |
63 CcTest* prev_; | 72 CcTest* prev_; |
64 }; | 73 }; |
65 | 74 |
66 #endif // ifndef CCTEST_H_ | 75 #endif // ifndef CCTEST_H_ |
OLD | NEW |