tests: top-level test comments: specs only
This commit is contained in:
1 parent
0bd7b87d2b
commit
e0ab895027
3 files changed
+4
-38
No files matched your search
+1
-14
@@ -1,12 +1,8 @@
|
||||
-- compat tests: the Luau semantics the library relies on, checked under both runtimes. Under luau these pin down what
|
||||
-- Luau does; under LuaJIT they check compat/luajit.lua (bit32, buffer, table / math / string / utf8 additions, typeof)
|
||||
-- and tools/build.py's lowering (generalized iteration, if-expression chains, continue, compound assignment, string
|
||||
-- interpolation, floor division, number literals).
|
||||
-- compat tests: the Luau semantics the library relies on, under luau and under LuaJIT (compat/luajit.lua + build.py lowering).
|
||||
local T = require("@tests/T")
|
||||
|
||||
local t = T.suite("compat")
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ bit32
|
||||
do
|
||||
t:eq(bit32.band(0xFFFFFFFF, 0x0F0F0F0F), 0x0F0F0F0F, "band unsigned")
|
||||
t:eq(bit32.band(-1), 0xFFFFFFFF, "band(-1)")
|
||||
@@ -46,7 +42,6 @@ do
|
||||
t:check(bit32.btest(6, 2) and not bit32.btest(4, 2), "btest")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ buffer
|
||||
do
|
||||
local b = buffer.create(16)
|
||||
t:eq(buffer.len(b), 16, "len")
|
||||
@@ -92,7 +87,6 @@ do
|
||||
t:check(not pcall(buffer.readstring, b, 10, 7), "readstring past the end throws")
|
||||
t:check(not pcall(buffer.copy, b, 10, b, 0, 7), "copy past the end throws")
|
||||
t:check(not pcall(buffer.fill, b, 10, 0, 7), "fill past the end throws")
|
||||
-- strings, NULs, copy, fill
|
||||
local s = buffer.fromstring("a\0b\255c")
|
||||
t:eq(buffer.len(s), 5, "fromstring with NUL")
|
||||
t:eq(buffer.tostring(s), "a\0b\255c", "tostring with NUL")
|
||||
@@ -112,7 +106,6 @@ do
|
||||
t:eq(buffer.tostring(c), "ABBA", "fill value wraps")
|
||||
t:eq(buffer.len(buffer.create(0)), 0, "empty buffer")
|
||||
t:eq(buffer.tostring(buffer.create(0)), "", "empty tostring")
|
||||
-- readbits / writebits
|
||||
local bb = buffer.create(8)
|
||||
buffer.writeu32(bb, 0, 0xDEADBEEF)
|
||||
t:eq(buffer.readbits(bb, 4, 12), 3054, "readbits")
|
||||
@@ -130,7 +123,6 @@ do
|
||||
t:eq(buffer.readu8(big, 500000), 0, "big buffer zero-filled")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ typeof / type
|
||||
do
|
||||
local b = buffer.create(1)
|
||||
t:eq(typeof(b), "buffer", "typeof buffer")
|
||||
@@ -141,7 +133,6 @@ do
|
||||
t:eq(typeof("s"), "string", "typeof string")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ table / math / string
|
||||
do
|
||||
local c = table.create(3, 7)
|
||||
t:eq(#c, 3, "table.create size")
|
||||
@@ -177,7 +168,6 @@ do
|
||||
t:eq(math.floor(-3.5), -4, "floor")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ utf8
|
||||
do
|
||||
t:eq(utf8.char(72, 228, 8364, 128512), "H\xC3\xA4\xE2\x82\xAC\xF0\x9F\x98\x80", "utf8.char")
|
||||
t:eq(utf8.len("h\xC3\xA4ll\xE2\x82\xAC"), 5, "utf8.len")
|
||||
@@ -193,9 +183,7 @@ do
|
||||
t:check(string.find("\xC3\xA4", utf8.charpattern) == 1, "utf8.charpattern")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ syntax lowering
|
||||
do
|
||||
-- generalized iteration: arrays (in order), dictionaries, mixed, iterator functions, nested
|
||||
local order = {}
|
||||
for i, v in { 10, 20, 30 } do
|
||||
table.insert(order, i * 100 + v)
|
||||
@@ -253,7 +241,6 @@ do
|
||||
local v = 5
|
||||
local arith = if v > 3 then v * 2 else v - 1
|
||||
t:eq(arith, 10, "if-expression arithmetic")
|
||||
-- continue, compound assignment, interpolation, floor division, literals
|
||||
local odd = 0
|
||||
for i = 1, 10 do
|
||||
if i % 2 == 0 then
|
||||
|
||||
Reference in new issue
Block a user