• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ArkScript-lang / Ark / 25858053380

14 May 2026 11:40AM UTC coverage: 94.21% (+0.1%) from 94.076%
25858053380

push

github

SuperFola
fix(builtins): redo the count left 0/1 bits to use an arbitrary number of bits

5 of 5 new or added lines in 1 file covered. (100.0%)

2 existing lines in 1 file now uncovered.

10137 of 10760 relevant lines covered (94.21%)

780037.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.18
/src/arkreactor/VM/Value/Value.cpp
1
#include <Ark/VM/Value/Value.hpp>
2
#include <Ark/VM/Value/Procedure.hpp>
3
#include <Ark/VM/Value/Dict.hpp>
4

5
#include <fmt/format.h>
6
#include <fmt/ostream.h>
7

8
namespace Ark
9
{
10
    Value::Value() noexcept :
4,634,142✔
11
        m_type(ValueType::Undefined)
4,634,142✔
12
    {}
9,268,284✔
13

14
    Value::Value(ValueType type) noexcept :
6,323✔
15
        m_type(type)
6,323✔
16
    {
6,323✔
17
        if (type == ValueType::List)
6,323✔
18
            m_value = List_t();
6,244✔
19
        else if (type == ValueType::String)
79✔
20
            m_value = std::string();
57✔
21
    }
6,323✔
22

23
    Value::Value(const int value) noexcept :
44,962✔
24
        m_type(ValueType::Number), m_value(static_cast<double>(value))
44,962✔
25
    {}
89,924✔
26

27
    Value::Value(const int64_t value) noexcept :
73✔
28
        m_type(ValueType::Number), m_value(static_cast<double>(value))
73✔
29
    {}
146✔
30

31
    Value::Value(const double value) noexcept :
4,487,753✔
32
        m_type(ValueType::Number), m_value(value)
4,487,753✔
33
    {}
8,975,506✔
34

35
    Value::Value(const String_t& value) noexcept :
38,837✔
36
        m_type(ValueType::String), m_value(value)
38,837✔
37
    {}
77,674✔
38

39
    Value::Value(const char* value) noexcept :
505✔
40
        m_type(ValueType::String), m_value(std::string(value))
505✔
41
    {}
505✔
42

43
    Value::Value(internal::PageAddr_t value) noexcept :
180,331✔
44
        m_type(ValueType::PageAddr), m_value(value)
180,331✔
45
    {}
360,662✔
46

47
    Value::Value(Procedure&& value) noexcept :
118✔
48
        m_type(ValueType::CProc), m_value(std::move(value))
118✔
49
    {}
118✔
50

51
    Value::Value(List_t&& value) noexcept :
145✔
52
        m_type(ValueType::List), m_value(std::move(value))
145✔
53
    {}
145✔
54

55
    Value::Value(internal::Closure&& value) noexcept :
3,484✔
56
        m_type(ValueType::Closure), m_value(std::move(value))
3,484✔
57
    {}
3,484✔
58

59
    Value::Value(UserType&& value) noexcept :
18✔
60
        m_type(ValueType::User), m_value(value)
18✔
61
    {}
18✔
62

63
    Value::Value(Dict_t&& value) noexcept :
56✔
64
        m_type(ValueType::Dict), m_value(std::make_shared<Dict_t>(std::move(value)))
56✔
65
    {}
112✔
66

67
    Value::Value(Ref_t ref) noexcept :
54,598✔
68
        m_type(ValueType::Reference), m_value(ref)
54,598✔
69
    {}
109,196✔
70

71
    void Value::push_back(const Value& value)
29,791✔
72
    {
29,791✔
73
        list().emplace_back(value);
29,791✔
74
    }
29,791✔
75

76
    void Value::push_back(Value&& value)
21✔
77
    {
21✔
78
        list().emplace_back(std::move(value));
21✔
79
    }
21✔
80

81
    std::string Value::toString(VM& vm, const bool show_as_code) const noexcept
4,386✔
82
    {
4,386✔
83
        switch (valueType())
4,386✔
84
        {
3,132✔
85
            case ValueType::Number:
86
                return fmt::format("{}", number());
4,242✔
87

88
            case ValueType::String:
89
                if (show_as_code)
1,110✔
90
                    return fmt::format("\"{}\"", string());
148✔
91
                return string();
984✔
92

93
            case ValueType::PageAddr:
94
                return fmt::format("Function@{}", pageAddr());
24✔
95

96
            case ValueType::CProc:
97
                return "CProcedure";
23✔
98

99
            case ValueType::List:
100
            {
101
                std::string out = "[";
21✔
102
                for (auto it = constList().begin(), it_end = constList().end(); it != it_end; ++it)
66✔
103
                {
104
                    if (it->valueType() == ValueType::String)
45✔
105
                        out += "\"" + it->toString(vm) + "\"";
5✔
106
                    else
107
                        out += it->toString(vm);
40✔
108
                    if (it + 1 != it_end)
45✔
109
                        out += " ";
27✔
110
                }
45✔
111
                return out + "]";
21✔
112
            }
22✔
113

114
            case ValueType::Closure:
115
                return closure().toString(vm);
2✔
116

117
            case ValueType::User:
118
                return fmt::format("{}", fmt::streamed(usertype()));
2✔
119

120
            case ValueType::Dict:
121
                return dict().toString(vm);
62✔
122

123
            case ValueType::Nil:
124
                return "nil";
83✔
125

126
            case ValueType::True:
127
                return "true";
24✔
128

129
            case ValueType::False:
130
                return "false";
2✔
131

132
            case ValueType::Undefined:
133
                return "undefined";
7✔
134

135
            case ValueType::Reference:
136
                if (reference() != this)
7✔
137
                    return reference()->toString(vm);
7✔
138
                return "Ref(self)";
4✔
139

140
            case ValueType::InstPtr:
141
                return fmt::format("Instruction@{}", pageAddr());
4✔
142

143
            case ValueType::Garbage:
UNCOV
144
                return fmt::format("Garbage (expected)");
×
145

146
            default:
UNCOV
147
                return "~\\._./~";
×
148
        }
149
    }
4,386✔
150

151
    bool operator==(const Value& A, const Value& B) noexcept
3,257,776✔
152
    {
3,257,776✔
153
        // values should have the same type
154
        if (A.m_type != B.m_type)
3,257,776✔
155
            return false;
2,101,065✔
156
        // all the types >= Nil are Nil itself, True, False, Undefined
157
        if (A.typeNum() >= static_cast<uint8_t>(ValueType::Nil))
1,156,711✔
158
            return true;
995✔
159

160
        if (A.valueType() == ValueType::Dict)
1,155,716✔
161
            return A.dict() == B.dict();
15✔
162

163
        return A.m_value == B.m_value;
1,155,701✔
164
    }
3,257,776✔
165

166
    bool operator!(const Value& A) noexcept
1,621,108✔
167
    {
1,621,108✔
168
        switch (A.valueType())
1,621,108✔
169
        {
1✔
170
            case ValueType::List:
171
                return A.constList().empty();
509,548✔
172

173
            case ValueType::Number:
174
                return A.number() == 0.0;
509,548✔
175

176
            case ValueType::String:
177
                return A.string().empty();
4✔
178

179
            case ValueType::Dict:
180
                return std::cmp_equal(A.dict().size(), 0);
45,032✔
181

182
            case ValueType::User:
183
                [[fallthrough]];
184
            case ValueType::Nil:
185
                [[fallthrough]];
186
            case ValueType::False:
187
                return true;
1,111,556✔
188

189
            case ValueType::True:
190
                [[fallthrough]];
191
            default:
192
                return false;
1,066,527✔
193
        }
194
    }
1,621,108✔
195
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc