mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +00:00
Pledge and unveil redbean's unit tests
This commit is contained in:
parent
513a659dd2
commit
31e4b0867b
21 changed files with 44 additions and 6 deletions
|
@ -13,6 +13,8 @@
|
|||
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
assert(assert(argon2.hash_encoded("password", "somesalt", {
|
||||
variant = argon2.variants.argon2_i,
|
||||
m_cost = 65536,
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
assert(EncodeJson(nil) == "null")
|
||||
assert(EncodeJson(true) == "true")
|
||||
assert(EncodeJson(false) == "false")
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
assert(EncodeLua(nil) == "nil")
|
||||
assert(EncodeLua(true) == "true")
|
||||
assert(EncodeLua(false) == "false")
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
unix.pledge("stdio")
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail11.json
|
||||
assert(not DecodeJson([[
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
unix.pledge("stdio")
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: pass1.json
|
||||
assert(DecodeJson([[
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
-- these test cases are prefixed with n_
|
||||
-- ljson should reject all of them as invalid
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
-- these test cases are prefixed with n_
|
||||
-- ljson should reject all of them as invalid
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
-- these test cases are prefixed with n_
|
||||
-- ljson should reject all of them as invalid
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
-- these test cases are prefixed with n_
|
||||
-- ljson should reject all of them as invalid
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
-- these test cases are prefixed with i_
|
||||
-- ljson is free to accept or reject,
|
||||
-- but we run them anyway to check for segfaults
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
-- these test cases are prefixed with y_
|
||||
-- ljson should accept all of them as valid
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
x = Rdtsc()
|
||||
y = Rdtsc()
|
||||
assert(y > x)
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
assert(EncodeLua(assert(DecodeJson[[ 0 ]])) == '0' )
|
||||
assert(EncodeLua(assert(DecodeJson[[ [1] ]])) == '{1}')
|
||||
assert(EncodeLua(assert(DecodeJson[[ 2.3 ]])) == '2.3')
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
assert(string.match("127.123.231.1", "%d+.%d+.%d+.%d+"))
|
||||
assert(re.search([[^\d{1,3}(\.\d{1,3}){3}$]], "127.123.231.1"))
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
-- test redbean lua language extensions
|
||||
assert(0b100 == 4)
|
||||
assert(0200 == 128)
|
||||
|
|
|
@ -151,6 +151,9 @@ end
|
|||
|
||||
function main()
|
||||
assert(unix.makedirs(tmpdir))
|
||||
unix.unveil(tmpdir, "rwc")
|
||||
unix.unveil(nil, nil)
|
||||
unix.pledge("stdio rpath wpath cpath proc")
|
||||
ok, err = pcall(UnixTest)
|
||||
if ok then
|
||||
assert(unix.rmrf(tmpdir))
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
unix.pledge("stdio")
|
||||
|
||||
assert("/usr/lib" == path.dirname("/usr/lib/foo.bar"))
|
||||
assert("/usr" == path.dirname("/usr/lib"))
|
||||
assert("usr" == path.dirname("usr/lib"))
|
||||
|
|
|
@ -38,6 +38,9 @@ end
|
|||
|
||||
local function main()
|
||||
assert(unix.makedirs(tmpdir))
|
||||
unix.unveil(tmpdir, "rwc")
|
||||
unix.unveil(nil, nil)
|
||||
unix.pledge("stdio rpath wpath cpath")
|
||||
ok, err = pcall(SlurpTest)
|
||||
if ok then
|
||||
assert(unix.rmrf(tmpdir))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue