github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/math/cos_test.go (about)

     1  package math_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/MontFerret/ferret/pkg/runtime/values"
     8  	"github.com/MontFerret/ferret/pkg/stdlib/math"
     9  
    10  	. "github.com/smartystreets/goconvey/convey"
    11  )
    12  
    13  func TestCos(t *testing.T) {
    14  	Convey("Should return a value", t, func() {
    15  		out, err := math.Cos(context.Background(), values.NewFloat(1))
    16  
    17  		So(err, ShouldBeNil)
    18  		So(out, ShouldEqual, 0.5403023058681398)
    19  
    20  		out, err = math.Cos(context.Background(), values.NewFloat(0))
    21  
    22  		So(err, ShouldBeNil)
    23  		So(out, ShouldEqual, 1)
    24  
    25  		out, err = math.Cos(context.Background(), values.NewFloat(-3.141592653589783))
    26  
    27  		So(err, ShouldBeNil)
    28  		So(out.Unwrap(), ShouldEqual, -1)
    29  	})
    30  }