github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/io/file_test.go (about)

     1  package io_test
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	_ "github.com/lmorg/murex/builtins"
     8  	"github.com/lmorg/murex/test"
     9  )
    10  
    11  func TestPipeTelemetry(t *testing.T) {
    12  	tests := []test.MurexTest{
    13  		{
    14  			Block:  `tout * 12345 -> pt`,
    15  			Stdout: `12345`,
    16  		},
    17  	}
    18  
    19  	test.RunMurexTests(tests, t)
    20  }
    21  
    22  func TestWriteFile(t *testing.T) {
    23  	file := t.TempDir()
    24  	file += "/TestWriteFile.txt"
    25  
    26  	tests := []test.MurexTest{
    27  		{
    28  			Block:  fmt.Sprintf(`out foo |> %s; out bar |> %s; open %s`, file, file, file),
    29  			Stdout: "bar\n",
    30  		},
    31  	}
    32  
    33  	test.RunMurexTests(tests, t)
    34  }
    35  
    36  func TestAppendFile(t *testing.T) {
    37  	file := t.TempDir()
    38  	file += "/TestAppendFile.txt"
    39  
    40  	tests := []test.MurexTest{
    41  		{
    42  			Block:  fmt.Sprintf(`out foo |> %s; out bar >> %s; open %s`, file, file, file),
    43  			Stdout: "foo\nbar\n",
    44  		},
    45  	}
    46  
    47  	test.RunMurexTests(tests, t)
    48  }