1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-23 01:24:30 +02:00
ferret/pkg/stdlib/math/sin_test.go

37 lines
827 B
Go
Raw Normal View History

package math_test
import (
"context"
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/MontFerret/ferret/pkg/stdlib/math"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestSin(t *testing.T) {
Convey("Should return sin value", t, func() {
out, err := math.Sin(context.Background(), values.NewFloat(3.141592653589783/2))
So(err, ShouldBeNil)
So(out, ShouldEqual, 1)
out, err = math.Sin(context.Background(), values.NewInt(0))
So(err, ShouldBeNil)
So(out, ShouldEqual, 0)
out, err = math.Sin(context.Background(), values.NewFloat(-3.141592653589783/2))
So(err, ShouldBeNil)
So(out, ShouldEqual, -1)
v, _ := math.Radians(context.Background(), values.NewInt(270))
out, err = math.Sin(context.Background(), v)
So(err, ShouldBeNil)
So(out, ShouldEqual, -1)
})
}