| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
use quasi_declare::declare; |
| 11 |
use quasi_router::stage::Plan; |
| 12 |
|
| 13 |
declare! { |
| 14 |
|
| 15 |
#[constant] |
| 16 |
pub shape label(text: &str) -> Node; |
| 17 |
|
| 18 |
text text; |
| 19 |
} |
| 20 |
|
| 21 |
declare! { |
| 22 |
|
| 23 |
#[staged] |
| 24 |
pub shape panel() -> Node; |
| 25 |
|
| 26 |
region "panel" as Pane { |
| 27 |
include label("written down"); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
#[test] |
| 32 |
fn a_constant_include_of_a_literal_lands_in_the_staged_twin() { |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
let rendered = format!("{:?}", panel_staged(&Plan::full(1))); |
| 37 |
|
| 38 |
assert!( |
| 39 |
rendered.contains("written down"), |
| 40 |
"the literal did not survive the include boundary: {rendered}" |
| 41 |
); |
| 42 |
assert!( |
| 43 |
!rendered.contains("ZQH"), |
| 44 |
"a sentinel stood in for a value nothing varies: {rendered}" |
| 45 |
); |
| 46 |
} |
| 47 |
|
| 48 |
#[test] |
| 49 |
fn the_promise_leaves_the_shape_itself_alone() { |
| 50 |
|
| 51 |
|
| 52 |
assert_eq!(label("same"), label_constant("same")); |
| 53 |
} |
| 54 |
|
| 55 |
#[test] |
| 56 |
fn a_staged_shape_answers_for_nothing_when_every_include_is_constant() { |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
assert_eq!(PANEL_STAGED.sites, 0); |
| 61 |
assert_eq!(PANEL_STAGED.holes, 0); |
| 62 |
} |
| 63 |
|