github.com/hirochachacha/plua@v0.0.0-20170217012138-c82f520cc725/stdlib/table/table_test.go (about)

     1  package table_test
     2  
     3  import (
     4  	"path/filepath"
     5  	"testing"
     6  
     7  	"github.com/hirochachacha/plua/compiler"
     8  	"github.com/hirochachacha/plua/runtime"
     9  	"github.com/hirochachacha/plua/stdlib/base"
    10  	"github.com/hirochachacha/plua/stdlib/table"
    11  )
    12  
    13  func TestTable(t *testing.T) {
    14  	c := compiler.NewCompiler()
    15  
    16  	matches, err := filepath.Glob("testdata/*.lua")
    17  	if err != nil {
    18  		t.Fatal(err)
    19  	}
    20  
    21  	for _, fname := range matches {
    22  		proto, err := c.CompileFile(fname, 0)
    23  		if err != nil {
    24  			t.Fatal(err)
    25  		}
    26  
    27  		p := runtime.NewProcess()
    28  
    29  		p.Require("_G", base.Open)
    30  		p.Require("table", table.Open)
    31  
    32  		_, err = p.Exec(proto)
    33  		if err != nil {
    34  			t.Error(err)
    35  		}
    36  	}
    37  }