cuelang.org/go@v0.10.1/pkg/math/math_test.go (about) 1 // Copyright 2020 CUE Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package math_test 16 17 import ( 18 "fmt" 19 "testing" 20 21 "cuelang.org/go/pkg/internal/builtintest" 22 "cuelang.org/go/pkg/math" 23 ) 24 25 func TestBuiltin(t *testing.T) { 26 builtintest.Run("math", t) 27 } 28 29 func Example_constants() { 30 show := func(name string, value any) { 31 fmt.Printf("% 7s: %v\n", name, value) 32 } 33 34 show("E", math.E) 35 show("Pi", math.Pi) 36 show("Phi", math.Phi) 37 38 show("Sqrt2", math.Sqrt2) 39 show("SqrtE", math.SqrtE) 40 show("SqrtPi", math.SqrtPi) 41 show("SqrtPhi", math.SqrtPhi) 42 43 show("Ln2", math.Ln2) 44 show("Log2E", math.Log2E) 45 show("Ln10", math.Ln10) 46 show("Log10E", math.Log10E) 47 48 // Output: 49 // E: 2.718281828459045 50 // Pi: 3.141592653589793 51 // Phi: 1.618033988749895 52 // Sqrt2: 1.4142135623730951 53 // SqrtE: 1.6487212707001282 54 // SqrtPi: 1.772453850905516 55 // SqrtPhi: 1.272019649514069 56 // Ln2: 0.6931471805599453 57 // Log2E: 1.4426950408889634 58 // Ln10: 2.302585092994046 59 // Log10E: 0.4342944819032518 60 }