-
Notifications
You must be signed in to change notification settings - Fork 27
/
main_test.go
71 lines (54 loc) · 1.5 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//go:build !js
// +build !js
package main
import (
"testing"
"github.com/lmorg/murex/lang"
"github.com/lmorg/murex/test/count"
"github.com/lmorg/murex/utils/json"
)
// TestMurex tests murex runtime environment can be initialized and and simple
// command line can execute
func TestMurex(t *testing.T) {
count.Tests(t, 1)
lang.InitEnv()
block := []rune("a [Mon..Fri]->regexp m/^T/")
_, err := lang.ShellProcess.Fork(lang.F_NO_STDIN | lang.F_NO_STDOUT | lang.F_NO_STDERR).Execute(block)
if err != nil {
t.Error(err.Error())
}
}
func TestRunCommandLine(t *testing.T) {
count.Tests(t, 1)
runCommandString(`out: "testing" -> null`)
}
func TestRunSource(t *testing.T) {
count.Tests(t, 1)
file := "test/source.mx"
runSource(file)
}
func TestRunSourceGzMods(t *testing.T) {
count.Tests(t, 1)
file := "test/source.mx.gz"
runSource(file)
}
func TestArgvToCmdLineStr(t *testing.T) {
tests := map[string][]string{
`foobar`: []string{`foobar`},
`\ foo`: []string{` foo`},
`foo\ `: []string{`foo `}, // TODO: this might cause things to break...?
`foo bar`: []string{`foo`, `bar`},
`foo\ bar baz`: []string{`foo bar`, `baz`},
`foo\ bar`: []string{`foo `, `bar`},
}
count.Tests(t, len(tests))
for expected, argv := range tests {
actual := argvToCmdLineStr(argv)
if expected != actual {
t.Error("Expected does not match actual:")
t.Logf(" argv: %s", json.LazyLogging(argv))
t.Logf(" expected: '%s'", expected)
t.Logf(" actual: '%s'", actual)
}
}
}