github.com/erikdubbelboer/gopher-lua@v0.0.0-20160512044044-e68f0dc85040/_glua-tests/strings.lua (about)

     1  
     2  local ok, msg = pcall(function()
     3    string.dump()
     4  end)
     5  assert(not ok and string.find(msg, "GopherLua does not support the string.dump"))
     6  assert(string.find("","aaa") == nil)
     7  assert(string.gsub("hello world", "(%w+)", "%1 %1 %c") == "hello hello %c world world %c")
     8  local ok, msg = pcall(function()
     9    string.gsub("aaa", "]", "")
    10  end)
    11  assert(not ok and string.find(msg, "invalid '%]'"))
    12  
    13  local ok, msg = pcall(function()
    14    string.match("aaa", "]", -10)
    15  end)
    16  assert(not ok and string.find(msg, "invalid '%]'"))
    17  
    18  local ok, msg = pcall(function()
    19    string.find("aaa", "]")
    20  end)
    21  assert(not ok and string.find(msg, "invalid '%]'"))
    22  
    23  local ok, msg = pcall(function()
    24    string.gmatch("aaa", "]")
    25  end)
    26  assert(not ok and string.find(msg, "invalid '%]'"))
    27  
    28  local ret1, ret2, ret3, ret4 = string.find("aaa bbb", "(%w+())")
    29  assert(ret1 == 1)
    30  assert(ret2 == 3)
    31  assert(ret3 == "aaa")
    32  assert(ret4 == 4)