MCPcopy Create free account
hub / github.com/PlutoLang/Pluto / luaopen_assert

Function luaopen_assert

src/lassertlib.cpp:10–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8};
9
10LUAMOD_API int luaopen_assert(lua_State *L) {
11#ifdef PLUTO_DONT_LOAD_ANY_STANDARD_LIBRARY_CODE_WRITTEN_IN_PLUTO
12 return 0;
13#else
14 const auto code = R"EOC(pluto_use "0.6.0"
15
16local module = {}
17
18local function deepCompare(t1, t2)
19 if t1 == t2 then
20 return true
21 end
22
23 if #t1 ~= #t2 then
24 return false
25 end
26
27 if next(t1) == nil and next(t2) ~= nil then
28 return false
29 end
30
31 for k, v1 in t1 do
32 local v2 = t2[k]
33
34 if type(v1) == "table" and type(v2) == "table" and v1 ~= v2 then
35 if not deepCompare(v1, v2) then
36 return false
37 end
38 elseif v1 ~= v2 then
39 return false
40 end
41 end
42
43 for k in t2 do
44 if t1[k] == nil then
45 return false
46 end
47 end
48
49 return true
50end
51
52local class AssertionError
53 function __construct(assertion_name: string, public intended_value, public received_value)
54 self.assertion_name = "assert." .. assertion_name
55 self.should_dump = true
56 self.write_intended = true
57 self.write_recieved = true
58
59 self.intended_name = "Intended Value"
60 self.received_name = "Received Value"
61
62 return self
63 end
64
65 function raise()
66 local message = self:getFileInformation() .. " -> Assertion Error: " .. self:getExtraInformation()
67

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected