Skip to content

Commit

Permalink
tests/math: add -tags nolibc to force Go implementations of math.Exp,…
Browse files Browse the repository at this point in the history
…Exp2,Log
  • Loading branch information
ydnar committed Mar 3, 2024
1 parent 0f658e3 commit d507134
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 27 additions & 0 deletions tests/math/math_nolibc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//go:build nolibc

package math_test

//go:export exp
func exp(f float64) float64 {
return mathExp(f)
}

//go:linkname mathExp math.exp
func mathExp(float64) float64

//go:export exp2
func exp2(f float64) float64 {
return mathExp(f)
}

//go:linkname mathExp2 math.exp2
func mathExp2(float64) float64

//go:export log
func log(f float64) float64 {
return mathLog(f)
}

//go:linkname mathLog math.log
func mathLog(float64) float64
4 changes: 2 additions & 2 deletions tests/math/math_bench_test.go → tests/math/math_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// //go:build tinygo.wasm

package math_test

import (
"math"
"math/rand"
"testing"
_ "unsafe"
)

var tested float64
Expand Down Expand Up @@ -33,6 +32,7 @@ func BenchmarkMathCeil(b *testing.B) {
}
tested = f
}

func BenchmarkMathExp(b *testing.B) {
var f float64
for i := 0; i < b.N; i++ {
Expand Down

0 comments on commit d507134

Please sign in to comment.