use repe_core::structs::{assert_listing_order, assert_no_endpoint_collision};
#[test]
fn an_order_naming_every_endpoint_passes() {
assert_listing_order(
&["a", "calc", "ratio"],
&["a"],
&[("calc", "fn(&self) -> u64")],
&["ratio"],
false,
);
}
#[test]
#[should_panic(expected = "names a key that is not an endpoint on this struct")]
fn an_order_naming_an_unknown_key_is_rejected() {
assert_listing_order(&["a", "typo"], &["a"], &[], &[], false);
}
#[test]
#[should_panic(expected = "is missing from `#[repe(listing_order(..))]`")]
fn an_order_omitting_a_method_is_rejected() {
assert_listing_order(&["a"], &["a"], &[("calc", "fn(&self) -> u64")], &[], false);
}
#[test]
#[should_panic(expected = "is missing from `#[repe(listing_order(..))]`")]
fn an_order_omitting_an_accessor_is_rejected() {
assert_listing_order(&["a"], &["a"], &[], &["ratio"], false);
}
#[test]
fn a_recovering_table_stands_every_check_down() {
assert_listing_order(&["a", "typo"], &["a"], &[], &[], true);
}
#[test]
#[should_panic(expected = "names a key that is not an endpoint on this struct")]
fn an_empty_table_that_is_not_recovering_is_still_checked() {
assert_listing_order(&["a", "typo"], &["a"], &[], &[], false);
}
#[test]
fn three_disjoint_endpoint_sets_pass() {
assert_no_endpoint_collision(&["a"], &[("calc", "fn(&self) -> u64")], &["ratio"]);
}
#[test]
#[should_panic(expected = "the struct's declaration wins dispatch")]
fn a_method_colliding_with_a_struct_declaration_is_rejected() {
assert_no_endpoint_collision(&["calc"], &[("calc", "fn(&self) -> u64")], &[]);
}
#[test]
#[should_panic(expected = "the struct's declaration wins dispatch")]
fn an_accessor_colliding_with_a_struct_declaration_is_rejected() {
assert_no_endpoint_collision(&["ratio"], &[], &["ratio"]);
}
#[test]
#[should_panic(expected = "one of them is unreachable")]
fn a_method_colliding_with_an_accessor_is_rejected() {
assert_no_endpoint_collision(&[], &[("ratio", "fn(&self) -> u64")], &["ratio"]);
}