forked from M-Labs/nac3
1
0
Fork 0

nac3standalone: add test for abs function

This commit is contained in:
ychenfo 2022-03-08 23:21:58 +08:00
parent 5006028e2d
commit 60b3807ab3
2 changed files with 26 additions and 1 deletions

View File

@ -40,7 +40,9 @@ pub extern "C" fn output_uint64(x: u64) {
#[no_mangle] #[no_mangle]
pub extern "C" fn output_float64(x: f64) { pub extern "C" fn output_float64(x: f64) {
println!("{}", x); // debug output to preserve the digits after the decimal points
// to match python `print` function
println!("{:?}", x);
} }
#[no_mangle] #[no_mangle]

View File

@ -65,4 +65,27 @@ def run() -> int32:
output_float64(max(-12.234, 3.23)) output_float64(max(-12.234, 3.23))
output_float64(max(0.1, 12.3)) output_float64(max(0.1, 12.3))
output_float64(max(1.1, 1.1)) output_float64(max(1.1, 1.1))
# abs ===========
output_int32(int32(abs(False)))
output_int32(int32(abs(True)))
output_int32(abs(0))
output_int32(abs(-3))
output_int32(abs(2))
output_int64(abs(int64(-12)))
output_int64(abs(int64(0)))
output_int64(abs(int64(2)))
output_uint32(abs(uint32(0)))
output_uint32(abs(uint32(24)))
output_uint64(abs(uint64(0)))
output_uint64(abs(uint64(24)))
output_float64(abs(-12.234))
output_float64(abs(-0.0))
output_float64(abs(1.1))
return 0 return 0