lang: Port TestAstFunc2 to txtar format

This ports TestAstFunc2 from our home-grown content storage system to
the txtar package. Since a single file can be used to represent the
entire folder hierarchy, this makes it much easier to see and edit
tests.
This commit is contained in:
James Shubin
2023-06-01 14:53:54 -04:00
parent 446dbde836
commit 8fffd10280
236 changed files with 727 additions and 502 deletions

View File

@@ -24,6 +24,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"sort"
"strings"
"testing"
@@ -47,6 +48,7 @@ import (
"github.com/kylelemons/godebug/pretty"
"github.com/spf13/afero"
"golang.org/x/tools/txtar"
)
const (
@@ -1049,34 +1051,11 @@ func TestAstFunc2(t *testing.T) {
Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix
}
type errs struct {
failLexParse bool
failInit bool
failInterpolate bool
failSetScope bool
failUnify bool
failGraph bool
failInterpret bool
failAutoEdge bool
}
type test struct { // an individual test
name string
path string // relative sub directory path inside tests dir
fail bool
//graph *pgraph.Graph
expstr string // expected output graph in string format
errs errs
path string // relative txtar path inside tests dir
}
testCases := []test{}
//{
// graph, _ := pgraph.NewGraph("g")
// testCases = append(testCases, test{
// name: "simple hello world",
// path: "hello0/",
// fail: false,
// expstr: graph.Sprint(),
// })
//}
// build test array automatically from reading the dir
files, err := ioutil.ReadDir(dir)
@@ -1086,108 +1065,22 @@ func TestAstFunc2(t *testing.T) {
}
sorted := []string{}
for _, f := range files {
if !f.IsDir() {
if f.IsDir() {
continue
}
if !strings.HasSuffix(f.Name(), ".txtar") {
continue
}
sorted = append(sorted, f.Name())
}
sort.Strings(sorted)
for _, f := range sorted {
graphFile := f + ".output" // expected output graph file
graphFileFull := dir + graphFile
info, err := os.Stat(graphFileFull)
if err != nil || info.IsDir() {
p := dir + f + "." + "T" + "O" + "D" + "O"
if _, err := os.Stat(p); err == nil {
// if it's a WIP, then don't error things
t.Logf("missing: %s", p)
continue
}
t.Errorf("missing: %s", graphFile)
t.Errorf("(err: %+v)", err)
continue
}
content, err := ioutil.ReadFile(graphFileFull)
if err != nil {
t.Errorf("could not read graph file: %+v", err)
return
}
str := string(content) // expected graph
// if the graph file has a magic error string, it's a failure
errStr := ""
failLexParse := false
failInit := false
failInterpolate := false
failSetScope := false
failUnify := false
failGraph := false
failInterpret := false
failAutoEdge := false
if strings.HasPrefix(str, magicError) {
errStr = strings.TrimPrefix(str, magicError)
str = errStr
if strings.HasPrefix(str, magicErrorLexParse) {
errStr = strings.TrimPrefix(str, magicErrorLexParse)
str = errStr
failLexParse = true
}
if strings.HasPrefix(str, magicErrorInit) {
errStr = strings.TrimPrefix(str, magicErrorInit)
str = errStr
failInit = true
}
if strings.HasPrefix(str, magicInterpolate) {
errStr = strings.TrimPrefix(str, magicInterpolate)
str = errStr
failInterpolate = true
}
if strings.HasPrefix(str, magicErrorSetScope) {
errStr = strings.TrimPrefix(str, magicErrorSetScope)
str = errStr
failSetScope = true
}
if strings.HasPrefix(str, magicErrorUnify) {
errStr = strings.TrimPrefix(str, magicErrorUnify)
str = errStr
failUnify = true
}
if strings.HasPrefix(str, magicErrorGraph) {
errStr = strings.TrimPrefix(str, magicErrorGraph)
str = errStr
failGraph = true
}
if strings.HasPrefix(str, magicErrorInterpret) {
errStr = strings.TrimPrefix(str, magicErrorInterpret)
str = errStr
failInterpret = true
}
if strings.HasPrefix(str, magicErrorAutoEdge) {
errStr = strings.TrimPrefix(str, magicErrorAutoEdge)
str = errStr
failAutoEdge = true
}
}
// add automatic test case
testCases = append(testCases, test{
name: fmt.Sprintf("dir: %s", f),
path: f + "/",
fail: errStr != "",
expstr: str,
errs: errs{
failLexParse: failLexParse,
failInit: failInit,
failInterpolate: failInterpolate,
failSetScope: failSetScope,
failUnify: failUnify,
failGraph: failGraph,
failInterpret: failInterpret,
failAutoEdge: failAutoEdge,
},
name: fmt.Sprintf("%s", f),
path: f, // <something>.txtar
})
//t.Logf("adding: %s", f + "/")
}
if testing.Short() {
@@ -1216,16 +1109,105 @@ func TestAstFunc2(t *testing.T) {
continue
}
t.Run(testName, func(t *testing.T) {
name, path, fail, expstr, errs := tc.name, tc.path, tc.fail, strings.Trim(tc.expstr, "\n"), tc.errs
src := dir + path // location of the test
failLexParse := errs.failLexParse
failInit := errs.failInit
failInterpolate := errs.failInterpolate
failSetScope := errs.failSetScope
failUnify := errs.failUnify
failGraph := errs.failGraph
failInterpret := errs.failInterpret
failAutoEdge := errs.failAutoEdge
name, path := tc.name, tc.path
tmpdir := t.TempDir() // gets cleaned up at end, new dir for each call
src := tmpdir // location of the test
txtarFile := dir + path
archive, err := txtar.ParseFile(txtarFile)
if err != nil {
t.Errorf("err parsing txtar(%s): %+v", txtarFile, err)
return
}
comment := strings.TrimSpace(string(archive.Comment))
t.Logf("comment: %s\n", comment)
// copy files out into the test temp directory
var testOutput []byte
found := false
for _, file := range archive.Files {
if file.Name == "OUTPUT" {
testOutput = file.Data
found = true
continue
}
name := filepath.Join(tmpdir, file.Name)
dir := filepath.Dir(name)
if err := os.MkdirAll(dir, 0770); err != nil {
t.Errorf("err making dir(%s): %+v", dir, err)
return
}
if err := ioutil.WriteFile(name, file.Data, 0660); err != nil {
t.Errorf("err writing file(%s): %+v", name, err)
return
}
}
if !found { // skip missing tests
return
}
expstr := string(testOutput) // expected graph
// if the graph file has a magic error string, it's a failure
errStr := ""
failLexParse := false
failInit := false
failInterpolate := false
failSetScope := false
failUnify := false
failGraph := false
failInterpret := false
failAutoEdge := false
if strings.HasPrefix(expstr, magicError) {
errStr = strings.TrimPrefix(expstr, magicError)
expstr = errStr
if strings.HasPrefix(expstr, magicErrorLexParse) {
errStr = strings.TrimPrefix(expstr, magicErrorLexParse)
expstr = errStr
failLexParse = true
}
if strings.HasPrefix(expstr, magicErrorInit) {
errStr = strings.TrimPrefix(expstr, magicErrorInit)
expstr = errStr
failInit = true
}
if strings.HasPrefix(expstr, magicInterpolate) {
errStr = strings.TrimPrefix(expstr, magicInterpolate)
expstr = errStr
failInterpolate = true
}
if strings.HasPrefix(expstr, magicErrorSetScope) {
errStr = strings.TrimPrefix(expstr, magicErrorSetScope)
expstr = errStr
failSetScope = true
}
if strings.HasPrefix(expstr, magicErrorUnify) {
errStr = strings.TrimPrefix(expstr, magicErrorUnify)
expstr = errStr
failUnify = true
}
if strings.HasPrefix(expstr, magicErrorGraph) {
errStr = strings.TrimPrefix(expstr, magicErrorGraph)
expstr = errStr
failGraph = true
}
if strings.HasPrefix(expstr, magicErrorInterpret) {
errStr = strings.TrimPrefix(expstr, magicErrorInterpret)
expstr = errStr
failInterpret = true
}
if strings.HasPrefix(expstr, magicErrorAutoEdge) {
errStr = strings.TrimPrefix(expstr, magicErrorAutoEdge)
expstr = errStr
failAutoEdge = true
}
}
fail := errStr != ""
expstr = strings.Trim(expstr, "\n")
t.Logf("\n\ntest #%d (%s) ----------------\npath: %s\n\n", index, name, src)

View File

@@ -1 +0,0 @@
Vertex: test[worldwide]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$some_bool = false
$fn = if $some_bool {
func($b) {
@@ -11,3 +12,5 @@ $fn = if $some_bool {
$out = $fn("wide")
test $out {}
-- OUTPUT --
Vertex: test[worldwide]

View File

@@ -1 +0,0 @@
Vertex: test[world]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$some_bool = false
$fn = if $some_bool {
func($b) {
@@ -11,3 +12,5 @@ $fn = if $some_bool {
$out = $fn(false)
test $out {}
-- OUTPUT --
Vertex: test[world]

View File

@@ -1 +0,0 @@
Vertex: test[hello]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
func funcgen() {
func() {
func() {
@@ -11,3 +12,5 @@ $fn2 = $fn1()
$out = $fn2()
test $out {}
-- OUTPUT --
Vertex: test[hello]

View File

@@ -1 +0,0 @@
Vertex: test[hello]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
# simple function definition containing function to be returned
$funcgen = func() {
func() {
@@ -15,3 +16,5 @@ $fn3 = $fn2()
$out = $fn3()
test $out {}
-- OUTPUT --
Vertex: test[hello]

View File

@@ -1,4 +0,0 @@
Vertex: test[hey]
Vertex: test[there]
Vertex: test[wow: hello]
Vertex: test[wow: world]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$funcgen = func() {
func($a) {
if $a {
@@ -36,3 +37,8 @@ test $out1() {} # hey
test $out2() {} # there
test $out3() {} # wow: hello
test $out4() {} # wow: world
-- OUTPUT --
Vertex: test[hey]
Vertex: test[there]
Vertex: test[wow: hello]
Vertex: test[wow: world]

View File

@@ -1,2 +0,0 @@
Vertex: test[hello]
Vertex: test[world]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
# this can return changing functions, and could be optimized, too
func funcgen($b) {
if $b {
@@ -19,3 +20,6 @@ $out2 = $fn2()
test $out1 {}
test $out2 {}
-- OUTPUT --
Vertex: test[hello]
Vertex: test[world]

View File

@@ -1,2 +0,0 @@
Vertex: test[hello]
Vertex: test[world]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
# this can return changing functions, and could be optimized, too
$funcgen = func($b) {
if $b {
@@ -19,3 +20,6 @@ $out2 = $fn2()
test $out1 {}
test $out2 {}
-- OUTPUT --
Vertex: test[hello]
Vertex: test[world]

View File

@@ -1,4 +0,0 @@
Vertex: test[true-true]
Vertex: test[true-false]
Vertex: test[false-true]
Vertex: test[false-false]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
# this can return changing functions, and could be optimized, too
$funcgen = func($a) {
if $a {
@@ -39,3 +40,8 @@ test $out1() {}
test $out2() {}
test $out3() {}
test $out4() {}
-- OUTPUT --
Vertex: test[true-true]
Vertex: test[true-false]
Vertex: test[false-true]
Vertex: test[false-false]

View File

@@ -1 +0,0 @@
Vertex: test[t1]

View File

@@ -1,5 +1,8 @@
include foo
-- main.mcl --
$x1 = "t1"
class foo {
test $x1 {}
}
$x1 = "t1"
include foo
-- OUTPUT --
Vertex: test[t1]

View File

@@ -1 +0,0 @@
Vertex: test[t1]

View File

@@ -1,5 +1,8 @@
$x1 = "t1"
-- main.mcl --
include foo
class foo {
test $x1 {}
}
include foo
$x1 = "t1"
-- OUTPUT --
Vertex: test[t1]

View File

@@ -1 +0,0 @@
Vertex: test[t1]

View File

@@ -1,5 +1,8 @@
-- main.mcl --
$x1 = "bad1"
class foo($x1) {
test $x1 {}
}
include foo("t1")
-- OUTPUT --
Vertex: test[t1]

View File

@@ -1,2 +0,0 @@
Vertex: test[t1]
Vertex: test[t2]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$x1 = "t1"
class foo {
test $x1 {}
@@ -5,3 +6,6 @@ class foo {
}
include foo
$x2 = "t2"
-- OUTPUT --
Vertex: test[t1]
Vertex: test[t2]

View File

@@ -1,2 +0,0 @@
Vertex: test[t1: t1]
Vertex: test[t2: t2]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$x1 = "bad1"
class foo($x1, $x2) {
test "t1: " + $x2 {} # swapped
@@ -5,3 +6,6 @@ class foo($x1, $x2) {
}
include foo($x2, "t1")
$x2 = "t2"
-- OUTPUT --
Vertex: test[t1: t1]
Vertex: test[t2: t2]

View File

@@ -1,3 +0,0 @@
Vertex: test[t0: t0]
Vertex: test[t1: t1]
Vertex: test[t2: t2]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$x1 = "bad1"
class foo($x1, $x2) {
include bar
@@ -10,3 +11,7 @@ class foo($x1, $x2) {
include foo("t1", $x2)
$x2 = "t2"
$x0 = "t0"
-- OUTPUT --
Vertex: test[t0: t0]
Vertex: test[t1: t1]
Vertex: test[t2: t2]

View File

@@ -1 +0,0 @@
# err: errSetScope: class `bar` does not exist in this scope

View File

@@ -1,3 +1,4 @@
-- main.mcl --
class foo {
test "t1" {}
class bar { # unused definition
@@ -7,3 +8,5 @@ class foo {
include foo
# This sort of thing is not currently supported, and not sure if it ever will.
include bar # nope!
-- OUTPUT --
# err: errSetScope: class `bar` does not exist in this scope

View File

@@ -1 +0,0 @@
Vertex: test[t1]

View File

@@ -0,0 +1,12 @@
-- main.mcl --
$x1 = "bad1"
include defs.foo
import "defs.mcl" # out of order for fun
-- defs.mcl --
class foo {
test $x1 {} # capture the var
}
$x1 = "t1"
-- OUTPUT --
Vertex: test[t1]

View File

@@ -1,4 +0,0 @@
class foo {
test $x1 {} # capture the var
}
$x1 = "t1"

View File

@@ -1,4 +0,0 @@
$x1 = "bad1"
include defs.foo
import "defs.mcl" # out of order for fun

View File

@@ -1 +0,0 @@
# err: errSetScope: recursive reference while setting scope: not a dag

View File

@@ -0,0 +1,9 @@
-- main.mcl --
class c1 {
include c2
}
class c2 {
include c1
}
-- OUTPUT --
# err: errSetScope: recursive reference while setting scope: not a dag

View File

@@ -1,6 +0,0 @@
class c1 {
include c2
}
class c2 {
include c1
}

View File

@@ -1 +0,0 @@
# err: errSetScope: recursive reference while setting scope: not a dag

View File

@@ -1,3 +1,4 @@
-- main.mcl --
class c1($cond) {
test "nope" {}
if $cond {
@@ -7,3 +8,5 @@ class c1($cond) {
}
}
include c1(true)
-- OUTPUT --
# err: errSetScope: recursive reference while setting scope: not a dag

View File

@@ -1 +0,0 @@
Vertex: test[d]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$msg = "a"
class shadowme($msg) {
$msg = "c"
@@ -8,3 +9,5 @@ class shadowme($msg) {
}
include shadowme("b")
-- OUTPUT --
Vertex: test[d]

View File

@@ -1 +0,0 @@
Vertex: test[c]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$msg = "a"
class shadowme($msg) {
$msg = "c"
@@ -8,3 +9,5 @@ class shadowme($msg) {
}
include shadowme("b")
-- OUTPUT --
Vertex: test[c]

View File

@@ -1,2 +0,0 @@
Vertex: test[a]
Vertex: test[hello]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$foo = "a"
class c1($cond) {
@@ -15,3 +16,6 @@ include c1(true)
# but little value.
test $foo {}
-- OUTPUT --
Vertex: test[a]
Vertex: test[hello]

View File

@@ -1,3 +0,0 @@
Vertex: test[hello purpleidea]
Vertex: test[hello user]
Vertex: test[who is there?]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$funcgen = func() {
func($b) {
"hello" + " " + "world"
@@ -28,3 +29,7 @@ $out3 = $fn("")
test $out1 {}
test $out2 {}
test $out3 {}
-- OUTPUT --
Vertex: test[hello purpleidea]
Vertex: test[hello user]
Vertex: test[who is there?]

View File

@@ -1,2 +0,0 @@
Vertex: test[so true]
Vertex: test[so false]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
# out of order
$out1 = $fn(true)
$some_bool = false
@@ -25,3 +26,6 @@ $funcgen = func() {
test $out1 {}
test $out2 {}
-- OUTPUT --
Vertex: test[so true]
Vertex: test[so false]

View File

@@ -1,2 +0,0 @@
Vertex: test[so true]
Vertex: test[so false]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$funcgen = func() {
func($b) {
if $b {
@@ -25,3 +26,6 @@ $out2 = $fn(false)
test $out1 {}
test $out2 {}
-- OUTPUT --
Vertex: test[so true]
Vertex: test[so false]

View File

@@ -1 +0,0 @@
Vertex: test[exists]

View File

@@ -1,2 +1,5 @@
-- main.mcl --
# this magic string variable should exist and be "exists"
test $const.res.file.state.exists {}
-- OUTPUT --
Vertex: test[exists]

View File

@@ -1,4 +0,0 @@
Vertex: test[passed1]
Vertex: test[passed2]
Vertex: test[passed3]
Vertex: test[passed4]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$ints = [13, 42, 0, -37,]
$s1 = if contains(42, $ints) {
@@ -35,3 +36,8 @@ test $s1 {} # passed
test $s2 {} # passed
test $s3 {} # passed
test $s4 {} # passed
-- OUTPUT --
Vertex: test[passed1]
Vertex: test[passed2]
Vertex: test[passed3]
Vertex: test[passed4]

View File

@@ -1,3 +0,0 @@
Vertex: test[This is file1 in the files/ folder.]
Vertex: test[This is file2 in the files/ folder.]
Vertex: test[This is file3 in the files/ folder inside of the mod1/ module.]

View File

@@ -1,3 +1,6 @@
-- metadata.yaml --
#files: "files/" # these are some extra files we can use (is the default)
-- main.mcl --
import "golang/strings"
import "deploy"
import "second.mcl"
@@ -51,3 +54,29 @@ test strings.trim_space($x3) {}
#test "f3" {
# anotherstr => $x3,
#}
-- second.mcl --
import "deploy"
# relative paths for us
$f = "/files/file2" # real file is here as well
$f2 = deploy.abspath($f)
$x2 = deploy.readfile($f)
-- files/file1 --
This is file1 in the files/ folder.
-- files/file2 --
This is file2 in the files/ folder.
-- mod1/metadata.yaml --
#files: "files/" # these are some extra files we can use (is the default)
-- mod1/main.mcl --
import "deploy"
# relative paths for us
$f = "/files/file3" # real file is in: /mod1/files/file3
$f3 = deploy.abspath($f)
$x3 = deploy.readfile($f)
-- mod1/files/file3 --
This is file3 in the files/ folder inside of the mod1/ module.
-- OUTPUT --
Vertex: test[This is file1 in the files/ folder.]
Vertex: test[This is file2 in the files/ folder.]
Vertex: test[This is file3 in the files/ folder inside of the mod1/ module.]

View File

@@ -1 +0,0 @@
This is file1 in the files/ folder.

View File

@@ -1 +0,0 @@
This is file2 in the files/ folder.

View File

@@ -1 +0,0 @@
#files: "files/" # these are some extra files we can use (is the default)

View File

@@ -1 +0,0 @@
This is file3 in the files/ folder inside of the mod1/ module.

View File

@@ -1,6 +0,0 @@
import "deploy"
# relative paths for us
$f = "/files/file3" # real file is in: /mod1/files/file3
$f3 = deploy.abspath($f)
$x3 = deploy.readfile($f)

View File

@@ -1 +0,0 @@
#files: "files/" # these are some extra files we can use (is the default)

View File

@@ -1,6 +0,0 @@
import "deploy"
# relative paths for us
$f = "/files/file2" # real file is here as well
$f2 = deploy.abspath($f)
$x2 = deploy.readfile($f)

View File

@@ -1,3 +0,0 @@
Vertex: test[This is a different file1 in the files/ folder.]
Vertex: test[This is a different file2 in the files/ folder.]
Vertex: test[This is a different file3 in the files/ folder inside of the mod1/ module.]

View File

@@ -1,3 +1,6 @@
-- metadata.yaml --
#files: "files/" # these are some extra files we can use (is the default)
-- main.mcl --
import "golang/strings"
import "deploy"
import "second.mcl"
@@ -51,3 +54,29 @@ test strings.trim_space($x3) {}
#test "f3" {
# anotherstr => $x3,
#}
-- second.mcl --
import "deploy"
# relative paths for us
$f = "/files/file2" # real file is here as well
$f2 = deploy.abspath($f)
$x2 = deploy.readfile($f)
-- files/file1 --
This is a different file1 in the files/ folder.
-- files/file2 --
This is a different file2 in the files/ folder.
-- mod1/metadata.yaml --
#files: "files/" # these are some extra files we can use (is the default)
-- mod1/main.mcl --
import "deploy"
# relative paths for us
$f = "/files/file3" # real file is in: /mod1/files/file3
$f3 = deploy.abspath($f)
$x3 = deploy.readfile($f)
-- mod1/files/file3 --
This is a different file3 in the files/ folder inside of the mod1/ module.
-- OUTPUT --
Vertex: test[This is a different file1 in the files/ folder.]
Vertex: test[This is a different file2 in the files/ folder.]
Vertex: test[This is a different file3 in the files/ folder inside of the mod1/ module.]

View File

@@ -1 +0,0 @@
This is a different file1 in the files/ folder.

View File

@@ -1 +0,0 @@
This is a different file2 in the files/ folder.

View File

@@ -1 +0,0 @@
#files: "files/" # these are some extra files we can use (is the default)

View File

@@ -1 +0,0 @@
This is a different file3 in the files/ folder inside of the mod1/ module.

View File

@@ -1,6 +0,0 @@
import "deploy"
# relative paths for us
$f = "/files/file3" # real file is in: /mod1/files/file3
$f3 = deploy.abspath($f)
$x3 = deploy.readfile($f)

View File

@@ -1 +0,0 @@
#files: "files/" # these are some extra files we can use (is the default)

View File

@@ -1,6 +0,0 @@
import "deploy"
# relative paths for us
$f = "/files/file2" # real file is here as well
$f2 = deploy.abspath($f)
$x2 = deploy.readfile($f)

View File

@@ -1,2 +0,0 @@
Vertex: test[hello:a]
Vertex: test[hello:b]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
$prefix = "hello"
func prefixer($x) {
@@ -9,3 +10,6 @@ $out2 = prefixer("b")
test $out1 {} # hello:a
test $out2 {} # hello:b
-- OUTPUT --
Vertex: test[hello:a]
Vertex: test[hello:b]

View File

@@ -1,2 +0,0 @@
Vertex: test[helloa]
Vertex: test[hellob]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
# this should be a function as a value, iow a lambda
$prefixer = func($x) {
"hello" + $x # i'd only ever expect one "hello" string in the graph
@@ -8,3 +9,6 @@ $out2 = $prefixer("b")
test $out1 {} # helloa
test $out2 {} # hellob
-- OUTPUT --
Vertex: test[helloa]
Vertex: test[hellob]

View File

@@ -1,3 +1,23 @@
-- main.mcl --
# this must pass type unification and generate output
# single resource
test "name" {}
# single resource, defined by list variable
$names = ["hey", "there",]
test $names {}
# multiples resources, defined by list
test ["hello", "world",] {
Depend => Test[$names],
}
$morenames = ["wow", "cool", "amazing",]
test $morenames {}
Test[$names] -> Test[$morenames]
-- OUTPUT --
Edge: test[hey] -> test[amazing] # test[hey] -> test[amazing]
Edge: test[hey] -> test[cool] # test[hey] -> test[cool]
Edge: test[hey] -> test[hello] # test[hey] -> test[hello]

View File

@@ -1,18 +0,0 @@
# this must pass type unification and generate output
# single resource
test "name" {}
# single resource, defined by list variable
$names = ["hey", "there",]
test $names {}
# multiples resources, defined by list
test ["hello", "world",] {
Depend => Test[$names],
}
$morenames = ["wow", "cool", "amazing",]
test $morenames {}
Test[$names] -> Test[$morenames]

View File

@@ -1 +0,0 @@
Vertex: test[name]

View File

@@ -1,5 +1,8 @@
-- main.mcl --
# make sure the engine works with empty values
test "name" {
slicestring => [], # empty list
mapintfloat => {}, # empty map
}
-- OUTPUT --
Vertex: test[name]

View File

@@ -1 +0,0 @@
Vertex: test[x: This is x]

View File

@@ -0,0 +1,6 @@
-- main.mcl --
# escaping example
$x = "This is x"
test "x: ${x}" {}
-- OUTPUT --
Vertex: test[x: This is x]

View File

@@ -1,3 +0,0 @@
# escaping example
$x = "This is x"
test "x: ${x}" {}

View File

@@ -1,26 +0,0 @@
Vertex: test[A: ${test}]
Vertex: test[B: $]
Vertex: test[C: This is c1]
Vertex: test[D: \$]
Vertex: test[E: {}]
Vertex: test[F: hello]
Vertex: test[G: This is g1 EOF]
Vertex: test[H: {hhh} EOF]
Vertex: test[I: This is ii EOF]
Vertex: test[J: $ is a dollar sign]
Vertex: test[K: $ {zzz} EOF]
Vertex: test[L: $$This is l1 EOF]
Vertex: test[M: $ $$]
Vertex: test[N: hello " world]
Vertex: test[O: hello "" world]
Vertex: test[P: hello \ world]
Vertex: test[Q: hello \\ world]
Vertex: test[R: \This is r1 EOF]
Vertex: test[S: \$ EOF]
Vertex: test[T: newline
EOF]
Vertex: test[U: tab \ tabEOF]
Vertex: test[W: \$]
Vertex: test[X: $This is x1 EOF]
Vertex: test[Y: ${unused} EOF]
Vertex: test[Z: $$$]

View File

@@ -1,3 +1,4 @@
-- main.mcl --
# escaping examples
test "A: \${test}" {}
@@ -60,3 +61,30 @@ $y1 = "{unused}"
test "Y: $${y1} EOF" {} # check there isn't double parsing
test "Z: $$$" {}
-- OUTPUT --
Vertex: test[A: ${test}]
Vertex: test[B: $]
Vertex: test[C: This is c1]
Vertex: test[D: \$]
Vertex: test[E: {}]
Vertex: test[F: hello]
Vertex: test[G: This is g1 EOF]
Vertex: test[H: {hhh} EOF]
Vertex: test[I: This is ii EOF]
Vertex: test[J: $ is a dollar sign]
Vertex: test[K: $ {zzz} EOF]
Vertex: test[L: $$This is l1 EOF]
Vertex: test[M: $ $$]
Vertex: test[N: hello " world]
Vertex: test[O: hello "" world]
Vertex: test[P: hello \ world]
Vertex: test[Q: hello \\ world]
Vertex: test[R: \This is r1 EOF]
Vertex: test[S: \$ EOF]
Vertex: test[T: newline
EOF]
Vertex: test[U: tab \ tabEOF]
Vertex: test[W: \$]
Vertex: test[X: $This is x1 EOF]
Vertex: test[Y: ${unused} EOF]
Vertex: test[Z: $$$]

View File

@@ -1 +0,0 @@
# err: errInterpolate: parser failed: cannot parse string: X: ${foo()}

View File

@@ -0,0 +1,5 @@
-- main.mcl --
# this is invalid (you can't have a function inside a var lookup)
test "X: ${foo()}" {}
-- OUTPUT --
# err: errInterpolate: parser failed: cannot parse string: X: ${foo()}

View File

@@ -1,2 +0,0 @@
# this is invalid (you can't have a function inside a var lookup)
test "X: ${foo()}" {}

View File

@@ -1 +0,0 @@
# err: errInterpolate: parser failed: cannot parse string: X: ${}

View File

@@ -0,0 +1,5 @@
-- main.mcl --
# this is invalid (you can't have an empty var lookup)
test "X: ${}" {}
-- OUTPUT --
# err: errInterpolate: parser failed: cannot parse string: X: ${}

View File

@@ -1,2 +0,0 @@
# this is invalid (you can't have an empty var lookup)
test "X: ${}" {}

View File

@@ -1 +0,0 @@
# err: errInterpolate: parser failed: unknown escape sequence: \z

View File

@@ -0,0 +1,5 @@
-- main.mcl --
# this is invalid (you can't escape a z, right?)
test "X: \z" {}
-- OUTPUT --
# err: errInterpolate: parser failed: unknown escape sequence: \z

View File

@@ -1,2 +0,0 @@
# this is invalid (you can't escape a z, right?)
test "X: \z" {}

View File

@@ -1 +0,0 @@
# err: errInterpolate: parser failed: unknown escape sequence: \j

View File

@@ -0,0 +1,5 @@
-- main.mcl --
# this is invalid (there's no \j escape sequence)
test "X: there is no \j sequence" {}
-- OUTPUT --
# err: errInterpolate: parser failed: unknown escape sequence: \j

View File

@@ -1,2 +0,0 @@
# this is invalid (there's no \j escape sequence)
test "X: there is no \j sequence" {}

View File

@@ -0,0 +1,12 @@
some comment can go here!
-- main.mcl --
import "fmt"
test fmt.printf("answer: %d", 42) {}
-- files/file1 --
this is file1
-- files/file2 --
this is file2
-- OUTPUT --
Vertex: test[answer: 42]

Some files were not shown because too many files have changed in this diff Show More