UNPKG

969 Btext/coffeescriptView Raw
1test_madd = ->
2 i = 0
3 if DEBUG then console.log("test madd")
4 m = mtotal
5 for i in [-100...100]
6 for j in [-100...100]
7 test_maddf(i, j, i + j)
8 #if (m != mtotal)
9 # logout("memory leak\n")
10 # errout()
11 logout("ok\n")
12
13test_maddf = (na, nb, nc) ->
14
15 a = mint(na)
16 b = mint(nb)
17 c = mint(nc)
18
19 d = madd(a, b)
20
21 if (mcmp(c, d) == 0)
22 return
23 else
24 throw new Error("test_maddf")
25
26 #sprintf(logbuf, "%d %d %d %d\n", na, nb, nc, *d * MSIGN(d))
27 logout(logbuf)
28 errout()
29
30test_msub = ->
31 i = 0
32 logout("test msub\n")
33 m = mtotal
34 for i in [-100..100]
35 for j in [-100..100]
36 test_msubf(i, j, i - j)
37 if (m != mtotal)
38 logout("memory leak\n")
39 errout()
40 logout("ok\n")
41
42test_msubf = (na, nb, nc) ->
43 #unsigned int *a, *b, *c, *d
44
45 a = mint(na)
46 b = mint(nb)
47 c = mint(nc)
48
49 d = msub(a, b)
50
51 if (mcmp(c, d) == 0)
52 #mfree(a)
53 #mfree(b)
54 #mfree(c)
55 #mfree(d)
56 return
57
58 #sprintf(logbuf, "%d %d %d %d\n", na, nb, nc, *d * MSIGN(d))
59 logout(logbuf)
60 errout()
61
62#endif