github.com/yunabe/lgo@v0.0.0-20190709125917-42c42d410fdf/parser/custom_test.go (about)

     1  package parser
     2  
     3  import (
     4  	"go/token"
     5  	"testing"
     6  )
     7  
     8  func parseLesserGoString(src string) (f *LGOBlock, err error) {
     9  	return ParseLesserGoFile(token.NewFileSet(), "", []byte(src), 0)
    10  }
    11  
    12  func TestParseLesserGoString(t *testing.T) {
    13  	_, err := parseLesserGoString(`
    14  	var x = 10
    15  
    16  	func f(i int) int {
    17  		return i
    18  	}
    19  
    20  	(func(){fmt.Println("hello")}())
    21  	`)
    22  	if err != nil {
    23  		t.Error(err)
    24  		return
    25  	}
    26  }