2019-02-08 15:24:54 +03:00
|
|
|
package luaparser
|
|
|
|
|
|
|
|
import (
|
2019-02-08 18:02:24 +03:00
|
|
|
"fmt"
|
|
|
|
"testing"
|
2019-02-08 15:24:54 +03:00
|
|
|
)
|
|
|
|
|
2019-02-08 18:02:24 +03:00
|
|
|
func TestParse(t *testing.T) {
|
|
|
|
p := New()
|
|
|
|
m, err := p.ParseMap(`return {a=1, b=true, c="abc"}`)
|
2019-02-08 15:24:54 +03:00
|
|
|
|
2019-02-08 18:02:24 +03:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-02-08 15:24:54 +03:00
|
|
|
|
2019-02-08 18:02:24 +03:00
|
|
|
fmt.Println(m)
|
2019-02-08 15:24:54 +03:00
|
|
|
|
2019-02-08 18:02:24 +03:00
|
|
|
if m["a"].(int) != 1 {
|
|
|
|
t.Fatal("parsing error")
|
|
|
|
}
|
2019-02-08 15:24:54 +03:00
|
|
|
|
2019-02-08 18:02:24 +03:00
|
|
|
if !m["b"].(bool) {
|
|
|
|
t.Fatal("parsing error")
|
|
|
|
}
|
2019-02-08 15:24:54 +03:00
|
|
|
|
2019-02-08 18:02:24 +03:00
|
|
|
if m["c"].(string) != "abc" {
|
|
|
|
t.Fatal("parsing error")
|
|
|
|
}
|
2019-02-08 15:24:54 +03:00
|
|
|
|
|
|
|
}
|