src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/eval/vals/bool_test.go (about)

     1  package vals
     2  
     3  import (
     4  	"testing"
     5  
     6  	"src.elv.sh/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  	tt.Test(t, Bool,
    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  }