1 | test_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 |
|
9 |
|
10 |
|
11 | logout("ok\n")
|
12 |
|
13 | test_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 |
|
27 | logout(logbuf)
|
28 | errout()
|
29 |
|
30 | test_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 |
|
42 | test_msubf = (na, nb, nc) ->
|
43 |
|
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 |
|
53 |
|
54 |
|
55 |
|
56 | return
|
57 |
|
58 |
|
59 | logout(logbuf)
|
60 | errout()
|
61 |
|
62 |
|