Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/cgp-macro-lib/src/parse/check_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Parse for CheckComponents {
let context_type: SimpleType = parse2(context_type.to_token_stream())?;

Ident::new(
&format!("__CanUse{}", context_type.name),
&format!("__Check{}", context_type.name),
context_type.span(),
)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,10 @@ pub struct Rectangle {
pub height: f64,
}

delegate_components! {
delegate_and_check_components! {
Rectangle {
#[check_params(f64)]
AreaCalculatorComponent:
RectangleArea,
}
}

check_components! {
Rectangle {
AreaCalculatorComponent: f64,
}
}
19 changes: 15 additions & 4 deletions crates/cgp-tests/tests/component_tests/cgp_impl/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub struct PlainRectangle {
pub height: f64,
}

delegate_components! {
delegate_and_check_components! {
PlainRectangle {
AreaCalculatorComponent:
RectangleAreaCalculator,
Expand All @@ -114,7 +114,7 @@ pub struct ScaledRectangle {
pub height: f64,
}

delegate_components! {
delegate_and_check_components! {
ScaledRectangle {
AreaCalculatorComponent:
ScaledAreaCalculator<RectangleAreaCalculator>,
Expand All @@ -126,7 +126,7 @@ pub struct PlainCircle {
pub radius: f64,
}

delegate_components! {
delegate_and_check_components! {
PlainCircle {
AreaCalculatorComponent:
CircleAreaCalculator,
Expand All @@ -139,13 +139,24 @@ pub struct ScaledCircle {
pub radius: f64,
}

delegate_components! {
delegate_and_check_components! {
ScaledCircle {
AreaCalculatorComponent:
ScaledAreaCalculator<CircleAreaCalculator>,
}
}

check_components! {
#[check_trait(CheckScaledRectangleProviders)]
#[check_providers(
RectangleAreaCalculator,
ScaledAreaCalculator<RectangleAreaCalculator>,
)]
ScaledRectangle {
AreaCalculatorComponent,
}
}

#[test]
fn test_scaled_area() {
let rectangle = PlainRectangle {
Expand Down
Loading