mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
71cd3835bc
Qualified imports of pkg/tt outnumber unqualified (27 to 24). Improve consistency, and clarity, by changing the dot (unqualified) imports of that package symbols to qualified.
29 lines
598 B
Go
29 lines
598 B
Go
package vars
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"src.elv.sh/pkg/eval/errs"
|
|
"src.elv.sh/pkg/tt"
|
|
)
|
|
|
|
func TestNewReadOnly(t *testing.T) {
|
|
v := NewReadOnly("haha")
|
|
if v.Get() != "haha" {
|
|
t.Errorf("Get doesn't return initial value")
|
|
}
|
|
|
|
err := v.Set("lala")
|
|
if _, ok := err.(errs.SetReadOnlyVar); !ok {
|
|
t.Errorf("Set a readonly var doesn't error as expected: %#v", err)
|
|
}
|
|
}
|
|
|
|
func TestIsReadOnly(t *testing.T) {
|
|
tt.Test(t, tt.Fn("IsReadOnly", IsReadOnly), tt.Table{
|
|
Args(NewReadOnly("foo")).Rets(true),
|
|
Args(FromGet(func() any { return "foo" })).Rets(true),
|
|
Args(FromInit("foo")).Rets(false),
|
|
})
|
|
}
|