luacat 사용 example

87 views
Skip to first unread message

Woo-Kyoung Noh

unread,
Aug 26, 2011, 1:34:49 AM8/26/11
to luausers-kr
안녕하세요.
루아 라이브러리를 github에서 공유하고 있습니다.
https://github.com/wookay/luacat


아래는 이를 사용하는 코드구요,
https://github.com/wookay/luacat/blob/master/Quiz/test_parse_url.lua
일부를 짜 봤습니다

Quiz 디렉토리에서 test_parse_params.lua를 만들어 아래 코드를 복사하고
lua test_parse_params.lua 실행하면 됩니다.


package.path = package.path .. ";../luacat/?.lua"
require 'luacat'

function parse_params(query)
return Hash(Table.map(String.split(query, '&'), function(pair)
return String.split(pair, '=')
end))
end

function test_parse_params()
local query = "client=safari&rls=en&q=lua&ie=UTF-8&oe=UTF-8"
local expected = {
client = "safari",
rls = "en",
q = "lua",
ie = "UTF-8",
oe = "UTF-8",
}
assert_equal(expected, parse_params(query))
end

if is_main() then
UnitTest.run()
end

Reply all
Reply to author
Forward
0 new messages