github.com/xyproto/u-root@v6.0.1-0.20200302025726-5528e0c77a3c+incompatible/cmds/core/elvish/eval/vals/bool_test.go (about)

     1  package vals
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/u-root/u-root/cmds/core/elvish/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  var boolTests = tt.Table{
    16  	Args(true).Rets(true),
    17  	Args(false).Rets(false),
    18  
    19  	Args(customBooler{true}).Rets(true),
    20  	Args(customBooler{false}).Rets(false),
    21  
    22  	Args(customNonBooler{}).Rets(true),
    23  }
    24  
    25  func TestBool(t *testing.T) {
    26  	tt.Test(t, tt.Fn("Bool", Bool), boolTests)
    27  }