refactored tests based on test-file.txt; this file is no more needed
This commit is contained in:
+22
-20
@@ -5,10 +5,13 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"io"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// const (
|
||||
// builtinOsFile_dummyFile = "/tmp/.go-test_dummy.txt"
|
||||
// )
|
||||
|
||||
func TestFuncOs(t *testing.T) {
|
||||
section := "Builtin-OS-File"
|
||||
inputs := []inputType{
|
||||
@@ -27,30 +30,29 @@ func TestFuncOs(t *testing.T) {
|
||||
/* 13 */ {`builtin "os.file"; handle=fileClose(123)`, nil, `fileClose(): invalid file handle`},
|
||||
/* 14 */ {`builtin "os.file"; handle=fileOpen("/tmp/dummy"); c=fileReadTextAll(handle); fileClose(handle); c`, "bye-bye", nil},
|
||||
/* 15 */ {`builtin "os.file"; c=fileReadTextAll(123)`, nil, `fileReadTextAll(): invalid file handle 123 [int64]`},
|
||||
/* 16 */ {`builtin "os.file"; it=fileLineIterator("test-file.txt"); it++`, "uno", nil},
|
||||
/* 17 */ {`builtin "os.file"; it=fileLineIterator("test-file.txt"); it++;it++;it++`, nil, io.EOF.Error()},
|
||||
/* 18 */ {`builtin "os.file"; it=fileLineIterator("test-file.txt"); it.clean`, nil, nil},
|
||||
/* 19 */ {`builtin "os.file"; it=fileLineIterator("test-file.txt"); string(it)`, `$(fileLineIterator@"test-file.txt")`, nil},
|
||||
/* 20 */ {`builtin "os.file"; handle=fileOpen("/etc/hosts"); fileClose(handle); string(handle)`, `reader`, nil},
|
||||
/* 21 */ {`builtin "os.file"; handle=fileCreate("/tmp/dummy"); fileClose(handle); string(handle)`, `writer`, nil},
|
||||
/* 16 */ {`builtin "os.file"; handle=fileOpen("/etc/hosts"); fileClose(handle); string(handle)`, `reader`, nil},
|
||||
/* 17 */ {`builtin "os.file"; handle=fileCreate("/tmp/dummy"); fileClose(handle); string(handle)`, `writer`, nil},
|
||||
}
|
||||
|
||||
// t.Setenv("EXPR_PATH", ".")
|
||||
|
||||
// runTestSuiteSpec(t, section, inputs, 24)
|
||||
// RunTestSuiteSpec(t, section, inputs, 17)
|
||||
RunTestSuite(t, section, inputs)
|
||||
}
|
||||
|
||||
func TestFuncOsByteIter(t *testing.T) {
|
||||
section := "Builtin-OS-File-Byte-Iter"
|
||||
inputs := []inputType{
|
||||
/* 1 */ {`builtin "os.file"; it=fileByteIterator("test-file.txt"); string(it)`, `$(fileByteIterator@"test-file.txt")`, nil},
|
||||
/* 2 */ {`builtin ["os.file", "string"]; it=fileByteIterator("test-file.txt"); char(it++)`, `u`, nil},
|
||||
/* 3 */ {`builtin ["os.file", "string"]; it=fileByteIterator("test-file.txt"); it++; it.reset; char(it++)`, `u`, nil},
|
||||
}
|
||||
// func setupBuiltinOsFile() (err error) {
|
||||
// var fh *os.File
|
||||
// // Create test file
|
||||
// if fh, err = os.Create(builtinOsFile_dummyFile); err == nil {
|
||||
// defer fh.Close()
|
||||
// fmt.Fprintln(fh, "uno")
|
||||
// fmt.Fprintln(fh, "due")
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
|
||||
// t.Setenv("EXPR_PATH", ".")
|
||||
|
||||
// runTestSuiteSpec(t, section, inputs, 24)
|
||||
RunTestSuite(t, section, inputs)
|
||||
}
|
||||
// func cleanupBuiltinOsFile() {
|
||||
// if fileExists(builtinOsFile_dummyFile) {
|
||||
// os.Remove(builtinOsFile_dummyFile)
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user