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:
@@ -24,6 +24,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -47,6 +48,7 @@ import (
|
|||||||
|
|
||||||
"github.com/kylelemons/godebug/pretty"
|
"github.com/kylelemons/godebug/pretty"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
|
"golang.org/x/tools/txtar"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -1049,34 +1051,11 @@ func TestAstFunc2(t *testing.T) {
|
|||||||
Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix
|
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
|
type test struct { // an individual test
|
||||||
name string
|
name string
|
||||||
path string // relative sub directory path inside tests dir
|
path string // relative txtar path inside tests dir
|
||||||
fail bool
|
|
||||||
//graph *pgraph.Graph
|
|
||||||
expstr string // expected output graph in string format
|
|
||||||
errs errs
|
|
||||||
}
|
}
|
||||||
testCases := []test{}
|
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
|
// build test array automatically from reading the dir
|
||||||
files, err := ioutil.ReadDir(dir)
|
files, err := ioutil.ReadDir(dir)
|
||||||
@@ -1086,108 +1065,22 @@ func TestAstFunc2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
sorted := []string{}
|
sorted := []string{}
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
if !f.IsDir() {
|
if f.IsDir() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if !strings.HasSuffix(f.Name(), ".txtar") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
sorted = append(sorted, f.Name())
|
sorted = append(sorted, f.Name())
|
||||||
}
|
}
|
||||||
sort.Strings(sorted)
|
sort.Strings(sorted)
|
||||||
for _, f := range 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
|
// add automatic test case
|
||||||
testCases = append(testCases, test{
|
testCases = append(testCases, test{
|
||||||
name: fmt.Sprintf("dir: %s", f),
|
name: fmt.Sprintf("%s", f),
|
||||||
path: f + "/",
|
path: f, // <something>.txtar
|
||||||
fail: errStr != "",
|
|
||||||
expstr: str,
|
|
||||||
errs: errs{
|
|
||||||
failLexParse: failLexParse,
|
|
||||||
failInit: failInit,
|
|
||||||
failInterpolate: failInterpolate,
|
|
||||||
failSetScope: failSetScope,
|
|
||||||
failUnify: failUnify,
|
|
||||||
failGraph: failGraph,
|
|
||||||
failInterpret: failInterpret,
|
|
||||||
failAutoEdge: failAutoEdge,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
//t.Logf("adding: %s", f + "/")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
@@ -1216,16 +1109,105 @@ func TestAstFunc2(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
t.Run(testName, func(t *testing.T) {
|
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
|
name, path := tc.name, tc.path
|
||||||
src := dir + path // location of the test
|
tmpdir := t.TempDir() // gets cleaned up at end, new dir for each call
|
||||||
failLexParse := errs.failLexParse
|
src := tmpdir // location of the test
|
||||||
failInit := errs.failInit
|
txtarFile := dir + path
|
||||||
failInterpolate := errs.failInterpolate
|
|
||||||
failSetScope := errs.failSetScope
|
archive, err := txtar.ParseFile(txtarFile)
|
||||||
failUnify := errs.failUnify
|
if err != nil {
|
||||||
failGraph := errs.failGraph
|
t.Errorf("err parsing txtar(%s): %+v", txtarFile, err)
|
||||||
failInterpret := errs.failInterpret
|
return
|
||||||
failAutoEdge := errs.failAutoEdge
|
}
|
||||||
|
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)
|
t.Logf("\n\ntest #%d (%s) ----------------\npath: %s\n\n", index, name, src)
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[worldwide]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$some_bool = false
|
$some_bool = false
|
||||||
$fn = if $some_bool {
|
$fn = if $some_bool {
|
||||||
func($b) {
|
func($b) {
|
||||||
@@ -11,3 +12,5 @@ $fn = if $some_bool {
|
|||||||
|
|
||||||
$out = $fn("wide")
|
$out = $fn("wide")
|
||||||
test $out {}
|
test $out {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[worldwide]
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[world]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$some_bool = false
|
$some_bool = false
|
||||||
$fn = if $some_bool {
|
$fn = if $some_bool {
|
||||||
func($b) {
|
func($b) {
|
||||||
@@ -11,3 +12,5 @@ $fn = if $some_bool {
|
|||||||
|
|
||||||
$out = $fn(false)
|
$out = $fn(false)
|
||||||
test $out {}
|
test $out {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[world]
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[hello]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
func funcgen() {
|
func funcgen() {
|
||||||
func() {
|
func() {
|
||||||
func() {
|
func() {
|
||||||
@@ -11,3 +12,5 @@ $fn2 = $fn1()
|
|||||||
$out = $fn2()
|
$out = $fn2()
|
||||||
|
|
||||||
test $out {}
|
test $out {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hello]
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[hello]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
# simple function definition containing function to be returned
|
# simple function definition containing function to be returned
|
||||||
$funcgen = func() {
|
$funcgen = func() {
|
||||||
func() {
|
func() {
|
||||||
@@ -15,3 +16,5 @@ $fn3 = $fn2()
|
|||||||
$out = $fn3()
|
$out = $fn3()
|
||||||
|
|
||||||
test $out {}
|
test $out {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hello]
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
Vertex: test[hey]
|
|
||||||
Vertex: test[there]
|
|
||||||
Vertex: test[wow: hello]
|
|
||||||
Vertex: test[wow: world]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$funcgen = func() {
|
$funcgen = func() {
|
||||||
func($a) {
|
func($a) {
|
||||||
if $a {
|
if $a {
|
||||||
@@ -36,3 +37,8 @@ test $out1() {} # hey
|
|||||||
test $out2() {} # there
|
test $out2() {} # there
|
||||||
test $out3() {} # wow: hello
|
test $out3() {} # wow: hello
|
||||||
test $out4() {} # wow: world
|
test $out4() {} # wow: world
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hey]
|
||||||
|
Vertex: test[there]
|
||||||
|
Vertex: test[wow: hello]
|
||||||
|
Vertex: test[wow: world]
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Vertex: test[hello]
|
|
||||||
Vertex: test[world]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
# this can return changing functions, and could be optimized, too
|
# this can return changing functions, and could be optimized, too
|
||||||
func funcgen($b) {
|
func funcgen($b) {
|
||||||
if $b {
|
if $b {
|
||||||
@@ -19,3 +20,6 @@ $out2 = $fn2()
|
|||||||
|
|
||||||
test $out1 {}
|
test $out1 {}
|
||||||
test $out2 {}
|
test $out2 {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hello]
|
||||||
|
Vertex: test[world]
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Vertex: test[hello]
|
|
||||||
Vertex: test[world]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
# this can return changing functions, and could be optimized, too
|
# this can return changing functions, and could be optimized, too
|
||||||
$funcgen = func($b) {
|
$funcgen = func($b) {
|
||||||
if $b {
|
if $b {
|
||||||
@@ -19,3 +20,6 @@ $out2 = $fn2()
|
|||||||
|
|
||||||
test $out1 {}
|
test $out1 {}
|
||||||
test $out2 {}
|
test $out2 {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hello]
|
||||||
|
Vertex: test[world]
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
Vertex: test[true-true]
|
|
||||||
Vertex: test[true-false]
|
|
||||||
Vertex: test[false-true]
|
|
||||||
Vertex: test[false-false]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
# this can return changing functions, and could be optimized, too
|
# this can return changing functions, and could be optimized, too
|
||||||
$funcgen = func($a) {
|
$funcgen = func($a) {
|
||||||
if $a {
|
if $a {
|
||||||
@@ -39,3 +40,8 @@ test $out1() {}
|
|||||||
test $out2() {}
|
test $out2() {}
|
||||||
test $out3() {}
|
test $out3() {}
|
||||||
test $out4() {}
|
test $out4() {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[true-true]
|
||||||
|
Vertex: test[true-false]
|
||||||
|
Vertex: test[false-true]
|
||||||
|
Vertex: test[false-false]
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[t1]
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
include foo
|
-- main.mcl --
|
||||||
|
$x1 = "t1"
|
||||||
class foo {
|
class foo {
|
||||||
test $x1 {}
|
test $x1 {}
|
||||||
}
|
}
|
||||||
$x1 = "t1"
|
include foo
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[t1]
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[t1]
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
$x1 = "t1"
|
-- main.mcl --
|
||||||
|
include foo
|
||||||
class foo {
|
class foo {
|
||||||
test $x1 {}
|
test $x1 {}
|
||||||
}
|
}
|
||||||
include foo
|
$x1 = "t1"
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[t1]
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[t1]
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
|
-- main.mcl --
|
||||||
$x1 = "bad1"
|
$x1 = "bad1"
|
||||||
class foo($x1) {
|
class foo($x1) {
|
||||||
test $x1 {}
|
test $x1 {}
|
||||||
}
|
}
|
||||||
include foo("t1")
|
include foo("t1")
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[t1]
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Vertex: test[t1]
|
|
||||||
Vertex: test[t2]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$x1 = "t1"
|
$x1 = "t1"
|
||||||
class foo {
|
class foo {
|
||||||
test $x1 {}
|
test $x1 {}
|
||||||
@@ -5,3 +6,6 @@ class foo {
|
|||||||
}
|
}
|
||||||
include foo
|
include foo
|
||||||
$x2 = "t2"
|
$x2 = "t2"
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[t1]
|
||||||
|
Vertex: test[t2]
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Vertex: test[t1: t1]
|
|
||||||
Vertex: test[t2: t2]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$x1 = "bad1"
|
$x1 = "bad1"
|
||||||
class foo($x1, $x2) {
|
class foo($x1, $x2) {
|
||||||
test "t1: " + $x2 {} # swapped
|
test "t1: " + $x2 {} # swapped
|
||||||
@@ -5,3 +6,6 @@ class foo($x1, $x2) {
|
|||||||
}
|
}
|
||||||
include foo($x2, "t1")
|
include foo($x2, "t1")
|
||||||
$x2 = "t2"
|
$x2 = "t2"
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[t1: t1]
|
||||||
|
Vertex: test[t2: t2]
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
Vertex: test[t0: t0]
|
|
||||||
Vertex: test[t1: t1]
|
|
||||||
Vertex: test[t2: t2]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$x1 = "bad1"
|
$x1 = "bad1"
|
||||||
class foo($x1, $x2) {
|
class foo($x1, $x2) {
|
||||||
include bar
|
include bar
|
||||||
@@ -10,3 +11,7 @@ class foo($x1, $x2) {
|
|||||||
include foo("t1", $x2)
|
include foo("t1", $x2)
|
||||||
$x2 = "t2"
|
$x2 = "t2"
|
||||||
$x0 = "t0"
|
$x0 = "t0"
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[t0: t0]
|
||||||
|
Vertex: test[t1: t1]
|
||||||
|
Vertex: test[t2: t2]
|
||||||
@@ -1 +0,0 @@
|
|||||||
# err: errSetScope: class `bar` does not exist in this scope
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
class foo {
|
class foo {
|
||||||
test "t1" {}
|
test "t1" {}
|
||||||
class bar { # unused definition
|
class bar { # unused definition
|
||||||
@@ -7,3 +8,5 @@ class foo {
|
|||||||
include foo
|
include foo
|
||||||
# This sort of thing is not currently supported, and not sure if it ever will.
|
# This sort of thing is not currently supported, and not sure if it ever will.
|
||||||
include bar # nope!
|
include bar # nope!
|
||||||
|
-- OUTPUT --
|
||||||
|
# err: errSetScope: class `bar` does not exist in this scope
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[t1]
|
|
||||||
12
lang/interpret_test/TestAstFunc2/class-capture8.txtar
Normal file
12
lang/interpret_test/TestAstFunc2/class-capture8.txtar
Normal 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]
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
class foo {
|
|
||||||
test $x1 {} # capture the var
|
|
||||||
}
|
|
||||||
$x1 = "t1"
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
$x1 = "bad1"
|
|
||||||
include defs.foo
|
|
||||||
|
|
||||||
import "defs.mcl" # out of order for fun
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# err: errSetScope: recursive reference while setting scope: not a dag
|
|
||||||
9
lang/interpret_test/TestAstFunc2/class-recursion1.txtar
Normal file
9
lang/interpret_test/TestAstFunc2/class-recursion1.txtar
Normal 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
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
class c1 {
|
|
||||||
include c2
|
|
||||||
}
|
|
||||||
class c2 {
|
|
||||||
include c1
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# err: errSetScope: recursive reference while setting scope: not a dag
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
class c1($cond) {
|
class c1($cond) {
|
||||||
test "nope" {}
|
test "nope" {}
|
||||||
if $cond {
|
if $cond {
|
||||||
@@ -7,3 +8,5 @@ class c1($cond) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
include c1(true)
|
include c1(true)
|
||||||
|
-- OUTPUT --
|
||||||
|
# err: errSetScope: recursive reference while setting scope: not a dag
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[d]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$msg = "a"
|
$msg = "a"
|
||||||
class shadowme($msg) {
|
class shadowme($msg) {
|
||||||
$msg = "c"
|
$msg = "c"
|
||||||
@@ -8,3 +9,5 @@ class shadowme($msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
include shadowme("b")
|
include shadowme("b")
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[d]
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[c]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$msg = "a"
|
$msg = "a"
|
||||||
class shadowme($msg) {
|
class shadowme($msg) {
|
||||||
$msg = "c"
|
$msg = "c"
|
||||||
@@ -8,3 +9,5 @@ class shadowme($msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
include shadowme("b")
|
include shadowme("b")
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[c]
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Vertex: test[a]
|
|
||||||
Vertex: test[hello]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$foo = "a"
|
$foo = "a"
|
||||||
|
|
||||||
class c1($cond) {
|
class c1($cond) {
|
||||||
@@ -15,3 +16,6 @@ include c1(true)
|
|||||||
# but little value.
|
# but little value.
|
||||||
|
|
||||||
test $foo {}
|
test $foo {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[a]
|
||||||
|
Vertex: test[hello]
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
Vertex: test[hello purpleidea]
|
|
||||||
Vertex: test[hello user]
|
|
||||||
Vertex: test[who is there?]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$funcgen = func() {
|
$funcgen = func() {
|
||||||
func($b) {
|
func($b) {
|
||||||
"hello" + " " + "world"
|
"hello" + " " + "world"
|
||||||
@@ -28,3 +29,7 @@ $out3 = $fn("")
|
|||||||
test $out1 {}
|
test $out1 {}
|
||||||
test $out2 {}
|
test $out2 {}
|
||||||
test $out3 {}
|
test $out3 {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hello purpleidea]
|
||||||
|
Vertex: test[hello user]
|
||||||
|
Vertex: test[who is there?]
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Vertex: test[so true]
|
|
||||||
Vertex: test[so false]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
# out of order
|
# out of order
|
||||||
$out1 = $fn(true)
|
$out1 = $fn(true)
|
||||||
$some_bool = false
|
$some_bool = false
|
||||||
@@ -25,3 +26,6 @@ $funcgen = func() {
|
|||||||
|
|
||||||
test $out1 {}
|
test $out1 {}
|
||||||
test $out2 {}
|
test $out2 {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[so true]
|
||||||
|
Vertex: test[so false]
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Vertex: test[so true]
|
|
||||||
Vertex: test[so false]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$funcgen = func() {
|
$funcgen = func() {
|
||||||
func($b) {
|
func($b) {
|
||||||
if $b {
|
if $b {
|
||||||
@@ -25,3 +26,6 @@ $out2 = $fn(false)
|
|||||||
|
|
||||||
test $out1 {}
|
test $out1 {}
|
||||||
test $out2 {}
|
test $out2 {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[so true]
|
||||||
|
Vertex: test[so false]
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[exists]
|
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
|
-- main.mcl --
|
||||||
# this magic string variable should exist and be "exists"
|
# this magic string variable should exist and be "exists"
|
||||||
test $const.res.file.state.exists {}
|
test $const.res.file.state.exists {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[exists]
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
Vertex: test[passed1]
|
|
||||||
Vertex: test[passed2]
|
|
||||||
Vertex: test[passed3]
|
|
||||||
Vertex: test[passed4]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$ints = [13, 42, 0, -37,]
|
$ints = [13, 42, 0, -37,]
|
||||||
|
|
||||||
$s1 = if contains(42, $ints) {
|
$s1 = if contains(42, $ints) {
|
||||||
@@ -35,3 +36,8 @@ test $s1 {} # passed
|
|||||||
test $s2 {} # passed
|
test $s2 {} # passed
|
||||||
test $s3 {} # passed
|
test $s3 {} # passed
|
||||||
test $s4 {} # passed
|
test $s4 {} # passed
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[passed1]
|
||||||
|
Vertex: test[passed2]
|
||||||
|
Vertex: test[passed3]
|
||||||
|
Vertex: test[passed4]
|
||||||
@@ -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.]
|
|
||||||
@@ -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 "golang/strings"
|
||||||
import "deploy"
|
import "deploy"
|
||||||
import "second.mcl"
|
import "second.mcl"
|
||||||
@@ -51,3 +54,29 @@ test strings.trim_space($x3) {}
|
|||||||
#test "f3" {
|
#test "f3" {
|
||||||
# anotherstr => $x3,
|
# 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.]
|
||||||
@@ -1 +0,0 @@
|
|||||||
This is file1 in the files/ folder.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
This is file2 in the files/ folder.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
#files: "files/" # these are some extra files we can use (is the default)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
This is file3 in the files/ folder inside of the mod1/ module.
|
|
||||||
@@ -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)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
#files: "files/" # these are some extra files we can use (is the default)
|
|
||||||
@@ -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)
|
|
||||||
@@ -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.]
|
|
||||||
@@ -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 "golang/strings"
|
||||||
import "deploy"
|
import "deploy"
|
||||||
import "second.mcl"
|
import "second.mcl"
|
||||||
@@ -51,3 +54,29 @@ test strings.trim_space($x3) {}
|
|||||||
#test "f3" {
|
#test "f3" {
|
||||||
# anotherstr => $x3,
|
# 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.]
|
||||||
@@ -1 +0,0 @@
|
|||||||
This is a different file1 in the files/ folder.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
This is a different file2 in the files/ folder.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
#files: "files/" # these are some extra files we can use (is the default)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
This is a different file3 in the files/ folder inside of the mod1/ module.
|
|
||||||
@@ -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)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
#files: "files/" # these are some extra files we can use (is the default)
|
|
||||||
@@ -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)
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Vertex: test[hello:a]
|
|
||||||
Vertex: test[hello:b]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
$prefix = "hello"
|
$prefix = "hello"
|
||||||
|
|
||||||
func prefixer($x) {
|
func prefixer($x) {
|
||||||
@@ -9,3 +10,6 @@ $out2 = prefixer("b")
|
|||||||
|
|
||||||
test $out1 {} # hello:a
|
test $out1 {} # hello:a
|
||||||
test $out2 {} # hello:b
|
test $out2 {} # hello:b
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hello:a]
|
||||||
|
Vertex: test[hello:b]
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Vertex: test[helloa]
|
|
||||||
Vertex: test[hellob]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
# this should be a function as a value, iow a lambda
|
# this should be a function as a value, iow a lambda
|
||||||
$prefixer = func($x) {
|
$prefixer = func($x) {
|
||||||
"hello" + $x # i'd only ever expect one "hello" string in the graph
|
"hello" + $x # i'd only ever expect one "hello" string in the graph
|
||||||
@@ -8,3 +9,6 @@ $out2 = $prefixer("b")
|
|||||||
|
|
||||||
test $out1 {} # helloa
|
test $out1 {} # helloa
|
||||||
test $out2 {} # hellob
|
test $out2 {} # hellob
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[helloa]
|
||||||
|
Vertex: test[hellob]
|
||||||
@@ -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[amazing] # test[hey] -> test[amazing]
|
||||||
Edge: test[hey] -> test[cool] # test[hey] -> test[cool]
|
Edge: test[hey] -> test[cool] # test[hey] -> test[cool]
|
||||||
Edge: test[hey] -> test[hello] # test[hey] -> test[hello]
|
Edge: test[hey] -> test[hello] # test[hey] -> test[hello]
|
||||||
@@ -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]
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[name]
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
|
-- main.mcl --
|
||||||
# make sure the engine works with empty values
|
# make sure the engine works with empty values
|
||||||
test "name" {
|
test "name" {
|
||||||
slicestring => [], # empty list
|
slicestring => [], # empty list
|
||||||
mapintfloat => {}, # empty map
|
mapintfloat => {}, # empty map
|
||||||
}
|
}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[name]
|
||||||
@@ -1 +0,0 @@
|
|||||||
Vertex: test[x: This is x]
|
|
||||||
6
lang/interpret_test/TestAstFunc2/escaping0.txtar
Normal file
6
lang/interpret_test/TestAstFunc2/escaping0.txtar
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
# escaping example
|
||||||
|
$x = "This is x"
|
||||||
|
test "x: ${x}" {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[x: This is x]
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# escaping example
|
|
||||||
$x = "This is x"
|
|
||||||
test "x: ${x}" {}
|
|
||||||
@@ -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: $$$]
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- main.mcl --
|
||||||
# escaping examples
|
# escaping examples
|
||||||
|
|
||||||
test "A: \${test}" {}
|
test "A: \${test}" {}
|
||||||
@@ -60,3 +61,30 @@ $y1 = "{unused}"
|
|||||||
test "Y: $${y1} EOF" {} # check there isn't double parsing
|
test "Y: $${y1} EOF" {} # check there isn't double parsing
|
||||||
|
|
||||||
test "Z: $$$" {}
|
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: $$$]
|
||||||
@@ -1 +0,0 @@
|
|||||||
# err: errInterpolate: parser failed: cannot parse string: X: ${foo()}
|
|
||||||
5
lang/interpret_test/TestAstFunc2/escaping2.txtar
Normal file
5
lang/interpret_test/TestAstFunc2/escaping2.txtar
Normal 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()}
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# this is invalid (you can't have a function inside a var lookup)
|
|
||||||
test "X: ${foo()}" {}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# err: errInterpolate: parser failed: cannot parse string: X: ${}
|
|
||||||
5
lang/interpret_test/TestAstFunc2/escaping3.txtar
Normal file
5
lang/interpret_test/TestAstFunc2/escaping3.txtar
Normal 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: ${}
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# this is invalid (you can't have an empty var lookup)
|
|
||||||
test "X: ${}" {}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# err: errInterpolate: parser failed: unknown escape sequence: \z
|
|
||||||
5
lang/interpret_test/TestAstFunc2/escaping4.txtar
Normal file
5
lang/interpret_test/TestAstFunc2/escaping4.txtar
Normal 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
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# this is invalid (you can't escape a z, right?)
|
|
||||||
test "X: \z" {}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# err: errInterpolate: parser failed: unknown escape sequence: \j
|
|
||||||
5
lang/interpret_test/TestAstFunc2/escaping5.txtar
Normal file
5
lang/interpret_test/TestAstFunc2/escaping5.txtar
Normal 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
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# this is invalid (there's no \j escape sequence)
|
|
||||||
test "X: there is no \j sequence" {}
|
|
||||||
12
lang/interpret_test/TestAstFunc2/example.txtar
Normal file
12
lang/interpret_test/TestAstFunc2/example.txtar
Normal 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
Reference in New Issue
Block a user