github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/process_mx_test.go (about) 1 package lang_test 2 3 import ( 4 "testing" 5 6 _ "github.com/lmorg/murex/builtins" 7 "github.com/lmorg/murex/test" 8 ) 9 10 // TestMxProcess is a function for testing parser, builtins and other behaviors 11 // which are defined in process.go. This might result in duplication of tests 12 // where such behavior is also tested in the builtin or other package, however 13 // that is acceptable because it allows different packages to be altered, 14 // refactored and even completely rewritten while still maintaining as much 15 // test coverage as possible. 16 func TestMxProcess(t *testing.T) { 17 tests := []test.MurexTest{ 18 { 19 Block: `pipe: TestMxProcess 20 bg { <TestMxProcess> } 21 out: "Hello, world!" -> <TestMxProcess> 22 !pipe: TestMxProcess`, 23 Stdout: "^Hello, world!\n$", 24 }, 25 26 { 27 Block: `alias: TestMxProcess=out Hello, world! 28 TestMxProcess`, 29 Stdout: "^Hello, world!\n$", 30 }, 31 32 { 33 Block: `global: TestMxProcess="Hello, world!" 34 $TestMxProcess`, 35 Stdout: "^Hello, world!$", 36 }, 37 38 { 39 Block: `global: json array = ([0, 1, 2, 3]) 40 $array[2]`, 41 Stdout: "2", 42 }, 43 44 { 45 Block: `function test-func { 46 out: "Hello, world!" 47 } 48 test-func`, 49 Stdout: "Hello, world!\n", 50 }, 51 52 { 53 Block: `private test-priv { 54 out: "Hello, world!" 55 } 56 test-priv`, 57 Stdout: "Hello, world!\n", 58 }, 59 60 { 61 Block: `function hello-world { 62 test define example { 63 "StdoutRegex": (^Hello world$) 64 } 65 out <test_example> "Hello world" 66 } 67 test config enable !auto-report 68 hello-world`, 69 Stdout: "Enabling test mode....\nDisabling auto-report....\nHello world\n", 70 }, 71 } 72 73 test.RunMurexTestsRx(tests, t) 74 }