Fix string.len (includes new tests.)
This commit is contained in:
@@ -395,7 +395,7 @@ public class StringLib extends LFunction {
|
||||
* Embedded zeros are counted, so "a\000bc\000" has length 5.
|
||||
*/
|
||||
static void len( LuaState vm ) {
|
||||
int l = vm.tostring(2).length();
|
||||
int l = vm.tolstring(2).length();
|
||||
vm.resettop();
|
||||
vm.pushinteger( l );
|
||||
}
|
||||
|
||||
@@ -68,3 +68,12 @@ t( 'abc' )
|
||||
t( 'ab' )
|
||||
t( 'a' )
|
||||
t( '' )
|
||||
|
||||
print(string.len("Hello, world"))
|
||||
print(#"Hello, world")
|
||||
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!"
|
||||
print(s, string.len(s), #s)
|
||||
|
||||
Reference in New Issue
Block a user