Skip to content

Commit

Permalink
Test file(mian.lua) and readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
wlingze committed Dec 13, 2020
1 parent 2984c52 commit 960f290
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
73 changes: 72 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,73 @@
# iccream-lua
icecream-lua

Never use print() to debug again. (lua)

lua version of [IceCraem](https://github.com/gruns/icecream).

## install

```sh
luarocks install icecream
```

## use

improt module:

```lua
local ic = require("icecream")
```

just use ic() to print information

**The example of printing variables**

```lua
a = 10
ic(a)
local x = 1
local y = 2
ic(x,y)
```

output `ic| a = 1` and `ic| x = 1, y = 1`

**The exmple of printing function**

```lua
local function fun1(a)
return a + 1
end
ic(fun1(22))
```

output `ic| fun1(22) = 23`

**The exmple when there are no parameters**

```lua
ic()
```

output: `ic| ` + filename + line + function, like this: `ic| /home/wlz/gh/icecream-lua/main.lua:37: in local 'testNoArg'`

**The exmple when there is no variable name**

```lua
ic(1, 2)
```

output: `ic| 1, 2`

**The exmple of display line munber**

```lua
ic(x,y)
-- ic| x = 1, y = 1
ic:SetIsOutPutPosition(true)
ic(x,y)
-- /home/wlz/gh/icecream-lua/main.lua:11: in local 'testPosition'
-- ic| x = 1, y = 1
```


9 changes: 7 additions & 2 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ local function testFunc()
end
ic(func(a1))
end

testPrefix()
print('---- test ic')
testIC()
print('---- test prefix')
testPrefix()
print('---- test positoin')
testPosition()
print('---- test no name')
testNoName()
print('---- test no args')
testNoArg()
print('---- test function')
testFunc()

0 comments on commit 960f290

Please sign in to comment.