github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/source_test.go (about) 1 package main 2 3 import ( 4 "embed" 5 "testing" 6 7 "github.com/lmorg/murex/lang" 8 "github.com/lmorg/murex/lang/ref" 9 "github.com/lmorg/murex/test" 10 "github.com/lmorg/murex/test/count" 11 ) 12 13 //go:embed test/source* 14 var source embed.FS 15 16 func TestDiskSource(t *testing.T) { 17 count.Tests(t, 1) 18 19 file := "test/source.mx" 20 test.ExistsFs(t, file, source) 21 22 disk, err := diskSource(file) 23 if err != nil { 24 t.Error(err) 25 } 26 27 if len(disk) == 0 { 28 t.Error(err) 29 } 30 } 31 32 func TestDiskSourceGz(t *testing.T) { 33 count.Tests(t, 1) 34 35 file := "test/source.mx.gz" 36 test.ExistsFs(t, file, source) 37 38 disk, err := diskSource(file) 39 if err != nil { 40 t.Error(err) 41 } 42 43 if len(disk) == 0 { 44 t.Error(err) 45 } 46 } 47 48 func TestExecSource(t *testing.T) { 49 count.Tests(t, 1) 50 51 lang.InitEnv() 52 53 source := `out: "testing"` 54 srcRef := ref.History.AddSource("(builtin)", "source/builtin", []byte(source)) 55 execSource([]rune(source), srcRef, false) 56 }