Files
lean4/tests/elab/subarray_split.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

92 lines
2.0 KiB
Lean4

/-!
# Tests for Subarray Splitting
The tests in this file check the basic splitting operations on subarrays.
-/
def abc' := #['a', 'b', 'c']
def abc := abc'.toSubarray
/-!
## Split
Splitting at various indices yields all the input elements the right number of times.
-/
/-- info: (#[].toSubarray, #[1, 2, 3, 4].toSubarray) -/
#guard_msgs in
#eval (#[1,2,3,4].toSubarray.split 0)
/-- info: (#[1].toSubarray, #[2, 3, 4].toSubarray) -/
#guard_msgs in
#eval (#[1,2,3,4].toSubarray.split 1)
/-- info: (#[1, 2].toSubarray, #[3, 4].toSubarray) -/
#guard_msgs in
#eval (#[1,2,3,4].toSubarray.split 2)
/-- info: (#[1, 2, 3].toSubarray, #[4].toSubarray) -/
#guard_msgs in
#eval (#[1,2,3,4].toSubarray.split 3)
/-- info: (#[1, 2, 3, 4].toSubarray, #[].toSubarray) -/
#guard_msgs in
#eval (#[1,2,3,4].toSubarray.split 4, by decide)
/-- info: (#[2, 3].toSubarray, #[4].toSubarray) -/
#guard_msgs in
#eval (#[1,2,3,4].toSubarray (start := 1) |>.split 2, by decide)
/-- info: (#[].toSubarray, #['a', 'b', 'c'].toSubarray) -/
#guard_msgs in
#eval abc.split 0
/-- info: (#['a'].toSubarray, #['b', 'c'].toSubarray) -/
#guard_msgs in
#eval abc.split 1
/-- info: (#['a', 'b'].toSubarray, #['c'].toSubarray) -/
#guard_msgs in
#eval abc.split 2
/-- info: (#['a', 'b', 'c'].toSubarray, #[].toSubarray) -/
#guard_msgs in
#eval abc.split 3
/-!
## Take and Drop
-/
/-- info: #[].toSubarray -/
#guard_msgs in
#eval #[1,2,3].toSubarray.take 0
/-- info: #[1].toSubarray -/
#guard_msgs in
#eval #[1,2,3].toSubarray.take 1
/-- info: #[1, 2].toSubarray -/
#guard_msgs in
#eval #[1,2,3].toSubarray.take 2
/-- info: #[1, 2, 3].toSubarray -/
#guard_msgs in
#eval #[1,2,3].toSubarray.take 100
/-- info: #[1, 2, 3].toSubarray -/
#guard_msgs in
#eval #[1,2,3].toSubarray.drop 0
/-- info: #[2, 3].toSubarray -/
#guard_msgs in
#eval #[1,2,3].toSubarray.drop 1
/-- info: #[3].toSubarray -/
#guard_msgs in
#eval #[1,2,3].toSubarray.drop 2
/-- info: #[].toSubarray -/
#guard_msgs in
#eval #[1,2,3].toSubarray.drop 100