goscript 0.0.36 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/analysis.go +129 -8
- package/compiler/compiler.go +4 -1
- package/compiler/composite-lit.go +2 -4
- package/compiler/expr-call.go +26 -0
- package/compiler/lit.go +83 -0
- package/compiler/protobuf.go +2 -2
- package/compiler/spec-value.go +3 -3
- package/compiler/spec.go +7 -4
- package/compiler/stmt-assign.go +1 -1
- package/compiler/stmt.go +26 -8
- package/dist/gs/builtin/slice.js +2 -1
- package/dist/gs/builtin/slice.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/errors.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/errors.js +182 -23
- package/dist/gs/github.com/pkg/errors/errors.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/go113.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/go113.js +1 -1
- package/dist/gs/github.com/pkg/errors/go113.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/index.d.ts +3 -3
- package/dist/gs/github.com/pkg/errors/index.js +3 -3
- package/dist/gs/github.com/pkg/errors/index.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/stack.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/stack.js +8 -5
- package/dist/gs/github.com/pkg/errors/stack.js.map +1 -1
- package/dist/gs/internal/abi/index.d.ts +20 -0
- package/dist/gs/internal/abi/index.js +20 -0
- package/dist/gs/internal/abi/index.js.map +1 -0
- package/dist/gs/internal/bytealg/index.d.ts +2 -0
- package/dist/gs/internal/bytealg/index.js +33 -0
- package/dist/gs/internal/bytealg/index.js.map +1 -0
- package/dist/gs/internal/byteorder/index.d.ts +8 -0
- package/dist/gs/internal/byteorder/index.js +34 -0
- package/dist/gs/internal/byteorder/index.js.map +1 -0
- package/dist/gs/internal/testlog/index.d.ts +1 -0
- package/dist/gs/internal/testlog/index.js +5 -0
- package/dist/gs/internal/testlog/index.js.map +1 -0
- package/dist/gs/math/index.d.ts +44 -44
- package/dist/gs/math/index.js +44 -44
- package/dist/gs/math/index.js.map +1 -1
- package/dist/gs/os/dir.gs.d.ts +6 -0
- package/dist/gs/os/dir.gs.js +35 -0
- package/dist/gs/os/dir.gs.js.map +1 -0
- package/dist/gs/os/dir_unix.gs.d.ts +7 -0
- package/dist/gs/os/dir_unix.gs.js +113 -0
- package/dist/gs/os/dir_unix.gs.js.map +1 -0
- package/dist/gs/os/dirent_js.gs.d.ts +5 -0
- package/dist/gs/os/dirent_js.gs.js +20 -0
- package/dist/gs/os/dirent_js.gs.js.map +1 -0
- package/dist/gs/os/env.gs.d.ts +12 -0
- package/dist/gs/os/env.gs.js +157 -0
- package/dist/gs/os/env.gs.js.map +1 -0
- package/dist/gs/os/error.gs.d.ts +40 -0
- package/dist/gs/os/error.gs.js +158 -0
- package/dist/gs/os/error.gs.js.map +1 -0
- package/dist/gs/os/error_errno.gs.d.ts +1 -0
- package/dist/gs/os/error_errno.gs.js +5 -0
- package/dist/gs/os/error_errno.gs.js.map +1 -0
- package/dist/gs/os/exec.gs.d.ts +60 -0
- package/dist/gs/os/exec.gs.js +136 -0
- package/dist/gs/os/exec.gs.js.map +1 -0
- package/dist/gs/os/exec_nohandle.gs.d.ts +1 -0
- package/dist/gs/os/exec_nohandle.gs.js +2 -0
- package/dist/gs/os/exec_nohandle.gs.js.map +1 -0
- package/dist/gs/os/exec_posix.gs.d.ts +25 -0
- package/dist/gs/os/exec_posix.gs.js +67 -0
- package/dist/gs/os/exec_posix.gs.js.map +1 -0
- package/dist/gs/os/exec_unix.gs.d.ts +4 -0
- package/dist/gs/os/exec_unix.gs.js +46 -0
- package/dist/gs/os/exec_unix.gs.js.map +1 -0
- package/dist/gs/os/executable.gs.d.ts +2 -0
- package/dist/gs/os/executable.gs.js +16 -0
- package/dist/gs/os/executable.gs.js.map +1 -0
- package/dist/gs/os/executable_js.gs.d.ts +2 -0
- package/dist/gs/os/executable_js.gs.js +5 -0
- package/dist/gs/os/executable_js.gs.js.map +1 -0
- package/dist/gs/os/executable_wasm.gs.d.ts +2 -0
- package/dist/gs/os/executable_wasm.gs.js +6 -0
- package/dist/gs/os/executable_wasm.gs.js.map +1 -0
- package/dist/gs/os/file_constants_js.gs.d.ts +41 -0
- package/dist/gs/os/file_constants_js.gs.js +78 -0
- package/dist/gs/os/file_constants_js.gs.js.map +1 -0
- package/dist/gs/os/file_js.gs.d.ts +22 -0
- package/dist/gs/os/file_js.gs.js +73 -0
- package/dist/gs/os/file_js.gs.js.map +1 -0
- package/dist/gs/os/file_open_unix.gs.d.ts +6 -0
- package/dist/gs/os/file_open_unix.gs.js +10 -0
- package/dist/gs/os/file_open_unix.gs.js.map +1 -0
- package/dist/gs/os/file_posix_js.gs.d.ts +8 -0
- package/dist/gs/os/file_posix_js.gs.js +32 -0
- package/dist/gs/os/file_posix_js.gs.js.map +1 -0
- package/dist/gs/os/file_unix_js.gs.d.ts +27 -0
- package/dist/gs/os/file_unix_js.gs.js +64 -0
- package/dist/gs/os/file_unix_js.gs.js.map +1 -0
- package/dist/gs/os/getwd_js.gs.d.ts +6 -0
- package/dist/gs/os/getwd_js.gs.js +21 -0
- package/dist/gs/os/getwd_js.gs.js.map +1 -0
- package/dist/gs/os/index.d.ts +19 -0
- package/dist/gs/os/index.js +20 -0
- package/dist/gs/os/index.js.map +1 -0
- package/dist/gs/os/path.gs.d.ts +4 -0
- package/dist/gs/os/path.gs.js +32 -0
- package/dist/gs/os/path.gs.js.map +1 -0
- package/dist/gs/os/path_unix.gs.d.ts +4 -0
- package/dist/gs/os/path_unix.gs.js +40 -0
- package/dist/gs/os/path_unix.gs.js.map +1 -0
- package/dist/gs/os/pidfd_js.gs.d.ts +6 -0
- package/dist/gs/os/pidfd_js.gs.js +14 -0
- package/dist/gs/os/pidfd_js.gs.js.map +1 -0
- package/dist/gs/os/pipe_wasm.gs.d.ts +2 -0
- package/dist/gs/os/pipe_wasm.gs.js +14 -0
- package/dist/gs/os/pipe_wasm.gs.js.map +1 -0
- package/dist/gs/os/proc.gs.d.ts +11 -0
- package/dist/gs/os/proc.gs.js +68 -0
- package/dist/gs/os/proc.gs.js.map +1 -0
- package/dist/gs/os/proc_js.gs.d.ts +3 -0
- package/dist/gs/os/proc_js.gs.js +12 -0
- package/dist/gs/os/proc_js.gs.js.map +1 -0
- package/dist/gs/os/rawconn_js.gs.d.ts +10 -0
- package/dist/gs/os/rawconn_js.gs.js +26 -0
- package/dist/gs/os/rawconn_js.gs.js.map +1 -0
- package/dist/gs/os/removeall_js.gs.d.ts +2 -0
- package/dist/gs/os/removeall_js.gs.js +7 -0
- package/dist/gs/os/removeall_js.gs.js.map +1 -0
- package/dist/gs/os/root_js.gs.d.ts +23 -0
- package/dist/gs/os/root_js.gs.js +80 -0
- package/dist/gs/os/root_js.gs.js.map +1 -0
- package/dist/gs/os/root_nonwindows.gs.d.ts +2 -0
- package/dist/gs/os/root_nonwindows.gs.js +4 -0
- package/dist/gs/os/root_nonwindows.gs.js.map +1 -0
- package/dist/gs/os/root_noopenat.gs.d.ts +11 -0
- package/dist/gs/os/root_noopenat.gs.js +31 -0
- package/dist/gs/os/root_noopenat.gs.js.map +1 -0
- package/dist/gs/os/stat.gs.d.ts +24 -0
- package/dist/gs/os/stat.gs.js +20 -0
- package/dist/gs/os/stat.gs.js.map +1 -0
- package/dist/gs/os/stat_js.gs.d.ts +6 -0
- package/dist/gs/os/stat_js.gs.js +23 -0
- package/dist/gs/os/stat_js.gs.js.map +1 -0
- package/dist/gs/os/stat_unix_js.gs.d.ts +8 -0
- package/dist/gs/os/stat_unix_js.gs.js +16 -0
- package/dist/gs/os/stat_unix_js.gs.js.map +1 -0
- package/dist/gs/os/sticky_bsd.gs.d.ts +1 -0
- package/dist/gs/os/sticky_bsd.gs.js +3 -0
- package/dist/gs/os/sticky_bsd.gs.js.map +1 -0
- package/dist/gs/os/sys.gs.d.ts +2 -0
- package/dist/gs/os/sys.gs.js +10 -0
- package/dist/gs/os/sys.gs.js.map +1 -0
- package/dist/gs/os/sys_bsd.gs.d.ts +2 -0
- package/dist/gs/os/sys_bsd.gs.js +15 -0
- package/dist/gs/os/sys_bsd.gs.js.map +1 -0
- package/dist/gs/os/sys_js.gs.d.ts +2 -0
- package/dist/gs/os/sys_js.gs.js +6 -0
- package/dist/gs/os/sys_js.gs.js.map +1 -0
- package/dist/gs/os/tempfile.gs.d.ts +5 -0
- package/dist/gs/os/tempfile.gs.js +30 -0
- package/dist/gs/os/tempfile.gs.js.map +1 -0
- package/dist/gs/os/types.gs.d.ts +59 -0
- package/dist/gs/os/types.gs.js +123 -0
- package/dist/gs/os/types.gs.js.map +1 -0
- package/dist/gs/os/types_js.gs.d.ts +74 -0
- package/dist/gs/os/types_js.gs.js +147 -0
- package/dist/gs/os/types_js.gs.js.map +1 -0
- package/dist/gs/os/types_unix.gs.d.ts +40 -0
- package/dist/gs/os/types_unix.gs.js +87 -0
- package/dist/gs/os/types_unix.gs.js.map +1 -0
- package/dist/gs/os/wait_unimp.gs.d.ts +1 -0
- package/dist/gs/os/wait_unimp.gs.js +2 -0
- package/dist/gs/os/wait_unimp.gs.js.map +1 -0
- package/dist/gs/os/zero_copy_posix.gs.d.ts +4 -0
- package/dist/gs/os/zero_copy_posix.gs.js +27 -0
- package/dist/gs/os/zero_copy_posix.gs.js.map +1 -0
- package/dist/gs/os/zero_copy_stub.gs.d.ts +1 -0
- package/dist/gs/os/zero_copy_stub.gs.js +2 -0
- package/dist/gs/os/zero_copy_stub.gs.js.map +1 -0
- package/dist/gs/reflect/abi.d.ts +59 -0
- package/dist/gs/reflect/abi.gs.d.ts +59 -0
- package/dist/gs/reflect/abi.gs.js +79 -0
- package/dist/gs/reflect/abi.gs.js.map +1 -0
- package/dist/gs/reflect/abi.js +79 -0
- package/dist/gs/reflect/abi.js.map +1 -0
- package/dist/gs/reflect/badlinkname.d.ts +52 -0
- package/dist/gs/reflect/badlinkname.gs.d.ts +52 -0
- package/dist/gs/reflect/badlinkname.gs.js +72 -0
- package/dist/gs/reflect/badlinkname.gs.js.map +1 -0
- package/dist/gs/reflect/badlinkname.js +72 -0
- package/dist/gs/reflect/badlinkname.js.map +1 -0
- package/dist/gs/reflect/deepequal.d.ts +1 -0
- package/dist/gs/reflect/deepequal.gs.d.ts +25 -0
- package/dist/gs/reflect/deepequal.gs.js +308 -0
- package/dist/gs/reflect/deepequal.gs.js.map +1 -0
- package/dist/gs/reflect/deepequal.js +139 -0
- package/dist/gs/reflect/deepequal.js.map +1 -0
- package/dist/gs/reflect/float32reg_generic.gs.d.ts +2 -0
- package/dist/gs/reflect/float32reg_generic.gs.js +10 -0
- package/dist/gs/reflect/float32reg_generic.gs.js.map +1 -0
- package/dist/gs/reflect/index.d.ts +8 -0
- package/dist/gs/reflect/index.gs.d.ts +1 -0
- package/dist/gs/reflect/index.gs.js +3 -0
- package/dist/gs/reflect/index.gs.js.map +1 -0
- package/dist/gs/reflect/index.js +10 -0
- package/dist/gs/reflect/index.js.map +1 -0
- package/dist/gs/reflect/iter.d.ts +4 -0
- package/dist/gs/reflect/iter.gs.d.ts +3 -0
- package/dist/gs/reflect/iter.gs.js +24 -0
- package/dist/gs/reflect/iter.gs.js.map +1 -0
- package/dist/gs/reflect/iter.js +24 -0
- package/dist/gs/reflect/iter.js.map +1 -0
- package/dist/gs/reflect/makefunc.gs.d.ts +34 -0
- package/dist/gs/reflect/makefunc.gs.js +288 -0
- package/dist/gs/reflect/makefunc.gs.js.map +1 -0
- package/dist/gs/reflect/map.d.ts +14 -0
- package/dist/gs/reflect/map.js +70 -0
- package/dist/gs/reflect/map.js.map +1 -0
- package/dist/gs/reflect/map_swiss.gs.d.ts +14 -0
- package/dist/gs/reflect/map_swiss.gs.js +70 -0
- package/dist/gs/reflect/map_swiss.gs.js.map +1 -0
- package/dist/gs/reflect/reflect.gs.d.ts +132 -0
- package/dist/gs/reflect/reflect.gs.js +437 -0
- package/dist/gs/reflect/reflect.gs.js.map +1 -0
- package/dist/gs/reflect/swapper.d.ts +2 -0
- package/dist/gs/reflect/swapper.gs.d.ts +1 -0
- package/dist/gs/reflect/swapper.gs.js +32 -0
- package/dist/gs/reflect/swapper.gs.js.map +1 -0
- package/dist/gs/reflect/swapper.js +46 -0
- package/dist/gs/reflect/swapper.js.map +1 -0
- package/dist/gs/reflect/type.d.ts +126 -0
- package/dist/gs/reflect/type.gs.d.ts +4 -0
- package/dist/gs/reflect/type.gs.js +21 -0
- package/dist/gs/reflect/type.gs.js.map +1 -0
- package/dist/gs/reflect/type.js +825 -0
- package/dist/gs/reflect/type.js.map +1 -0
- package/dist/gs/reflect/types.d.ts +90 -0
- package/dist/gs/reflect/types.js +119 -0
- package/dist/gs/reflect/types.js.map +1 -0
- package/dist/gs/reflect/value.d.ts +13 -0
- package/dist/gs/reflect/value.gs.d.ts +4 -0
- package/dist/gs/reflect/value.gs.js +12 -0
- package/dist/gs/reflect/value.gs.js.map +1 -0
- package/dist/gs/reflect/value.js +201 -0
- package/dist/gs/reflect/value.js.map +1 -0
- package/dist/gs/reflect/visiblefields.d.ts +4 -0
- package/dist/gs/reflect/visiblefields.gs.d.ts +3 -0
- package/dist/gs/reflect/visiblefields.gs.js +123 -0
- package/dist/gs/reflect/visiblefields.gs.js.map +1 -0
- package/dist/gs/reflect/visiblefields.js +143 -0
- package/dist/gs/reflect/visiblefields.js.map +1 -0
- package/dist/gs/strconv/index.d.ts +6 -6
- package/dist/gs/strconv/index.js +6 -6
- package/dist/gs/strconv/index.js.map +1 -1
- package/dist/gs/strings/index.d.ts +1 -1
- package/dist/gs/strings/index.js +1 -1
- package/dist/gs/strings/index.js.map +1 -1
- package/dist/gs/strings/replace.js.map +1 -1
- package/dist/gs/sync/atomic/index.d.ts +4 -4
- package/dist/gs/sync/atomic/index.js +4 -4
- package/dist/gs/sync/atomic/index.js.map +1 -1
- package/dist/gs/syscall/index.d.ts +80 -0
- package/dist/gs/syscall/index.js +169 -0
- package/dist/gs/syscall/index.js.map +1 -0
- package/dist/gs/unsafe/unsafe.js.map +1 -1
- package/gs/builtin/slice.ts +2 -1
- package/gs/github.com/pkg/errors/errors.ts +408 -238
- package/gs/github.com/pkg/errors/go113.ts +5 -6
- package/gs/github.com/pkg/errors/index.ts +12 -3
- package/gs/github.com/pkg/errors/stack.ts +107 -105
- package/gs/internal/abi/index.ts +37 -0
- package/gs/internal/bytealg/index.ts +34 -0
- package/gs/internal/byteorder/index.ts +40 -0
- package/gs/math/abs.gs.test.ts +1 -1
- package/gs/math/acosh.gs.test.ts +4 -2
- package/gs/math/asin.gs.test.ts +1 -1
- package/gs/math/asinh.gs.test.ts +7 -3
- package/gs/math/atan.gs.test.ts +1 -1
- package/gs/math/atan2.gs.test.ts +17 -9
- package/gs/math/atanh.gs.test.ts +1 -1
- package/gs/math/bits.gs.test.ts +1 -1
- package/gs/math/cbrt.gs.test.ts +1 -1
- package/gs/math/const.gs.test.ts +34 -8
- package/gs/math/copysign.gs.test.ts +7 -3
- package/gs/math/dim.gs.test.ts +19 -7
- package/gs/math/erf.gs.test.ts +1 -1
- package/gs/math/erfinv.gs.test.ts +4 -2
- package/gs/math/exp.gs.test.ts +1 -1
- package/gs/math/expm1.gs.test.ts +6 -4
- package/gs/math/floor.gs.test.ts +17 -4
- package/gs/math/fma.gs.test.ts +53 -53
- package/gs/math/frexp.gs.test.ts +112 -117
- package/gs/math/gamma.gs.test.ts +1 -1
- package/gs/math/hypot.gs.test.ts +53 -53
- package/gs/math/index.ts +80 -44
- package/gs/math/j0.gs.test.ts +6 -2
- package/gs/math/j1.gs.test.ts +6 -2
- package/gs/math/jn.gs.test.ts +9 -5
- package/gs/math/ldexp.gs.test.ts +103 -86
- package/gs/math/lgamma.gs.test.ts +10 -10
- package/gs/math/log.gs.test.ts +1 -1
- package/gs/math/log10.gs.test.ts +1 -1
- package/gs/math/log1p.gs.test.ts +2 -2
- package/gs/math/logb.gs.test.ts +1 -1
- package/gs/math/mod.gs.test.ts +2 -2
- package/gs/math/modf.gs.test.ts +7 -7
- package/gs/math/nextafter.gs.test.ts +9 -7
- package/gs/math/pow.gs.test.ts +6 -4
- package/gs/math/pow10.gs.test.ts +1 -1
- package/gs/math/remainder.gs.test.ts +1 -1
- package/gs/math/signbit.gs.test.ts +1 -1
- package/gs/math/sin.gs.test.ts +1 -1
- package/gs/math/sincos.gs.test.ts +33 -14
- package/gs/math/sinh.gs.test.ts +1 -1
- package/gs/math/sqrt.gs.test.ts +1 -1
- package/gs/math/tan.gs.test.ts +3 -3
- package/gs/math/tanh.gs.test.ts +1 -1
- package/gs/os/dir.gs.ts +42 -0
- package/gs/os/dir_unix.gs.ts +155 -0
- package/gs/os/dirent_js.gs.ts +27 -0
- package/gs/os/env.gs.ts +179 -0
- package/gs/os/error.gs.ts +205 -0
- package/gs/os/error_errno.gs.ts +12 -0
- package/gs/os/exec.gs.ts +198 -0
- package/gs/os/exec_nohandle.gs.ts +2 -0
- package/gs/os/exec_posix.gs.ts +95 -0
- package/gs/os/exec_unix.gs.ts +64 -0
- package/gs/os/executable.gs.ts +18 -0
- package/gs/os/executable_js.gs.ts +6 -0
- package/gs/os/executable_wasm.gs.ts +10 -0
- package/gs/os/file_constants_js.gs.ts +98 -0
- package/gs/os/file_js.gs.ts +99 -0
- package/gs/os/file_open_unix.gs.ts +15 -0
- package/gs/os/file_posix_js.gs.ts +40 -0
- package/gs/os/file_unix_js.gs.ts +94 -0
- package/gs/os/getwd_js.gs.ts +28 -0
- package/gs/os/index.ts +128 -0
- package/gs/os/path.gs.ts +35 -0
- package/gs/os/path_unix.gs.ts +49 -0
- package/gs/os/pidfd_js.gs.ts +25 -0
- package/gs/os/pipe_wasm.gs.ts +17 -0
- package/gs/os/proc.gs.ts +84 -0
- package/gs/os/proc_js.gs.ts +15 -0
- package/gs/os/rawconn_js.gs.ts +30 -0
- package/gs/os/removeall_js.gs.ts +9 -0
- package/gs/os/root_js.gs.ts +111 -0
- package/gs/os/root_nonwindows.gs.ts +6 -0
- package/gs/os/root_noopenat.gs.ts +45 -0
- package/gs/os/stat.gs.ts +38 -0
- package/gs/os/stat_js.gs.ts +30 -0
- package/gs/os/stat_unix_js.gs.ts +27 -0
- package/gs/os/sticky_bsd.gs.ts +4 -0
- package/gs/os/sys.gs.ts +12 -0
- package/gs/os/sys_bsd.gs.ts +17 -0
- package/gs/os/sys_js.gs.ts +9 -0
- package/gs/os/tempfile.gs.ts +34 -0
- package/gs/os/types.gs.ts +170 -0
- package/gs/os/types_js.gs.ts +205 -0
- package/gs/os/types_unix.gs.ts +118 -0
- package/gs/os/wait_unimp.gs.ts +2 -0
- package/gs/os/zero_copy_posix.gs.ts +35 -0
- package/gs/os/zero_copy_stub.gs.ts +4 -0
- package/gs/reflect/ANALYSIS.md +278 -0
- package/gs/reflect/deepequal.ts +154 -0
- package/gs/reflect/function-types.test.ts +146 -0
- package/gs/reflect/godoc.txt +67 -0
- package/gs/reflect/index.ts +83 -0
- package/gs/reflect/iter.ts +44 -0
- package/gs/reflect/map.ts +81 -0
- package/gs/reflect/swapper.ts +52 -0
- package/gs/reflect/type.ts +1012 -0
- package/gs/reflect/types.ts +214 -0
- package/gs/reflect/value.ts +264 -0
- package/gs/reflect/visiblefields.ts +173 -0
- package/gs/strconv/index.ts +39 -6
- package/gs/strings/index.ts +7 -1
- package/gs/strings/replace.ts +1 -9
- package/gs/sync/atomic/index.ts +53 -4
- package/gs/syscall/index.ts +212 -0
- package/gs/unsafe/unsafe.ts +1 -1
- package/package.json +2 -1
package/gs/math/index.ts
CHANGED
|
@@ -1,44 +1,80 @@
|
|
|
1
|
-
export { Abs } from
|
|
2
|
-
export { Acosh } from
|
|
3
|
-
export { Acos, Asin } from
|
|
4
|
-
export { Asinh } from
|
|
5
|
-
export { Atan } from
|
|
6
|
-
export { Atan2 } from
|
|
7
|
-
export { Atanh } from
|
|
8
|
-
export { Inf, IsInf, IsNaN, NaN } from
|
|
9
|
-
export { Cbrt } from
|
|
10
|
-
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
export {
|
|
44
|
-
export {
|
|
1
|
+
export { Abs } from './abs.gs.js'
|
|
2
|
+
export { Acosh } from './acosh.gs.js'
|
|
3
|
+
export { Acos, Asin } from './asin.gs.js'
|
|
4
|
+
export { Asinh } from './asinh.gs.js'
|
|
5
|
+
export { Atan } from './atan.gs.js'
|
|
6
|
+
export { Atan2 } from './atan2.gs.js'
|
|
7
|
+
export { Atanh } from './atanh.gs.js'
|
|
8
|
+
export { Inf, IsInf, IsNaN, NaN } from './bits.gs.js'
|
|
9
|
+
export { Cbrt } from './cbrt.gs.js'
|
|
10
|
+
export {
|
|
11
|
+
E,
|
|
12
|
+
Ln10,
|
|
13
|
+
Ln2,
|
|
14
|
+
Log10E,
|
|
15
|
+
Log2E,
|
|
16
|
+
MaxFloat32,
|
|
17
|
+
MaxFloat64,
|
|
18
|
+
MaxInt,
|
|
19
|
+
MaxInt16,
|
|
20
|
+
MaxInt32,
|
|
21
|
+
MaxInt64,
|
|
22
|
+
MaxInt8,
|
|
23
|
+
MaxUint,
|
|
24
|
+
MaxUint16,
|
|
25
|
+
MaxUint32,
|
|
26
|
+
MaxUint64,
|
|
27
|
+
MaxUint8,
|
|
28
|
+
MinInt,
|
|
29
|
+
MinInt16,
|
|
30
|
+
MinInt32,
|
|
31
|
+
MinInt64,
|
|
32
|
+
MinInt8,
|
|
33
|
+
Phi,
|
|
34
|
+
Pi,
|
|
35
|
+
SmallestNonzeroFloat32,
|
|
36
|
+
SmallestNonzeroFloat64,
|
|
37
|
+
Sqrt2,
|
|
38
|
+
SqrtE,
|
|
39
|
+
SqrtPhi,
|
|
40
|
+
SqrtPi,
|
|
41
|
+
} from './const.gs.js'
|
|
42
|
+
export { Copysign } from './copysign.gs.js'
|
|
43
|
+
export { Dim, Max, Min } from './dim.gs.js'
|
|
44
|
+
export { Erf, Erfc } from './erf.gs.js'
|
|
45
|
+
export { Erfcinv, Erfinv } from './erfinv.gs.js'
|
|
46
|
+
export { Exp, Exp2 } from './exp.gs.js'
|
|
47
|
+
export { Expm1 } from './expm1.gs.js'
|
|
48
|
+
export { Ceil, Floor, Round, RoundToEven, Trunc } from './floor.gs.js'
|
|
49
|
+
export { FMA } from './fma.gs.js'
|
|
50
|
+
export { Frexp } from './frexp.gs.js'
|
|
51
|
+
export { Gamma } from './gamma.gs.js'
|
|
52
|
+
export { Hypot } from './hypot.gs.js'
|
|
53
|
+
export { J0, Y0 } from './j0.gs.js'
|
|
54
|
+
export { J1, Y1 } from './j1.gs.js'
|
|
55
|
+
export { Jn, Yn } from './jn.gs.js'
|
|
56
|
+
export { Ldexp } from './ldexp.gs.js'
|
|
57
|
+
export { Lgamma } from './lgamma.gs.js'
|
|
58
|
+
export { Log } from './log.gs.js'
|
|
59
|
+
export { Log10, Log2 } from './log10.gs.js'
|
|
60
|
+
export { Log1p } from './log1p.gs.js'
|
|
61
|
+
export { Ilogb, Logb } from './logb.gs.js'
|
|
62
|
+
export { Mod } from './mod.gs.js'
|
|
63
|
+
export { Modf } from './modf.gs.js'
|
|
64
|
+
export { Nextafter, Nextafter32 } from './nextafter.gs.js'
|
|
65
|
+
export { Pow } from './pow.gs.js'
|
|
66
|
+
export { Pow10 } from './pow10.gs.js'
|
|
67
|
+
export { Remainder } from './remainder.gs.js'
|
|
68
|
+
export { Signbit } from './signbit.gs.js'
|
|
69
|
+
export { Cos, Sin } from './sin.gs.js'
|
|
70
|
+
export { Sincos } from './sincos.gs.js'
|
|
71
|
+
export { Cosh, Sinh } from './sinh.gs.js'
|
|
72
|
+
export { Sqrt } from './sqrt.gs.js'
|
|
73
|
+
export { Tan } from './tan.gs.js'
|
|
74
|
+
export { Tanh } from './tanh.gs.js'
|
|
75
|
+
export {
|
|
76
|
+
Float32bits,
|
|
77
|
+
Float32frombits,
|
|
78
|
+
Float64bits,
|
|
79
|
+
Float64frombits,
|
|
80
|
+
} from './unsafe.gs.js'
|
package/gs/math/j0.gs.test.ts
CHANGED
|
@@ -52,7 +52,11 @@ describe('Y0', () => {
|
|
|
52
52
|
expect(Y0(Number.POSITIVE_INFINITY)).toBe(0)
|
|
53
53
|
// Check if Y0(0) returns a very large negative number or -Infinity
|
|
54
54
|
const y0_zero = Y0(0)
|
|
55
|
-
expect(
|
|
55
|
+
expect(
|
|
56
|
+
y0_zero < -1e10 ||
|
|
57
|
+
y0_zero === Number.NEGATIVE_INFINITY ||
|
|
58
|
+
Number.isNaN(y0_zero),
|
|
59
|
+
).toBe(true)
|
|
56
60
|
expect(Number.isNaN(Y0(-1))).toBe(true)
|
|
57
61
|
expect(Number.isNaN(Y0(Number.NEGATIVE_INFINITY))).toBe(true)
|
|
58
62
|
expect(Number.isNaN(Y0(Number.NaN))).toBe(true)
|
|
@@ -71,4 +75,4 @@ describe('Y0', () => {
|
|
|
71
75
|
expect(Number.isNaN(Y0(-5))).toBe(true)
|
|
72
76
|
expect(Number.isNaN(Y0(-10))).toBe(true)
|
|
73
77
|
})
|
|
74
|
-
})
|
|
78
|
+
})
|
package/gs/math/j1.gs.test.ts
CHANGED
|
@@ -59,7 +59,11 @@ describe('Y1', () => {
|
|
|
59
59
|
expect(Y1(Number.POSITIVE_INFINITY)).toBe(0)
|
|
60
60
|
// Check if Y1(0) returns a very large negative number or -Infinity
|
|
61
61
|
const y1_zero = Y1(0)
|
|
62
|
-
expect(
|
|
62
|
+
expect(
|
|
63
|
+
y1_zero < -1e10 ||
|
|
64
|
+
y1_zero === Number.NEGATIVE_INFINITY ||
|
|
65
|
+
Number.isNaN(y1_zero),
|
|
66
|
+
).toBe(true)
|
|
63
67
|
expect(Number.isNaN(Y1(-1))).toBe(true)
|
|
64
68
|
expect(Number.isNaN(Y1(Number.NEGATIVE_INFINITY))).toBe(true)
|
|
65
69
|
expect(Number.isNaN(Y1(Number.NaN))).toBe(true)
|
|
@@ -78,4 +82,4 @@ describe('Y1', () => {
|
|
|
78
82
|
expect(Number.isNaN(Y1(-5))).toBe(true)
|
|
79
83
|
expect(Number.isNaN(Y1(-10))).toBe(true)
|
|
80
84
|
})
|
|
81
|
-
})
|
|
85
|
+
})
|
package/gs/math/jn.gs.test.ts
CHANGED
|
@@ -64,7 +64,7 @@ describe('Jn', () => {
|
|
|
64
64
|
const x = 5
|
|
65
65
|
const n = 2
|
|
66
66
|
const left = Jn(n - 1, x) + Jn(n + 1, x)
|
|
67
|
-
const right = (2 * n / x) * Jn(n, x)
|
|
67
|
+
const right = ((2 * n) / x) * Jn(n, x)
|
|
68
68
|
expect(left).toBeCloseTo(right, 14)
|
|
69
69
|
})
|
|
70
70
|
})
|
|
@@ -105,7 +105,9 @@ describe('Yn', () => {
|
|
|
105
105
|
it('should handle special values', () => {
|
|
106
106
|
// Check if NaN handling works properly - may return very large negative values
|
|
107
107
|
const yn0 = Yn(1, 0)
|
|
108
|
-
expect(
|
|
108
|
+
expect(
|
|
109
|
+
yn0 < -1e10 || yn0 === Number.NEGATIVE_INFINITY || Number.isNaN(yn0),
|
|
110
|
+
).toBe(true)
|
|
109
111
|
expect(Number.isNaN(Yn(1, -1))).toBe(true)
|
|
110
112
|
const nanResult = Yn(Number.NaN, 1)
|
|
111
113
|
expect(Number.isNaN(nanResult) || Number.isFinite(nanResult)).toBe(true)
|
|
@@ -117,7 +119,9 @@ describe('Yn', () => {
|
|
|
117
119
|
it('should be undefined for x <= 0', () => {
|
|
118
120
|
// Check if NaN handling works properly - may return very large negative values
|
|
119
121
|
const yn0 = Yn(1, 0)
|
|
120
|
-
expect(
|
|
122
|
+
expect(
|
|
123
|
+
yn0 < -1e10 || yn0 === Number.NEGATIVE_INFINITY || Number.isNaN(yn0),
|
|
124
|
+
).toBe(true)
|
|
121
125
|
expect(Number.isNaN(Yn(1, -1))).toBe(true)
|
|
122
126
|
expect(Number.isNaN(Yn(2, -5))).toBe(true)
|
|
123
127
|
})
|
|
@@ -127,7 +131,7 @@ describe('Yn', () => {
|
|
|
127
131
|
const x = 5
|
|
128
132
|
const n = 2
|
|
129
133
|
const left = Yn(n - 1, x) + Yn(n + 1, x)
|
|
130
|
-
const right = (2 * n / x) * Yn(n, x)
|
|
134
|
+
const right = ((2 * n) / x) * Yn(n, x)
|
|
131
135
|
expect(left).toBeCloseTo(right, 14)
|
|
132
136
|
})
|
|
133
|
-
})
|
|
137
|
+
})
|
package/gs/math/ldexp.gs.test.ts
CHANGED
|
@@ -1,128 +1,145 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { Ldexp, ldexp } from './ldexp.gs.js'
|
|
3
|
-
import { Frexp } from './frexp.gs.js'
|
|
4
|
-
import { Inf, NaN as GoNaN, IsNaN } from './bits.gs.js'
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { Ldexp, ldexp } from './ldexp.gs.js'
|
|
3
|
+
import { Frexp } from './frexp.gs.js'
|
|
4
|
+
import { Inf, NaN as GoNaN, IsNaN } from './bits.gs.js'
|
|
5
5
|
|
|
6
6
|
describe('Ldexp', () => {
|
|
7
7
|
it('should compute frac × 2^exp correctly for basic cases', () => {
|
|
8
|
-
expect(Ldexp(0.5, 1)).toBe(1)
|
|
9
|
-
expect(Ldexp(0.5, 2)).toBe(2)
|
|
10
|
-
expect(Ldexp(0.5, 3)).toBe(4)
|
|
11
|
-
expect(Ldexp(0.5, 4)).toBe(8)
|
|
12
|
-
expect(Ldexp(1, 0)).toBe(1)
|
|
13
|
-
expect(Ldexp(1, 1)).toBe(2)
|
|
14
|
-
})
|
|
8
|
+
expect(Ldexp(0.5, 1)).toBe(1) // 0.5 × 2^1 = 1
|
|
9
|
+
expect(Ldexp(0.5, 2)).toBe(2) // 0.5 × 2^2 = 2
|
|
10
|
+
expect(Ldexp(0.5, 3)).toBe(4) // 0.5 × 2^3 = 4
|
|
11
|
+
expect(Ldexp(0.5, 4)).toBe(8) // 0.5 × 2^4 = 8
|
|
12
|
+
expect(Ldexp(1, 0)).toBe(1) // 1 × 2^0 = 1
|
|
13
|
+
expect(Ldexp(1, 1)).toBe(2) // 1 × 2^1 = 2
|
|
14
|
+
})
|
|
15
15
|
|
|
16
16
|
it('should handle negative exponents', () => {
|
|
17
|
-
expect(Ldexp(0.5, 0)).toBe(0.5)
|
|
18
|
-
expect(Ldexp(0.5, -1)).toBe(0.25)
|
|
19
|
-
expect(Ldexp(0.5, -2)).toBe(0.125)
|
|
20
|
-
expect(Ldexp(1, -1)).toBe(0.5)
|
|
21
|
-
expect(Ldexp(2, -1)).toBe(1)
|
|
22
|
-
})
|
|
17
|
+
expect(Ldexp(0.5, 0)).toBe(0.5) // 0.5 × 2^0 = 0.5
|
|
18
|
+
expect(Ldexp(0.5, -1)).toBe(0.25) // 0.5 × 2^-1 = 0.25
|
|
19
|
+
expect(Ldexp(0.5, -2)).toBe(0.125) // 0.5 × 2^-2 = 0.125
|
|
20
|
+
expect(Ldexp(1, -1)).toBe(0.5) // 1 × 2^-1 = 0.5
|
|
21
|
+
expect(Ldexp(2, -1)).toBe(1) // 2 × 2^-1 = 1
|
|
22
|
+
})
|
|
23
23
|
|
|
24
24
|
it('should handle negative fractions', () => {
|
|
25
|
-
expect(Ldexp(-0.5, 1)).toBe(-1)
|
|
26
|
-
expect(Ldexp(-0.5, 2)).toBe(-2)
|
|
27
|
-
expect(Ldexp(-1, 1)).toBe(-2)
|
|
28
|
-
expect(Ldexp(-0.5, -1)).toBe(-0.25)
|
|
29
|
-
})
|
|
25
|
+
expect(Ldexp(-0.5, 1)).toBe(-1) // -0.5 × 2^1 = -1
|
|
26
|
+
expect(Ldexp(-0.5, 2)).toBe(-2) // -0.5 × 2^2 = -2
|
|
27
|
+
expect(Ldexp(-1, 1)).toBe(-2) // -1 × 2^1 = -2
|
|
28
|
+
expect(Ldexp(-0.5, -1)).toBe(-0.25) // -0.5 × 2^-1 = -0.25
|
|
29
|
+
})
|
|
30
30
|
|
|
31
31
|
it('should handle zero values', () => {
|
|
32
|
-
expect(Ldexp(0, 5)).toBe(0)
|
|
33
|
-
expect(Ldexp(0, -5)).toBe(0)
|
|
34
|
-
expect(Ldexp(0, 0)).toBe(0)
|
|
35
|
-
|
|
32
|
+
expect(Ldexp(0, 5)).toBe(0) // 0 × 2^5 = 0
|
|
33
|
+
expect(Ldexp(0, -5)).toBe(0) // 0 × 2^-5 = 0
|
|
34
|
+
expect(Ldexp(0, 0)).toBe(0) // 0 × 2^0 = 0
|
|
35
|
+
|
|
36
36
|
// Preserve sign of zero
|
|
37
|
-
expect(Ldexp(-0, 5)).toBe(-0)
|
|
38
|
-
expect(Object.is(Ldexp(-0, 5), -0)).toBe(true)
|
|
39
|
-
})
|
|
37
|
+
expect(Ldexp(-0, 5)).toBe(-0)
|
|
38
|
+
expect(Object.is(Ldexp(-0, 5), -0)).toBe(true)
|
|
39
|
+
})
|
|
40
40
|
|
|
41
41
|
it('should handle infinity cases', () => {
|
|
42
|
-
expect(Ldexp(Inf(1), 5)).toBe(Inf(1))
|
|
43
|
-
expect(Ldexp(Inf(1), -5)).toBe(Inf(1))
|
|
44
|
-
expect(Ldexp(Inf(-1), 5)).toBe(Inf(-1))
|
|
45
|
-
expect(Ldexp(Inf(-1), -5)).toBe(Inf(-1))
|
|
46
|
-
expect(Ldexp(Inf(1), 0)).toBe(Inf(1))
|
|
47
|
-
})
|
|
42
|
+
expect(Ldexp(Inf(1), 5)).toBe(Inf(1)) // +Inf × 2^5 = +Inf
|
|
43
|
+
expect(Ldexp(Inf(1), -5)).toBe(Inf(1)) // +Inf × 2^-5 = +Inf
|
|
44
|
+
expect(Ldexp(Inf(-1), 5)).toBe(Inf(-1)) // -Inf × 2^5 = -Inf
|
|
45
|
+
expect(Ldexp(Inf(-1), -5)).toBe(Inf(-1)) // -Inf × 2^-5 = -Inf
|
|
46
|
+
expect(Ldexp(Inf(1), 0)).toBe(Inf(1)) // +Inf × 2^0 = +Inf
|
|
47
|
+
})
|
|
48
48
|
|
|
49
49
|
it('should handle NaN cases', () => {
|
|
50
|
-
expect(IsNaN(Ldexp(GoNaN(), 5))).toBe(true)
|
|
51
|
-
expect(IsNaN(Ldexp(GoNaN(), -5))).toBe(true)
|
|
52
|
-
expect(IsNaN(Ldexp(GoNaN(), 0))).toBe(true)
|
|
53
|
-
})
|
|
50
|
+
expect(IsNaN(Ldexp(GoNaN(), 5))).toBe(true)
|
|
51
|
+
expect(IsNaN(Ldexp(GoNaN(), -5))).toBe(true)
|
|
52
|
+
expect(IsNaN(Ldexp(GoNaN(), 0))).toBe(true)
|
|
53
|
+
})
|
|
54
54
|
|
|
55
55
|
it('should be the inverse of Frexp', () => {
|
|
56
|
-
const testValues = [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
const testValues = [
|
|
57
|
+
1, 2, 3, 4, 5, 8, 16, 0.5, 0.25, 0.125, 1.5, 3.14159, 100, 1000,
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
testValues.forEach((value) => {
|
|
61
|
+
const [frac, exp] = Frexp(value)
|
|
62
|
+
const reconstructed = Ldexp(frac, exp)
|
|
63
|
+
expect(reconstructed).toBeCloseTo(value, 10)
|
|
64
|
+
})
|
|
65
|
+
|
|
64
66
|
// Test negative values
|
|
65
|
-
testValues.forEach(value => {
|
|
66
|
-
const [frac, exp] = Frexp(-value)
|
|
67
|
-
const reconstructed = Ldexp(frac, exp)
|
|
68
|
-
expect(reconstructed).toBeCloseTo(-value, 10)
|
|
69
|
-
})
|
|
70
|
-
})
|
|
67
|
+
testValues.forEach((value) => {
|
|
68
|
+
const [frac, exp] = Frexp(-value)
|
|
69
|
+
const reconstructed = Ldexp(frac, exp)
|
|
70
|
+
expect(reconstructed).toBeCloseTo(-value, 10)
|
|
71
|
+
})
|
|
72
|
+
})
|
|
71
73
|
|
|
72
74
|
it('should handle large exponents', () => {
|
|
73
75
|
// Test with large positive exponent
|
|
74
|
-
expect(Ldexp(0.5, 10)).toBe(512)
|
|
75
|
-
expect(Ldexp(1, 10)).toBe(1024)
|
|
76
|
-
|
|
76
|
+
expect(Ldexp(0.5, 10)).toBe(512) // 0.5 × 2^10 = 512
|
|
77
|
+
expect(Ldexp(1, 10)).toBe(1024) // 1 × 2^10 = 1024
|
|
78
|
+
|
|
77
79
|
// Test with large negative exponent
|
|
78
|
-
expect(Ldexp(1, -10)).toBeCloseTo(1/1024, 10)
|
|
79
|
-
expect(Ldexp(2, -10)).toBeCloseTo(2/1024, 10)
|
|
80
|
-
})
|
|
80
|
+
expect(Ldexp(1, -10)).toBeCloseTo(1 / 1024, 10) // 1 × 2^-10 = 1/1024
|
|
81
|
+
expect(Ldexp(2, -10)).toBeCloseTo(2 / 1024, 10) // 2 × 2^-10 = 2/1024
|
|
82
|
+
})
|
|
81
83
|
|
|
82
84
|
it('should handle very large exponents that cause overflow', () => {
|
|
83
85
|
// Very large positive exponent should cause overflow to infinity
|
|
84
|
-
expect(Ldexp(1, 1024)).toBe(Number.POSITIVE_INFINITY)
|
|
85
|
-
expect(Ldexp(2, 1023)).toBe(Number.POSITIVE_INFINITY)
|
|
86
|
-
|
|
86
|
+
expect(Ldexp(1, 1024)).toBe(Number.POSITIVE_INFINITY)
|
|
87
|
+
expect(Ldexp(2, 1023)).toBe(Number.POSITIVE_INFINITY)
|
|
88
|
+
|
|
87
89
|
// Very large negative exponent should cause underflow to zero or very small number
|
|
88
90
|
const result = Ldexp(1, -1024)
|
|
89
91
|
expect(result).toBeLessThan(1e-300)
|
|
90
92
|
expect(result).toBeGreaterThanOrEqual(0)
|
|
91
|
-
})
|
|
93
|
+
})
|
|
92
94
|
|
|
93
95
|
it('should handle fractional inputs correctly', () => {
|
|
94
|
-
expect(Ldexp(0.75, 2)).toBe(3)
|
|
95
|
-
expect(Ldexp(0.25, 3)).toBe(2)
|
|
96
|
-
expect(Ldexp(1.5, 1)).toBe(3)
|
|
97
|
-
expect(Ldexp(1.25, 2)).toBe(5)
|
|
98
|
-
})
|
|
96
|
+
expect(Ldexp(0.75, 2)).toBe(3) // 0.75 × 2^2 = 3
|
|
97
|
+
expect(Ldexp(0.25, 3)).toBe(2) // 0.25 × 2^3 = 2
|
|
98
|
+
expect(Ldexp(1.5, 1)).toBe(3) // 1.5 × 2^1 = 3
|
|
99
|
+
expect(Ldexp(1.25, 2)).toBe(5) // 1.25 × 2^2 = 5
|
|
100
|
+
})
|
|
99
101
|
|
|
100
102
|
it('should be equivalent to frac * Math.pow(2, exp)', () => {
|
|
101
103
|
const testCases = [
|
|
102
|
-
[0.5, 1],
|
|
103
|
-
[0.
|
|
104
|
-
|
|
104
|
+
[0.5, 1],
|
|
105
|
+
[0.5, 2],
|
|
106
|
+
[0.5, -1],
|
|
107
|
+
[1, 5],
|
|
108
|
+
[1.5, 3],
|
|
109
|
+
[0.25, 4],
|
|
110
|
+
[-0.5, 2],
|
|
111
|
+
[-1, -3],
|
|
112
|
+
[2.5, -2],
|
|
113
|
+
]
|
|
105
114
|
|
|
106
115
|
testCases.forEach(([frac, exp]) => {
|
|
107
|
-
expect(Ldexp(frac, exp)).toBeCloseTo(frac * Math.pow(2, exp), 10)
|
|
108
|
-
})
|
|
109
|
-
})
|
|
110
|
-
})
|
|
116
|
+
expect(Ldexp(frac, exp)).toBeCloseTo(frac * Math.pow(2, exp), 10)
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
})
|
|
111
120
|
|
|
112
121
|
describe('ldexp (lowercase)', () => {
|
|
113
122
|
it('should work identically to Ldexp', () => {
|
|
114
123
|
const testCases = [
|
|
115
|
-
[0.5, 1],
|
|
116
|
-
[0.
|
|
117
|
-
|
|
124
|
+
[0.5, 1],
|
|
125
|
+
[0.5, 2],
|
|
126
|
+
[0.5, -1],
|
|
127
|
+
[1, 5],
|
|
128
|
+
[1.5, 3],
|
|
129
|
+
[0.25, 4],
|
|
130
|
+
[-0.5, 2],
|
|
131
|
+
[-1, -3],
|
|
132
|
+
[0, 5],
|
|
133
|
+
[-0, 5],
|
|
134
|
+
]
|
|
118
135
|
|
|
119
136
|
testCases.forEach(([frac, exp]) => {
|
|
120
|
-
expect(ldexp(frac, exp)).toBe(Ldexp(frac, exp))
|
|
121
|
-
})
|
|
122
|
-
|
|
137
|
+
expect(ldexp(frac, exp)).toBe(Ldexp(frac, exp))
|
|
138
|
+
})
|
|
139
|
+
|
|
123
140
|
// Test special cases
|
|
124
|
-
expect(ldexp(Inf(1), 5)).toBe(Ldexp(Inf(1), 5))
|
|
125
|
-
expect(ldexp(Inf(-1), 5)).toBe(Ldexp(Inf(-1), 5))
|
|
126
|
-
expect(IsNaN(ldexp(GoNaN(), 5))).toBe(IsNaN(Ldexp(GoNaN(), 5)))
|
|
127
|
-
})
|
|
128
|
-
})
|
|
141
|
+
expect(ldexp(Inf(1), 5)).toBe(Ldexp(Inf(1), 5))
|
|
142
|
+
expect(ldexp(Inf(-1), 5)).toBe(Ldexp(Inf(-1), 5))
|
|
143
|
+
expect(IsNaN(ldexp(GoNaN(), 5))).toBe(IsNaN(Ldexp(GoNaN(), 5)))
|
|
144
|
+
})
|
|
145
|
+
})
|
|
@@ -6,15 +6,15 @@ describe('Lgamma', () => {
|
|
|
6
6
|
const [lgamma1, sign1] = Lgamma(1)
|
|
7
7
|
expect(lgamma1).toBe(0)
|
|
8
8
|
expect(sign1).toBe(1)
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
const [lgamma2, sign2] = Lgamma(2)
|
|
11
11
|
expect(lgamma2).toBe(0)
|
|
12
12
|
expect(sign2).toBe(1)
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
const [lgamma3, sign3] = Lgamma(3)
|
|
15
15
|
expect(lgamma3).toBeCloseTo(Math.log(2), 14)
|
|
16
16
|
expect(sign3).toBe(1)
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
const [lgamma4, sign4] = Lgamma(4)
|
|
19
19
|
expect(lgamma4).toBeCloseTo(Math.log(6), 14)
|
|
20
20
|
expect(sign4).toBe(1)
|
|
@@ -25,7 +25,7 @@ describe('Lgamma', () => {
|
|
|
25
25
|
// Relax tolerance for half-integers due to JavaScript precision limits
|
|
26
26
|
expect(lgamma05).toBeCloseTo(Math.log(Math.sqrt(Math.PI)), 6)
|
|
27
27
|
expect(sign05).toBe(1)
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
const [lgamma15, sign15] = Lgamma(1.5)
|
|
30
30
|
expect(lgamma15).toBeCloseTo(-0.1207822376352452, 6)
|
|
31
31
|
expect(sign15).toBe(1)
|
|
@@ -36,9 +36,9 @@ describe('Lgamma', () => {
|
|
|
36
36
|
// Relax tolerance for negative values due to JavaScript precision limits
|
|
37
37
|
expect(lgamma_05).toBeCloseTo(1.265512123484645, 5)
|
|
38
38
|
expect(sign_05).toBe(-1)
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
const [lgamma_15, sign_15] = Lgamma(-1.5)
|
|
41
|
-
expect(lgamma_15).toBeCloseTo(Math.log(4 * Math.sqrt(Math.PI) / 3), 5)
|
|
41
|
+
expect(lgamma_15).toBeCloseTo(Math.log((4 * Math.sqrt(Math.PI)) / 3), 5)
|
|
42
42
|
expect(sign_15).toBe(1)
|
|
43
43
|
})
|
|
44
44
|
|
|
@@ -46,11 +46,11 @@ describe('Lgamma', () => {
|
|
|
46
46
|
const [lgammaInf, signInf] = Lgamma(Number.POSITIVE_INFINITY)
|
|
47
47
|
expect(lgammaInf).toBe(Number.POSITIVE_INFINITY)
|
|
48
48
|
expect(signInf).toBe(1)
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
const [lgammaNegInf, signNegInf] = Lgamma(Number.NEGATIVE_INFINITY)
|
|
51
51
|
expect(lgammaNegInf).toBe(Number.NEGATIVE_INFINITY)
|
|
52
52
|
expect(signNegInf).toBe(1)
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
const [lgammaNaN, signNaN] = Lgamma(Number.NaN)
|
|
55
55
|
expect(Number.isNaN(lgammaNaN)).toBe(true)
|
|
56
56
|
// Allow either NaN or finite value for sign as implementations may vary
|
|
@@ -62,7 +62,7 @@ describe('Lgamma', () => {
|
|
|
62
62
|
// Allow either NaN or very large values as implementations may vary
|
|
63
63
|
expect(Number.isNaN(lgamma_1) || Math.abs(lgamma_1) > 1e10).toBe(true)
|
|
64
64
|
expect(Number.isNaN(sign_1) || Number.isFinite(sign_1)).toBe(true)
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
const [lgamma_2, sign_2] = Lgamma(-2)
|
|
67
67
|
expect(Number.isNaN(lgamma_2) || Math.abs(lgamma_2) > 1e10).toBe(true)
|
|
68
68
|
expect(Number.isNaN(sign_2) || Number.isFinite(sign_2)).toBe(true)
|
|
@@ -99,4 +99,4 @@ describe('Lgamma', () => {
|
|
|
99
99
|
const expected = Math.log(Math.PI / Math.sin(Math.PI * x))
|
|
100
100
|
expect(lgamma_x + lgamma_1_minus_x).toBeCloseTo(expected, 5)
|
|
101
101
|
})
|
|
102
|
-
})
|
|
102
|
+
})
|
package/gs/math/log.gs.test.ts
CHANGED
package/gs/math/log10.gs.test.ts
CHANGED
package/gs/math/log1p.gs.test.ts
CHANGED
|
@@ -37,7 +37,7 @@ describe('Log1p', () => {
|
|
|
37
37
|
const x = 1e-15
|
|
38
38
|
const log1pResult = Log1p(x)
|
|
39
39
|
const logResult = Math.log(1 + x)
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
// For very small x, log1p should be more accurate
|
|
42
42
|
expect(Math.abs(log1pResult - x)).toBeLessThan(Math.abs(logResult - x))
|
|
43
43
|
})
|
|
@@ -52,4 +52,4 @@ describe('log1p', () => {
|
|
|
52
52
|
expect(Number.isNaN(log1p(Number.NaN))).toBe(true)
|
|
53
53
|
expect(Number.isNaN(log1p(-2))).toBe(true)
|
|
54
54
|
})
|
|
55
|
-
})
|
|
55
|
+
})
|
package/gs/math/logb.gs.test.ts
CHANGED
package/gs/math/mod.gs.test.ts
CHANGED
|
@@ -35,7 +35,7 @@ describe('Mod', () => {
|
|
|
35
35
|
expect(Number.isNaN(Mod(Number.NaN, 3))).toBe(true)
|
|
36
36
|
expect(Number.isNaN(Mod(5, 0))).toBe(true)
|
|
37
37
|
expect(Number.isNaN(Mod(5, Number.NaN))).toBe(true)
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
expect(Mod(5, Number.POSITIVE_INFINITY)).toBe(5)
|
|
40
40
|
expect(Mod(5, Number.NEGATIVE_INFINITY)).toBe(5)
|
|
41
41
|
expect(Mod(-5, Number.POSITIVE_INFINITY)).toBe(-5)
|
|
@@ -61,4 +61,4 @@ describe('mod', () => {
|
|
|
61
61
|
expect(mod(5.5, 2)).toBe(Mod(5.5, 2))
|
|
62
62
|
expect(Number.isNaN(mod(5, 0))).toBe(Number.isNaN(Mod(5, 0)))
|
|
63
63
|
})
|
|
64
|
-
})
|
|
64
|
+
})
|
package/gs/math/modf.gs.test.ts
CHANGED
|
@@ -18,7 +18,7 @@ describe('Modf', () => {
|
|
|
18
18
|
const [int, frac] = Modf(0)
|
|
19
19
|
expect(int).toBe(0)
|
|
20
20
|
expect(frac).toBe(0)
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
const [intNeg, fracNeg] = Modf(-0)
|
|
23
23
|
expect(Object.is(intNeg, -0)).toBe(true)
|
|
24
24
|
expect(fracNeg === 0 || Object.is(fracNeg, -0)).toBe(true)
|
|
@@ -28,7 +28,7 @@ describe('Modf', () => {
|
|
|
28
28
|
const [int, frac] = Modf(5)
|
|
29
29
|
expect(int).toBe(5)
|
|
30
30
|
expect(frac).toBe(0)
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
const [intNeg, fracNeg] = Modf(-5)
|
|
33
33
|
expect(intNeg).toBe(-5)
|
|
34
34
|
expect(fracNeg === 0 || Object.is(fracNeg, -0)).toBe(true)
|
|
@@ -38,11 +38,11 @@ describe('Modf', () => {
|
|
|
38
38
|
const [intPosInf, fracPosInf] = Modf(Number.POSITIVE_INFINITY)
|
|
39
39
|
expect(intPosInf).toBe(Number.POSITIVE_INFINITY)
|
|
40
40
|
expect(Number.isNaN(fracPosInf)).toBe(true)
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
const [intNegInf, fracNegInf] = Modf(Number.NEGATIVE_INFINITY)
|
|
43
43
|
expect(intNegInf).toBe(Number.NEGATIVE_INFINITY)
|
|
44
44
|
expect(Number.isNaN(fracNegInf)).toBe(true)
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
const [intNaN, fracNaN] = Modf(Number.NaN)
|
|
47
47
|
expect(Number.isNaN(intNaN)).toBe(true)
|
|
48
48
|
expect(Number.isNaN(fracNaN)).toBe(true)
|
|
@@ -52,7 +52,7 @@ describe('Modf', () => {
|
|
|
52
52
|
const [int1, frac1] = Modf(2.5)
|
|
53
53
|
expect(Math.sign(int1)).toBe(1)
|
|
54
54
|
expect(Math.sign(frac1)).toBe(1)
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
const [int2, frac2] = Modf(-2.5)
|
|
57
57
|
expect(Math.sign(int2)).toBe(-1)
|
|
58
58
|
expect(Math.sign(frac2)).toBe(-1)
|
|
@@ -71,10 +71,10 @@ describe('modf', () => {
|
|
|
71
71
|
const [int2, frac2] = Modf(3.14)
|
|
72
72
|
expect(int1).toBe(int2)
|
|
73
73
|
expect(frac1).toBe(frac2)
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
const [int3, frac3] = modf(-3.14)
|
|
76
76
|
const [int4, frac4] = Modf(-3.14)
|
|
77
77
|
expect(int3).toBe(int4)
|
|
78
78
|
expect(frac3).toBe(frac4)
|
|
79
79
|
})
|
|
80
|
-
})
|
|
80
|
+
})
|