Cotton code
27 lines · 1.4 KB · RustRaw
//! Where the columns a person adds to a shipped table live (tools as//! packages, 137): the store adds them to the table `BUILTIN_STORES` names,//! and the tools read them from `builtin_store_table` — one table./// RULE: The store's table for each shipped table's added columns is the table the tools read them from (builtin_store_table), because two answers would write a value where no read finds it.#[test]fn the_store_and_the_tools_name_one_table_for_added_columns() {    let mut differ = Vec::new();    for (id, _) in cotton_store::schema::package_tables::builtin_shapes().expect("the shipped shapes") {        let tools = cotton_core::definitions::builtin_store_table(&id);        let store = cotton_store::schema::package_shape::BUILTIN_STORES.iter().find(|(of, _)| *of == id).map(|(_, table)| *table);        if tools != store {            differ.push(format!("{id}: tools read {tools:?}, the store adds to {store:?}"));        }    }    assert!(differ.is_empty(), "run the ignored print_builtin_stores into package_shape::BUILTIN_STORES: {differ:#?}");}#[test]#[ignore = "a generator: prints the store's BUILTIN_STORES"]fn print_builtin_stores() {    for (id, _) in cotton_store::schema::package_tables::builtin_shapes().unwrap() {        if let Some(store) = cotton_core::definitions::builtin_store_table(&id) {            println!("    (\"{id}\", \"{store}\"),");        }    }}