Skip to content

Commit

Permalink
Use snake_case for urlencode, urldecode, and formatint
Browse files Browse the repository at this point in the history
  • Loading branch information
well-in-that-case authored and Sainan committed Nov 21, 2023
1 parent 89c7d19 commit 3204503
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/lstrlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2354,10 +2354,10 @@ static int str_urldecode (lua_State *L) {
static const luaL_Reg strlib[] = {
{"duplicate", str_duplicate},
#ifdef PLUTO_USE_SOUP
{"urldecode", str_urldecode},
{"urlencode", str_urlencode},
{"url_decode", str_urldecode},
{"url_encode", str_urlencode},
#endif
{"formatint", str_formatint},
{"format_int", str_formatint},
{"replace", str_replace},
{"truncate", str_truncate},
{"find_last_not_of", str_find_last_not_of},
Expand Down
12 changes: 6 additions & 6 deletions testes/pluto/basic.pluto
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ do
assert(string.replace("LLLL", "L", "X") == "XXXX")
assert(string.replace("LLLL", "L", "X", 2) == "XXLL")
local function septest(sep)
local fn = |...| -> string.formatint(...)
local fn = |...| -> string.format_int(...)

assert(fn(100, sep) == "100")
assert(fn(1000, sep) == $"1{sep}000")
Expand All @@ -1072,7 +1072,7 @@ do
assert(err:contains("length of 1"))

local function septest2(sep)
local fn = |...| -> string.formatint(...)
local fn = |...| -> string.format_int(...)

assert(fn(100, sep, 2) == $"1{sep}00")
assert(fn(1000, sep, 2) == $"10{sep}00")
Expand All @@ -1089,13 +1089,13 @@ do
septest2(".")
septest2(" ")

assert(string.formatint("+3249230492345645324234234234234234234234234324242343243242342343423242344") == "+3,249,230,492,345,645,324,234,234,234,234,234,234,234,234,324,242,343,243,242,342,343,423,242,344")
assert(string.formatint("-3249230492345645324234234234234234234234234324242343243242342343423242344") == "-3,249,230,492,345,645,324,234,234,234,234,234,234,234,234,324,242,343,243,242,342,343,423,242,344")
assert(string.format_int("+3249230492345645324234234234234234234234234324242343243242342343423242344") == "+3,249,230,492,345,645,324,234,234,234,234,234,234,234,234,324,242,343,243,242,342,343,423,242,344")
assert(string.format_int("-3249230492345645324234234234234234234234234324242343243242342343423242344") == "-3,249,230,492,345,645,324,234,234,234,234,234,234,234,234,324,242,343,243,242,342,343,423,242,344")

if _PSOUP then
local str = "Hello, World! == %% 20 <> //\\"
assert(string.urlencode(str) == "Hello%2C%20World%21%20%3D%3D%20%25%25%2020%20%3C%3E%20%2F%2F%5C")
assert(string.urlencode(str):urldecode() == str)
assert(string.url_encode(str) == "Hello%2C%20World%21%20%3D%3D%20%25%25%2020%20%3C%3E%20%2F%2F%5C")
assert(string.url_encode(str):url_decode() == str)
end

assert("*":duplicate(3) == "***")
Expand Down

0 comments on commit 3204503

Please sign in to comment.