mirror of
https://github.com/leanprover/lean4.git
synced 2026-03-17 18:34:06 +00:00
This PR sets up the new integrated test/bench suite. It then migrates all benchmarks and some related tests to the new suite. There's also some documentation and some linting. For now, a lot of the old tests are left alone so this PR doesn't become even larger than it already is. Eventually, all tests should be migrated to the new suite though so there isn't a confusing mix of two systems.
52 lines
1.3 KiB
Lean4
52 lines
1.3 KiB
Lean4
/-- info: 2.100000 -/
|
|
#guard_msgs in
|
|
#eval (2.1 : Float32)
|
|
|
|
/-- info: 3.200000 -/
|
|
#guard_msgs in
|
|
#eval (2.1 : Float32) + 1.1
|
|
|
|
/-- info: 0.900000 -/
|
|
#guard_msgs in
|
|
#eval (2.1 : Float32) - 1.2
|
|
|
|
def test1 : IO Unit := do
|
|
IO.println ((2 : Float32).sin);
|
|
IO.println ((2 : Float32).cos);
|
|
IO.println ((2 : Float32).sqrt);
|
|
IO.println ((2 : Float32) ^ (100 : Float32));
|
|
|
|
/--
|
|
info: 0.909297
|
|
-0.416147
|
|
1.414214
|
|
1267650600228229401496703205376.000000
|
|
-/
|
|
#guard_msgs in
|
|
#eval test1
|
|
|
|
/-- info: 0.909297 -/
|
|
#guard_msgs in
|
|
#eval (2 : Float32).sin.toFloat
|
|
|
|
/-- info: 0.909297 -/
|
|
#guard_msgs in
|
|
#eval (2 : Float).sin.toFloat32
|
|
|
|
/-- info: 1606938044258990275541962092341162602522202993782792835301376.000000 -/
|
|
#guard_msgs in
|
|
#eval (2 : Float32).toFloat ^ (200 : Float32).toFloat
|
|
|
|
#guard (Float32.ofInt (-1 : Int)).toBits == 0xBF800000
|
|
|
|
-- 2^24 + 1 is the smallest Nat that can't be represented exactly in FP32 but can in FP64;
|
|
-- There are 23 bits of mantissa and an implicit leading 1. Additionally, powers of
|
|
-- 2 (within range) are exactly representable in either format.
|
|
-- This shows that we are not accidentally representing Float32 with 64 bits;
|
|
#guard
|
|
let n := Int.pow 2 24
|
|
(Float.ofInt n) - (Float32.ofInt n).toFloat == 0
|
|
#guard
|
|
let n := Int.pow 2 24 + 1
|
|
(Float.ofInt n) - (Float32.ofInt n).toFloat != 0
|