aboutsummaryrefslogtreecommitdiff
path: root/tests/tmath.nim
blob: 8f947b26f5f2bec725f96526ac7d1394e7b481d7 (plain)
1
2
3
4
5
6
7
8
9
10
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
import unittest
import nimterop/cimport

cOverride:
  type
    locale_t = object
    mingw_ldbl_type_t = object
    mingw_dbl_type_t = object

when defined(Windows):
  cOverride:
    type
      complex = object

static:
  when (NimMajor, NimMinor, NimPatch) < (1, 0, 0):
    # FP_ILOGB0 and FP_ILOGBNAN are casts that are unsupported
    # on lower Nim VMs
    cSkipSymbol @["math_errhandling", "FP_ILOGB0", "FP_ILOGBNAN"]
  else:
    cSkipSymbol @["math_errhandling"]
  cDisableCaching()
  cAddStdDir()

cPlugin:
  import strutils

  proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
    sym.name = sym.name.strip(chars={'_'}).replace("__", "_")

const FLAGS {.strdefine.} = ""
cImport(cSearchPath("math.h"), flags = FLAGS)

check sin(5) == -0.9589242746631385
check abs(-5) == 5
check sqrt(4.00) == 2.0