-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
46 lines (43 loc) · 839 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"luago/state"
"testing"
)
func TestLuaState(t *testing.T) {
ls := state.New()
ls.PushBoolean(true)
printStack(ls)
ls.PushInteger(10)
printStack(ls)
ls.PushNil()
printStack(ls)
ls.PushString("hello")
printStack(ls)
ls.PushValue(-4)
printStack(ls)
ls.Replace(3)
printStack(ls)
ls.SetTop(6)
printStack(ls)
ls.Remove(-3)
printStack(ls)
ls.SetTop(-5)
printStack(ls)
}
// func printStack(ls *state.LuaState) {
// top := ls.GetTop()
// for i := 1; i <= top; i++ {
// t := ls.Type(i)
// switch t {
// case api.LUA_TBOOLEAN:
// fmt.Printf("[%t]", ls.ToBoolean(i))
// case api.LUA_TNUMBER:
// fmt.Printf("[%g]", ls.ToNumber(i))
// case api.LUA_TSTRING:
// fmt.Printf("[%q]", ls.ToString(i))
// default:
// fmt.Printf("[%s]", ls.TypeName(t))
// }
// }
// fmt.Println()
// }