test explicit input over stdin and generate option defaults

This commit is contained in:
Arpad Ryszka 2018-01-09 00:31:00 +01:00
parent 736741915c
commit fd0e62377a
6 changed files with 634 additions and 575 deletions

View File

@ -188,6 +188,14 @@ var checkTests = []mainTest{
"treerack", "check", "-syntax-string", `foo = "bar"`, "-input-string", "bar",
},
},
{
title: "explicit over stdin",
args: []string{
"treerack", "check", "-syntax", "foo_test.treerack", "-input-string", "bar",
},
stdin: "invalid",
},
}
func TestCheck(t *testing.T) {

View File

@ -112,6 +112,14 @@ var checkSyntaxTests = []mainTest{
"treerack", "check-syntax", "-syntax-string", `foo = "bar"`,
},
},
{
title: "explicit over stdin",
args: []string{
"treerack", "check-syntax", "-syntax", "foo_test.treerack",
},
stdin: "invalid",
},
}
func TestCheckSyntax(t *testing.T) {

View File

@ -47,6 +47,40 @@ var generateTests = []mainTest{
"func Parse",
},
},
{
title: "default package name",
args: []string{
"treerack", "generate", "-export", "-syntax-string", `foo = "bar"`,
},
stdout: []string{
"package main",
"func Parse",
},
},
{
title: "no export",
args: []string{
"treerack", "generate", "-package-name", "foo", "-syntax-string", `foo = "bar"`,
},
stdout: []string{
"package foo",
"func parse",
},
},
{
title: "explicit over stdin",
args: []string{
"treerack", "generate", "-export", "-package-name", "foo", "-syntax", "foo_test.treerack",
},
stdin: "invalid",
stdout: []string{
"package foo",
"func Parse",
},
},
}
func TestGenerate(t *testing.T) {

View File

@ -56,6 +56,17 @@ var parseTests = []mainTest{
},
},
{
title: "explicit over stdin",
args: []string{
"treerack", "parse", "-syntax", "foo_test.treerack", "-input-string", "bar",
},
stdin: "invalid",
stdout: []string{
`"name":"foo"`,
},
},
{
title: "pretty",
args: []string{

View File

@ -1,19 +1,12 @@
[next]
errors
formatter
report unused parsers
parse hashed, storing only the results
linux packaging
[parser]
custom tokens
indentation
streaming support // ReadNode(io.Reader)
[cmd]
check
parse
help for positional argument
test explicit input priority
[errors]
take the last
@ -21,6 +14,11 @@ test error report on invalid flag
input name: may be just dropped because completely controlled by the client
input name needed in command to differentiate between syntax and input in check and parse subcommands
[parser]
custom tokens
indentation
streaming support // ReadNode(io.Reader)
[generator]
allchars: can have char sequence
make generator output non-random (track parsers in a list in definition order)

File diff suppressed because it is too large Load Diff