github.com/elves/elvish@v0.15.0/pkg/eval/vals/bool_test.go (about)

     1  package vals
     2  
     3  import (
     4  	"testing"
     5  
     6  	. "github.com/elves/elvish/pkg/tt"
     7  )
     8  
     9  type customBooler struct{ b bool }
    10  
    11  func (b customBooler) Bool() bool { return b.b }
    12  
    13  type customNonBooler struct{}
    14  
    15  func TestBool(t *testing.T) {
    16  	Test(t, Fn("Bool", Bool), Table{
    17  		Args(nil).Rets(false),
    18  
    19  		Args(true).Rets(true),
    20  		Args(false).Rets(false),
    21  
    22  		Args(customBooler{true}).Rets(true),
    23  		Args(customBooler{false}).Rets(false),
    24  
    25  		Args(customNonBooler{}).Rets(true),
    26  	})
    27  }