mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Add some minor tests of Lua library
This commit is contained in:
parent
017a7499d2
commit
dfdadbe9c1
10
scripts/math.lua
Normal file
10
scripts/math.lua
Normal file
@ -0,0 +1,10 @@
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
-- Read LICENSE.txt for more information.
|
||||
|
||||
assert(100 == math.abs(-100))
|
||||
assert(100 == math.min(100, 200, 300))
|
||||
assert(300 == math.max(100, 200, 300))
|
||||
assert(50 == math.fmod(250, 100))
|
||||
assert(3141 == math.floor(1000*math.pi))
|
14
scripts/os.lua
Normal file
14
scripts/os.lua
Normal file
@ -0,0 +1,14 @@
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
-- Read LICENSE.txt for more information.
|
||||
|
||||
assert("" ~= os.getenv("PATH"))
|
||||
print("PATH", os.getenv("PATH"))
|
||||
|
||||
local start_clock = os.clock()
|
||||
print("Start ", start_clock)
|
||||
|
||||
local end_clock = os.clock()
|
||||
print("End ", end_clock, " Elapsed ", end_clock - start_clock)
|
||||
assert(start_clock < end_clock)
|
23
scripts/string.lua
Normal file
23
scripts/string.lua
Normal file
@ -0,0 +1,23 @@
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
-- Read LICENSE.txt for more information.
|
||||
|
||||
assert(72 == string.byte("Hello", 1))
|
||||
assert(101 == string.byte("Hello", 2))
|
||||
assert(111 == string.byte("Hello", 5))
|
||||
assert("Hello" == string.char(72, 101, 108, 108, 111))
|
||||
|
||||
local s = "Hello"
|
||||
assert(111 == s:byte(5))
|
||||
assert(5 == string.len(s))
|
||||
assert("olleH" == string.reverse(s))
|
||||
assert("hello" == string.lower(s))
|
||||
assert("HELLO" == string.upper(s))
|
||||
|
||||
assert("Simple int 32" == string.format("Simple int %d", 32))
|
||||
assert("Simple int 0032" == string.format("Simple int %04d", 32))
|
||||
|
||||
assert(7 == string.find("Hello World!", "W"))
|
||||
|
||||
assert("-- hi 1000 --" == string.format("-- %s %d --", "hi", 1000))
|
Loading…
x
Reference in New Issue
Block a user