1 # This file is part of NIT ( http://www.nitlanguage.org ).
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 module test_native_gmp
is test
28 fun before_test
is before
do
36 fun after_test
is after
do
48 assert(res
.cmp_si
(30) == 0)
55 assert(res
.cmp_si
(30) == 0)
62 assert(res
.cmp_si
(10) == 0)
69 assert(res
.cmp_si
(10) == 0)
76 assert(res
.cmp_si
(20) == 0)
82 assert(res
.cmp_si
(40) == 0)
88 assert(res
.cmp_si
(-10) == 0)
94 assert(res
.cmp_si
(10) == 0)
101 assert(res
.cmp_si
(5) == 0)
104 fun test_tdiv_q_ui
do
107 op1
.tdiv_q_ui
(res
, ui
)
108 assert(res
.cmp_si
(1) == 0)
115 assert(res
.cmp_si
(1) == 0)
122 assert(res
.cmp_si
(0) == 0)
125 fun test_probab_prime_p
do
127 assert(op1
.probab_prime_p
(10i32
) == 2)
130 fun test_nextprime
do
133 assert(res
.cmp_si
(11) == 0)
140 assert(res
.cmp_si
(4) == 0)
147 assert(res
.cmp_si
(10) == 0)
153 assert(op1
.cmp
(op2
) == 0)
158 assert(op1
.cmp_si
(30) == 0)
164 assert(op1
.cmp
(op2
) == 0)
169 assert(op1
.cmp_si
(30) == 0)
174 assert(op1
.cmp_si
(3) == 0)
180 assert(op1
.cmp_si
(30) == 0)
184 op1
.set_str
("30".to_cstring
, 10i32
)
185 assert(op1
.cmp_si
(30) == 0)
192 assert(op1
.cmp_si
(20) == 0 and op2
.cmp_si
(10) == 0)
197 assert(op1
.get_si
== 12)
202 assert(op1
.get_d
== 12.0)
207 assert(op1
.get_str
(10i32
).to_s
== "12")
219 fun before_test
is before
do
226 fun after_test
is after
do
237 assert(res
.cmp_si
(10, 1) == 0)
244 assert(res
.cmp_si
(10, 3) == 0)
251 assert(res
.cmp_si
(100, 3) == 0)
258 assert(res
.cmp_si
(5, 3) == 0)
264 assert(res
.cmp_si
(-10, 3) == 0)
270 assert(res
.cmp_si
(10, 3) == 0)
276 assert(res
.cmp_si
(3, 10) == 0)
282 assert(res
.cmp
(op1
) == 0)
288 assert(res
.cmp_si
(10, 1) == 0)
293 assert(res
.cmp_si
(10, 3) == 0)
298 assert(res
.cmp_si
(1, 2) == 0)
302 res
.set_str
"1/2".to_cstring
303 assert(res
.cmp_si
(1, 2) == 0)
309 assert(res
.cmp_si
(10, 3) == 0)
314 assert(res
.get_d
== 0.5)
319 assert(res
.get_str
(10i32
).to_s
== "1/2")
325 assert(op1
.cmp
(op2
) == 0)
331 # assert(op1.cmp_z(l) == 0)
336 assert(op1
.cmp_si
(10, 3) == 0)
342 assert op1
.equal
(op2
)
348 assert(op1
.numref
.cmp
(l
) == 0)
354 assert(op1
.denref
.cmp
(l
) == 0)