• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "test/utils/test_list.h"
17 
18 #include "test/utils/test_util.h"
19 
20 // testcase list
21 #include "test/testcases/js_breakpoint_test.h"
22 #include "test/testcases/js_breakpoint_arrow_test.h"
23 #include "test/testcases/js_breakpoint_async_test.h"
24 #include "test/testcases/js_exception_test.h"
25 #include "test/testcases/js_range_error_test.h"
26 #include "test/testcases/js_single_step_test.h"
27 #include "test/testcases/js_step_into_test.h"
28 #include "test/testcases/js_step_over_test.h"
29 #include "test/testcases/js_step_out_test.h"
30 #include "test/testcases/js_syntax_exception_test.h"
31 #include "test/testcases/js_throw_exception_test.h"
32 #include "test/testcases/js_variable_first_test.h"
33 #include "test/testcases/js_variable_second_test.h"
34 #include "test/testcases/js_module_variable_test.h"
35 #include "test/testcases/js_dropframe_test.h"
36 #include "test/testcases/js_local_variable_scope_test.h"
37 #include "test/testcases/js_container_test.h"
38 
39 namespace panda::ecmascript::tooling::test {
40 static std::string g_currentTestName = "";
41 
RegisterTests()42 static void RegisterTests()
43 {
44     // Register testcases
45     TestUtil::RegisterTest("JsExceptionTest", GetJsExceptionTest());
46     TestUtil::RegisterTest("JsSingleStepTest", GetJsSingleStepTest());
47     TestUtil::RegisterTest("JsBreakpointTest", GetJsBreakpointTest());
48     TestUtil::RegisterTest("JsBreakpointAsyncTest", GetJsBreakpointAsyncTest());
49     TestUtil::RegisterTest("JsBreakpointArrowTest", GetJsBreakpointArrowTest());
50     TestUtil::RegisterTest("JsRangeErrorTest", GetJsRangeErrorTest());
51     TestUtil::RegisterTest("JsSyntaxExceptionTest", GetJsSyntaxExceptionTest());
52     TestUtil::RegisterTest("JsThrowExceptionTest", GetJsThrowExceptionTest());
53     TestUtil::RegisterTest("JsStepIntoTest", GetJsStepIntoTest());
54     TestUtil::RegisterTest("JsStepOverTest", GetJsStepOverTest());
55     TestUtil::RegisterTest("JsStepOutTest", GetJsStepOutTest());
56     TestUtil::RegisterTest("JsVariableFirstTest", GetJsVariableFirstTest());
57     TestUtil::RegisterTest("JsVariableSecondTest", GetJsVariableSecondTest());
58     TestUtil::RegisterTest("JsModuleVariableTest", GetJsModuleVariableTest());
59     TestUtil::RegisterTest("JsLocalVariableScopeTest", GetJsLocalVariableScopeTest());
60     TestUtil::RegisterTest("JsContainerTest", GetJsContainerTest());
61 }
62 
RegisterCInterpTests()63 static void RegisterCInterpTests()
64 {
65     TestUtil::RegisterTest("JSDropFrameTest", GetJsDropFrameTest());
66 }
67 
GetTestList()68 std::vector<const char *> GetTestList()
69 {
70     RegisterTests();
71     std::vector<const char *> res;
72 
73     auto &tests = TestUtil::GetTests();
74     for (const auto &entry : tests) {
75         res.push_back(entry.first.c_str());
76     }
77     return res;
78 }
79 
GetCInterpTestList()80 std::vector<const char *> GetCInterpTestList()
81 {
82     RegisterCInterpTests();
83     std::vector<const char *> res;
84 
85     auto &tests = TestUtil::GetTests();
86     for (const auto &entry : tests) {
87         res.push_back(entry.first.c_str());
88     }
89     return res;
90 }
91 
SetCurrentTestName(const std::string & testName)92 void SetCurrentTestName(const std::string &testName)
93 {
94     g_currentTestName = testName;
95 }
96 
GetCurrentTestName()97 std::string GetCurrentTestName()
98 {
99     return g_currentTestName;
100 }
101 
GetTestEntryPoint(const std::string & testName)102 std::pair<std::string, std::string> GetTestEntryPoint(const std::string &testName)
103 {
104     return TestUtil::GetTest(testName)->GetEntryPoint();
105 }
106 }  // namespace panda::ecmascript::tooling::test
107