From 69135233d57262f4895c105ae78215fb1f96e439 Mon Sep 17 00:00:00 2001 From: James Roseborough Date: Wed, 23 Jul 2008 14:11:56 +0000 Subject: [PATCH] improve strlib test. --- src/test/res/strlib.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/test/res/strlib.lua b/src/test/res/strlib.lua index b8db75a1..e7aaa9b8 100644 --- a/src/test/res/strlib.lua +++ b/src/test/res/strlib.lua @@ -82,14 +82,18 @@ print(string.len("\0\0\0")) print(#"\0\0\0") print(string.len("\0\1\2\3")) print(#"\0\1\2\3") -local s = "\194\161Hola!" +local s = "My JaCk-O-lAnTeRn CaSe TeXt" print(s, string.len(s), #s) +local function pc(...) + local s,e = pcall(...) + return s and e or 'false-'..type(e) +end local function strtests(name,func,...) - print(name, 'good', pcall( func, ... ) ) - print(name, 'empty', pcall( func ) ) - print(name, 'table', pcall( func, {} ) ) - print(name, 'nil', pcall( func, nil ) ) + print(name, 'good', pc( func, ... ) ) + print(name, 'empty', pc( func ) ) + print(name, 'table', pc( func, {} ) ) + print(name, 'nil', pc( func, nil ) ) end strtests('lower', string.lower, s )