//! Every case of `packages/core/__tests__/engine/memoryOrder.test.ts`.usesuper::*;fn entry(slug: &str, position: f64, pinned: bool) -> Positioned {Positioned { pinned, position, slug: slug.to_string(), }}fn sorted(mut rows: Vec<Positioned>) -> Vec<String> { rows.sort_by(position_order); rows.into_iter().map(|r| r.slug).collect()}#[test]fn puts_pinned_entries_first_whatever_their_position() { assert_eq!( sorted(vec![entry("a", 1000.0, false), entry("p", 9000.0, true)]), ["p", "a"] );}#[test]fn reads_the_owners_arrangement_not_the_clock() { assert_eq!( sorted(vec![ entry("c", 3000.0, false), entry("a", 1000.0, false), entry("b", 2000.0, false) ]), ["a", "b", "c"] );}#[test]fn breaks_a_tie_by_slug_so_the_order_is_total() { assert_eq!( sorted(vec![entry("b", 1000.0, false), entry("a", 1000.0, false)]), ["a", "b"] );}#[test]fn lands_halfway_between_two_neighbours() { assert_eq!(position_between(Some(1000.0), Some(2000.0)), Some(1500.0));}#[test]fn appends_a_step_past_the_last_row_when_there_is_nothing_after() { assert_eq!( position_between(Some(3000.0), None),Some(3000.0 + POSITION_STEP) );}#[test]fn takes_a_step_before_the_first_row_when_there_is_nothing_before() { assert_eq!( position_between(None, Some(1000.0)),Some(1000.0 - POSITION_STEP) );}#[test]fn is_the_first_step_in_an_empty_list() { assert_eq!(position_between(None, None), Some(POSITION_STEP));}#[test]fn answers_none_when_the_gap_has_run_out_of_float_so_the_caller_renumbers() {let before = 1.0_f64;// The next double above 1.let after = 1.0 + f64::EPSILON; assert_eq!(position_between(Some(before), Some(after)), None);}/// The step every append uses, pinned.////// It was two numbers: `MEMORY_POSITION_STEP` in `packages/store`'s migration/// ladder, which backfilled the positions, and `POSITION_STEP` here, which/// computes every position after that. A test read the first by path to hold/// them equal. Step 5i deleted the package and Rust's ladder has no position/// backfill, so there is one number — and it is pinned rather than compared,/// because a freshly migrated file's first appended entry lands in the MIDDLE/// of the list instead of at its end if it ever moves under one.#[test]fn the_position_step_is_the_one_declared_number() { assert_eq!(POSITION_STEP as i64, 1000);}