mirror of
https://github.com/kikito/inspect.lua.git
synced 2024-12-15 14:34:21 +00:00
Merge pull request #49 from kikito/fix-del-escape
escape DEL character. fixes #40
This commit is contained in:
commit
a74242cdac
29
.github/workflows/test.yml
vendored
Normal file
29
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: test
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
luaVersion: ["5.1.5", "5.2.4", "luajit-2.1.0-beta3", "luajit-openresty"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
|
||||||
|
- uses: leafo/gh-actions-lua@v8.0.0
|
||||||
|
with:
|
||||||
|
luaVersion: ${{ matrix.luaVersion }}
|
||||||
|
|
||||||
|
- uses: leafo/gh-actions-luarocks@v4.0.0
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
luarocks install busted
|
||||||
|
luarocks make
|
||||||
|
|
||||||
|
- name: test
|
||||||
|
run: |
|
||||||
|
busted -o utfTerminal
|
36
.travis.yml
36
.travis.yml
@ -1,36 +0,0 @@
|
|||||||
language: python
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
env:
|
|
||||||
- LUA="lua=5.1"
|
|
||||||
- LUA="lua=5.2"
|
|
||||||
- LUA="lua=5.3"
|
|
||||||
- LUA="luajit=2.0"
|
|
||||||
- LUA="luajit=2.1"
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- pip install hererocks
|
|
||||||
- hererocks lua_install -r^ --$LUA
|
|
||||||
- export PATH=$PATH:$PWD/lua_install/bin # Add directory with all installed binaries to PATH
|
|
||||||
|
|
||||||
install:
|
|
||||||
- luarocks install luacheck
|
|
||||||
- luarocks install busted
|
|
||||||
- luarocks install luacov
|
|
||||||
- luarocks install luacov-coveralls
|
|
||||||
|
|
||||||
script:
|
|
||||||
- luacheck --std max+busted *.lua spec
|
|
||||||
- busted --verbose --coverage
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- luacov-coveralls --exclude $TRAVIS_BUILD_DIR/lua_install
|
|
||||||
|
|
||||||
branches:
|
|
||||||
except:
|
|
||||||
- gh-pages
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
email:
|
|
||||||
on_success: change
|
|
||||||
on_failure: always
|
|
@ -1,9 +1,6 @@
|
|||||||
inspect.lua
|
inspect.lua
|
||||||
===========
|
===========
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/kikito/inspect.lua.png?branch=master)](https://travis-ci.org/kikito/inspect.lua)
|
|
||||||
[![Coverage Status](https://coveralls.io/repos/github/kikito/inspect.lua/badge.svg?branch=master)](https://coveralls.io/github/kikito/inspect.lua?branch=master)
|
|
||||||
|
|
||||||
|
|
||||||
This library transforms any Lua value into a human-readable representation. It is especially useful for debugging errors in tables.
|
This library transforms any Lua value into a human-readable representation. It is especially useful for debugging errors in tables.
|
||||||
|
|
||||||
|
@ -46,12 +46,12 @@ local function smartQuote(str)
|
|||||||
return '"' .. str:gsub('"', '\\"') .. '"'
|
return '"' .. str:gsub('"', '\\"') .. '"'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- \a => '\\a', \0 => '\\0', 31 => '\31'
|
-- \a => '\\a', \0 => nil
|
||||||
local shortControlCharEscapes = {
|
local shortControlCharEscapes = {
|
||||||
["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n",
|
["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n",
|
||||||
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v"
|
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v", ["\127"] = "\\127",
|
||||||
}
|
}
|
||||||
local longControlCharEscapes = {} -- \a => nil, \0 => \000, 31 => \031
|
local longControlCharEscapes = {["\127"]="\127"} -- \a => nil, \0 => \000, 31 => \031
|
||||||
for i=0, 31 do
|
for i=0, 31 do
|
||||||
local ch = string.char(i)
|
local ch = string.char(i)
|
||||||
if not shortControlCharEscapes[ch] then
|
if not shortControlCharEscapes[ch] then
|
||||||
@ -59,6 +59,7 @@ for i=0, 31 do
|
|||||||
longControlCharEscapes[ch] = string.format("\\%03d", i)
|
longControlCharEscapes[ch] = string.format("\\%03d", i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--longControlCharEscapes["\127"]="\\127"
|
||||||
|
|
||||||
local function escape(str)
|
local function escape(str)
|
||||||
return (str:gsub("\\", "\\\\")
|
return (str:gsub("\\", "\\\\")
|
||||||
|
@ -43,7 +43,12 @@ describe( 'inspect', function()
|
|||||||
inspect('Here are some control characters: \0 \1 \6 \17 \27 \31'))
|
inspect('Here are some control characters: \0 \1 \6 \17 \27 \31'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('escapes unnamed control characters with 3 digits when they are followed by numbers', function()
|
it('escapes DEL', function()
|
||||||
|
assert.equals('"DEL: \\127"',
|
||||||
|
inspect('DEL: \127'))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('escapes unnamed control characters with 4 digits when they are followed by numbers', function()
|
||||||
assert.equals('"Control chars followed by digits \\0001 \\0011 \\0061 \\0171 \\0271 \\0311"',
|
assert.equals('"Control chars followed by digits \\0001 \\0011 \\0061 \\0171 \\0271 \\0311"',
|
||||||
inspect('Control chars followed by digits \0001 \0011 \0061 \0171 \0271 \0311'))
|
inspect('Control chars followed by digits \0001 \0011 \0061 \0171 \0271 \0311'))
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user