30 lines
1.2 KiB
Go
30 lines
1.2 KiB
Go
|
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||
|
// All rights reserved.
|
||
|
|
||
|
// t_func-os_test.go
|
||
|
package expr
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestFuncOs(t *testing.T) {
|
||
|
section := "Func-OS"
|
||
|
inputs := []inputType{
|
||
|
/* 1 */ {`builtin "os.file"`, int64(1), nil},
|
||
|
/* 2 */ {`builtin "os.file"; handle=openFile("/etc/hosts"); closeFile(handle)`, true, nil},
|
||
|
/* 3 */ {`builtin "os.file"; handle=openFile("/etc/hostsX")`, nil, errors.New(`open /etc/hostsX: no such file or directory`)},
|
||
|
/* 4 */ {`builtin "os.file"; handle=createFile("/tmp/dummy"); closeFile(handle)`, true, nil},
|
||
|
/* 5 */ {`builtin "os.file"; handle=appendFile("/tmp/dummy"); writeFile(handle, "bye-bye"); closeFile(handle)`, true, nil},
|
||
|
/* 6 */ {`builtin "os.file"; handle=openFile("/tmp/dummy"); word=readFile(handle, "-"); closeFile(handle);word`, "bye", nil},
|
||
|
/* 7 */ {`builtin "os.file"; word=readFile(nil, "-")`, nil, errors.New(`readFileFunc(): invalid file handle`)},
|
||
|
/* 7 */ {`builtin "os.file"; writeFile(nil, "bye")`, nil, errors.New(`writeFileFunc(): invalid file handle`)},
|
||
|
}
|
||
|
|
||
|
// t.Setenv("EXPR_PATH", ".")
|
||
|
|
||
|
// parserTestSpec(t, section, inputs, 69)
|
||
|
parserTest(t, section, inputs)
|
||
|
}
|