- Timestamp:
- 04/26/2008 01:08:10 (7 months ago)
- Location:
- trunk/ext/lua
- Files:
-
- 1 added
- 3 modified
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/lua/Makefile
r217 r306 1 1 # change these to reflect your Lua installation 2 LUA=/usr/ 3 LUAINC= $(LUA)/include/lua50 4 LUALIB= $(LUA)/lib 5 LUABIN= $(LUA)/bin 2 # Default installation prefix 3 PREFIX=/home/leop/local 4 5 # System's libraries directory (where binary libraries are installed) 6 LUA_LIBDIR= $(PREFIX)/lib/lua/5.1 7 8 # System's lua directory (where Lua libraries are installed) 9 LUA_DIR= $(PREFIX)/share/lua/5.1 10 11 LUAINC= $(PREFIX)/include 12 LUALIB= $(PREFIX)/lib 13 LUABIN= $(PREFIX)/bin 6 14 7 15 CFLAGS= $(INCS) $(WARN) 8 16 WARN= -Wall 9 17 INCS= -I$(LUAINC) 10 LIBS=-lsyck 18 LIBS=-lsyck -L$(LUALIB) 11 19 12 MYNAME= syck 13 MYLIB= l$(MYNAME) 20 MYNAME=syck 21 OBJS= $(MYNAME).o 22 T= $(MYNAME).so 14 23 15 OBJS= $(MYLIB).o 24 all: $T test 16 25 17 T= $(MYLIB).so 26 install: 27 cp -f ./syck.so $(LUA_LIBDIR) 28 cp -f ./yaml.lua $(LUA_DIR) 18 29 19 all: $T 20 21 test: $T 30 uninstall: 31 rm -f $(LUA_DIR)/yaml.lua 32 rm -f $(LUA_LIBDIR)/syck.so 33 34 test: $t 22 35 $(LUABIN)/lua test.lua 36 @echo "built and tested successfully. run make install to install, or just move the libs manually" 23 37 24 38 $T: $(OBJS) … … 26 40 27 41 clean: 28 rm -f $(OBJS) $T core core.* a.out 42 rm -f $(OBJS) $T core core.* a.out test.dump 43 44 ready: -
trunk/ext/lua/test.lua
r221 r306 8 8 9 9 function testcase.test_load() 10 assert_error(function() syck.load() end)11 assert_nil( syck.load("--- "))12 assert_true( syck.load("--- true"))13 assert_false( syck.load("--- false"))14 assert_equal(10, syck.load("--- 10"))15 local t = syck.load("--- \n- 5\n- 10\n- 15")10 assert_error(function() yaml.load() end) 11 assert_nil(yaml.load("--- ")) 12 assert_true(yaml.load("--- true")) 13 assert_false(yaml.load("--- false")) 14 assert_equal(10, yaml.load("--- 10")) 15 local t = yaml.load("--- \n- 5\n- 10\n- 15") 16 16 assert_equal(5, t[1]) 17 17 assert_equal(10, t[2]) 18 18 assert_equal(15, t[3]) 19 local t = syck.load("--- \n- one\n- two\n- three")19 local t = yaml.load("--- \n- one\n- two\n- three") 20 20 assert_equal("one", t[1]) 21 21 assert_equal("two", t[2]) 22 22 assert_equal("three", t[3]) 23 local t = syck.load("--- \nthree: 15\ntwo: 10\none: 5")23 local t = yaml.load("--- \nthree: 15\ntwo: 10\none: 5") 24 24 assert_equal(5, t.one) 25 25 assert_equal(10, t.two) 26 26 assert_equal(15, t.three) 27 local t = syck.load("--- \nints: \n - 1\n - 2\n - 3\nmaps: \n three: 3\n two: 2\n one: 1\nstrings: \n - one\n - two\n - three")27 local t = yaml.load("--- \nints: \n - 1\n - 2\n - 3\nmaps: \n three: 3\n two: 2\n one: 1\nstrings: \n - one\n - two\n - three") 28 28 assert_equal(1, t.ints[1]) 29 29 assert_equal(2, t.ints[2]) … … 38 38 39 39 function testcase.test_dump() 40 assert_equal("--- \n", syck.dump(nil))41 assert_equal("--- hey\n", syck.dump("hey"))42 assert_equal("--- 5\n", syck.dump(5))43 assert_equal("--- true\n", syck.dump(true))44 assert_equal("--- false\n", syck.dump(false))45 assert_equal("--- \n- 5\n- 6\n- 7\n", syck.dump({5, 6, 7}))40 assert_equal("--- \n", yaml.dump(nil)) 41 assert_equal("--- hey\n", yaml.dump("hey")) 42 assert_equal("--- 5\n", yaml.dump(5)) 43 assert_equal("--- true\n", yaml.dump(true)) 44 assert_equal("--- false\n", yaml.dump(false)) 45 assert_equal("--- \n- 5\n- 6\n- 7\n", yaml.dump({5, 6, 7})) 46 46 47 47 local str = "--- \n- \n - 1\n - 2\n - 3\n- \n - 6\n - 7\n - 8\n" 48 assert_equal(str, syck.dump({{1, 2, 3}, {6, 7, 8}}))48 assert_equal(str, yaml.dump({{1, 2, 3}, {6, 7, 8}})) 49 49 local str = "--- \n- \n - 1\n - 2\n - 3\n- \n - one\n - two\n - three\n" 50 assert_equal(str, syck.dump({{1, 2, 3}, {"one", "two", "three"}}))50 assert_equal(str, yaml.dump({{1, 2, 3}, {"one", "two", "three"}})) 51 51 52 52 local str = "--- \none: 1\nthree: 3\ntwo: 2\n" 53 assert_equal(str, syck.dump({one=1, two=2, three=3}))53 assert_equal(str, yaml.dump({one=1, two=2, three=3})) 54 54 end 55 55 -
trunk/ext/lua/yaml.lua
r221 r306 1 1 -- borrow from lposix 2 2 -- 3 local function so(x) 4 local SOPATH= os.getenv"LUA_SOPATH" or "./" 5 assert(loadlib(SOPATH.."l"..x..".so","luaopen_"..x))() 6 end 7 8 so"syck" 3 require "syck" 9 4 10 5 yaml = {}