Files
lean4/tests/elab/net_addr.lean
Garmelon 08eb78a5b2 chore: switch to new test/bench suite (#12590)
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.
2026-02-25 13:51:53 +00:00

40 lines
1.1 KiB
Lean4

import Std.Net.Addr
open Std.Net
/-- info: true -/
#guard_msgs in
#eval (IPv4Addr.ofParts 192 168 178 120).toString == "192.168.178.120"
/-- info: true -/
#guard_msgs in
#eval (IPv4Addr.ofParts 1 2 3 4).toString == "1.2.3.4"
/-- info: true -/
#guard_msgs in
#eval (IPv6Addr.ofParts 0xdead 0xbeef 0 0 0 0 0 0).toString == "dead:beef::"
/-- info: true -/
#guard_msgs in
#eval (IPv6Addr.ofParts 0x1234 0x5678 0x9abc 0xdef1 0x4321 0x8765 0xcba9 0x1fed).toString == "1234:5678:9abc:def1:4321:8765:cba9:1fed"
/-- info: true -/
#guard_msgs in
#eval IPv4Addr.ofString "1.2.3.4" == some (IPv4Addr.ofParts 1 2 3 4)
/-- info: true -/
#guard_msgs in
#eval IPv4Addr.ofString "192.168.300.120" |>.isNone
/-- info: true -/
#guard_msgs in
#eval IPv6Addr.ofString "dead:beef::" == some (IPv6Addr.ofParts 0xdead 0xbeef 0 0 0 0 0 0)
/-- info: true -/
#guard_msgs in
#eval IPv6Addr.ofString "1234:5678:9abc:def1:4321:8765:cba9:1fed" == some (IPv6Addr.ofParts 0x1234 0x5678 0x9abc 0xdef1 0x4321 0x8765 0xcba9 0x1fed)
/-- info: true -/
#guard_msgs in
#eval IPv6Addr.ofString "dead:beef::badaddress" |>.isNone