forked from prometheus-lua/Prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyntax.lua
More file actions
38 lines (33 loc) · 987 Bytes
/
syntax.lua
File metadata and controls
38 lines (33 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--============================================================
-- Syntax Test Suite
-- Target: Unparser
-- Author: SpinnySpiwal
-- Purpose: Validate appropriate parser & unparser functionality, specifically in unseen edge cases.
-- Update 1: Added test for precedence bug fix in expressionPow.
--============================================================
local char = ("").char
print(char == string.char and "yes" or "no")
local pc, _ = pcall(function()
return (0).char
end)
-- Checks for unparser bug
print(pc == false and "yes" or "no")
local ok = pcall(function(...)
print("hello " .. ...)
end)
print(ok and "no" or "yes")
local function getString()
return "this string is 24 chars!"
end
-- Test for precedence bug fix in expressionPow
if 2 ^ #getString() == 16777216 then
print("TEST 1 PASSED")
else
print("TEST 1 FAILED")
end
-- Check if it still works the other way around
if (#getString()) ^ 2 == 576 then
print("TEST 2 PASSED")
else
print("TEST 2 FAILED")
end