1e509ee18Sopenharmony_ci/*
2e509ee18Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3e509ee18Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e509ee18Sopenharmony_ci * you may not use this file except in compliance with the License.
5e509ee18Sopenharmony_ci * You may obtain a copy of the License at
6e509ee18Sopenharmony_ci *
7e509ee18Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e509ee18Sopenharmony_ci *
9e509ee18Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e509ee18Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e509ee18Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e509ee18Sopenharmony_ci * See the License for the specific language governing permissions and
13e509ee18Sopenharmony_ci * limitations under the License.
14e509ee18Sopenharmony_ci */
15e509ee18Sopenharmony_ci
16e509ee18Sopenharmony_ci#include "test/utils/test_util.h"
17e509ee18Sopenharmony_ci
18e509ee18Sopenharmony_cinamespace panda::ecmascript::tooling::test {
19e509ee18Sopenharmony_ciTestMap TestUtil::testMap_;
20e509ee18Sopenharmony_cios::memory::Mutex TestUtil::eventMutex_;
21e509ee18Sopenharmony_cios::memory::ConditionVariable TestUtil::eventCv_;
22e509ee18Sopenharmony_ciDebugEvent TestUtil::lastEvent_ = DebugEvent::UNINITIALIZED;
23e509ee18Sopenharmony_cibool TestUtil::initialized_ = false;
24e509ee18Sopenharmony_cios::memory::Mutex TestUtil::suspendMutex_;
25e509ee18Sopenharmony_cios::memory::ConditionVariable TestUtil::suspendCv_;
26e509ee18Sopenharmony_cibool TestUtil::suspended_ = false;
27e509ee18Sopenharmony_ciJSPtLocation TestUtil::lastEventLocation_(nullptr, EntityId(0), 0);
28e509ee18Sopenharmony_ci
29e509ee18Sopenharmony_cistd::ostream &operator<<(std::ostream &out, DebugEvent value)
30e509ee18Sopenharmony_ci{
31e509ee18Sopenharmony_ci    const char *s = nullptr;
32e509ee18Sopenharmony_ci
33e509ee18Sopenharmony_ci#define ADD_CASE(entry) \
34e509ee18Sopenharmony_ci    case (entry):       \
35e509ee18Sopenharmony_ci        s = #entry;     \
36e509ee18Sopenharmony_ci        break
37e509ee18Sopenharmony_ci
38e509ee18Sopenharmony_ci    switch (value) {
39e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::BREAKPOINT);
40e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::LOAD_MODULE);
41e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::PAUSED);
42e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::EXCEPTION);
43e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::STEP_COMPLETE);
44e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::METHOD_ENTRY);
45e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::SINGLE_STEP);
46e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::VM_START);
47e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::VM_INITIALIZATION);
48e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::VM_DEATH);
49e509ee18Sopenharmony_ci        ADD_CASE(DebugEvent::UNINITIALIZED);
50e509ee18Sopenharmony_ci        default: {
51e509ee18Sopenharmony_ci            ASSERT(false && "Unknown DebugEvent");  // NOLINT
52e509ee18Sopenharmony_ci        }
53e509ee18Sopenharmony_ci    }
54e509ee18Sopenharmony_ci
55e509ee18Sopenharmony_ci#undef ADD_CASE
56e509ee18Sopenharmony_ci
57e509ee18Sopenharmony_ci    return out << s;
58e509ee18Sopenharmony_ci}
59e509ee18Sopenharmony_ci
60e509ee18Sopenharmony_cistd::ostream &operator<<(std::ostream &out, std::nullptr_t)
61e509ee18Sopenharmony_ci{
62e509ee18Sopenharmony_ci    return out << "nullptr";
63e509ee18Sopenharmony_ci}
64e509ee18Sopenharmony_ci
65e509ee18Sopenharmony_ciTestEvents::TestEvents()
66e509ee18Sopenharmony_ci{
67e509ee18Sopenharmony_ci    scenario = []() {
68e509ee18Sopenharmony_ci        ASSERT_EXITED();
69e509ee18Sopenharmony_ci        return true;
70e509ee18Sopenharmony_ci    };
71e509ee18Sopenharmony_ci}
72e509ee18Sopenharmony_ci}  // namespace panda::ecmascript::tooling::test
73