pkg/fall: make Zero and Root vars not funcs (#1367)

These can be just vars. Think that was intended as well.
This commit is contained in:
Miek Gieben
2018-01-09 22:29:19 +00:00
committed by GitHub
parent a19ea63d3a
commit cced1a4c12
5 changed files with 51 additions and 52 deletions

View File

@@ -28,7 +28,7 @@ func (f *F) setZones(zones []string) {
// SetZonesFromArgs sets zones in f to the passed value or to "." if the slice is empty.
func (f *F) SetZonesFromArgs(zones []string) {
if len(zones) == 0 {
f.setZones(Root().Zones)
f.setZones(Root.Zones)
return
}
f.setZones(zones)
@@ -50,9 +50,9 @@ func (f F) Equal(g F) bool {
// Zero returns a zero valued F.
var Zero = func() F {
return F{[]string{}}
}
}()
// Root returns F set to only ".".
var Root = func() F {
return F{[]string{"."}}
}
}()

View File

@@ -23,7 +23,7 @@ func TestEqual(t *testing.T) {
func TestZero(t *testing.T) {
var f F
if !f.Equal(Zero()) {
if !f.Equal(Zero) {
t.Errorf("F should be zero")
}
}
@@ -31,7 +31,7 @@ func TestZero(t *testing.T) {
func TestSetZonesFromArgs(t *testing.T) {
var f F
f.SetZonesFromArgs([]string{})
if !f.Equal(Root()) {
if !f.Equal(Root) {
t.Errorf("F should have the root zone")
}