From 81277927a963a1ec61d006c668a86fe611836d0a Mon Sep 17 00:00:00 2001
From: Nico Burns
Date: Mon, 16 Jan 2023 02:21:02 +0000
Subject: [PATCH 1/2] Fix justify content with margin test (error due to
differences in gentest setup between yoga and taffy
---
...fy_content_column_min_height_and_margin.rs | 33 ++++++++++++
...fy_content_colunn_max_height_and_margin.rs | 34 ++++++++++++
benches/generated/mod.rs | 4 ++
..._content_column_min_height_and_margin.html | 21 ++++++++
..._content_colunn_max_height_and_margin.html | 21 ++++++++
..._content_column_min_height_and_margin.html | 17 ------
..._content_colunn_max_height_and_margin.html | 17 ------
...fy_content_column_min_height_and_margin.rs | 53 ++++++++++++++++++
...fy_content_colunn_max_height_and_margin.rs | 54 +++++++++++++++++++
tests/generated/mod.rs | 2 +
10 files changed, 222 insertions(+), 34 deletions(-)
create mode 100644 benches/generated/justify_content_column_min_height_and_margin.rs
create mode 100644 benches/generated/justify_content_colunn_max_height_and_margin.rs
create mode 100644 test_fixtures/justify_content_column_min_height_and_margin.html
create mode 100644 test_fixtures/justify_content_colunn_max_height_and_margin.html
delete mode 100644 test_fixtures/xjustify_content_column_min_height_and_margin.html
delete mode 100644 test_fixtures/xjustify_content_colunn_max_height_and_margin.html
create mode 100644 tests/generated/justify_content_column_min_height_and_margin.rs
create mode 100644 tests/generated/justify_content_colunn_max_height_and_margin.rs
diff --git a/benches/generated/justify_content_column_min_height_and_margin.rs b/benches/generated/justify_content_column_min_height_and_margin.rs
new file mode 100644
index 000000000..206eca83f
--- /dev/null
+++ b/benches/generated/justify_content_column_min_height_and_margin.rs
@@ -0,0 +1,33 @@
+pub fn compute() {
+ #[allow(unused_imports)]
+ use taffy::prelude::*;
+ let mut taffy = taffy::Taffy::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(20f32),
+ height: taffy::style::Dimension::Points(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_direction: taffy::style::FlexDirection::Column,
+ justify_content: Some(taffy::style::JustifyContent::Center),
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) },
+ margin: taffy::geometry::Rect {
+ left: zero(),
+ right: zero(),
+ top: taffy::style::LengthPercentageAuto::Points(100f32),
+ bottom: zero(),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+}
diff --git a/benches/generated/justify_content_colunn_max_height_and_margin.rs b/benches/generated/justify_content_colunn_max_height_and_margin.rs
new file mode 100644
index 000000000..f6533d354
--- /dev/null
+++ b/benches/generated/justify_content_colunn_max_height_and_margin.rs
@@ -0,0 +1,34 @@
+pub fn compute() {
+ #[allow(unused_imports)]
+ use taffy::prelude::*;
+ let mut taffy = taffy::Taffy::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(20f32),
+ height: taffy::style::Dimension::Points(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_direction: taffy::style::FlexDirection::Column,
+ justify_content: Some(taffy::style::JustifyContent::Center),
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) },
+ max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(80f32) },
+ margin: taffy::geometry::Rect {
+ left: zero(),
+ right: zero(),
+ top: taffy::style::LengthPercentageAuto::Points(100f32),
+ bottom: zero(),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+}
diff --git a/benches/generated/mod.rs b/benches/generated/mod.rs
index dc6e01760..7b15259aa 100644
--- a/benches/generated/mod.rs
+++ b/benches/generated/mod.rs
@@ -561,11 +561,13 @@ mod grid_size_child_fixed_tracks;
mod justify_content_column_center;
mod justify_content_column_flex_end;
mod justify_content_column_flex_start;
+mod justify_content_column_min_height_and_margin;
mod justify_content_column_min_height_and_margin_bottom;
mod justify_content_column_min_height_and_margin_top;
mod justify_content_column_space_around;
mod justify_content_column_space_between;
mod justify_content_column_space_evenly;
+mod justify_content_colunn_max_height_and_margin;
mod justify_content_min_max;
mod justify_content_min_width_with_padding_child_width_greater_than_parent;
mod justify_content_min_width_with_padding_child_width_lower_than_parent;
@@ -1229,11 +1231,13 @@ fn benchmark(c: &mut Criterion) {
justify_content_column_center::compute();
justify_content_column_flex_end::compute();
justify_content_column_flex_start::compute();
+ justify_content_column_min_height_and_margin::compute();
justify_content_column_min_height_and_margin_bottom::compute();
justify_content_column_min_height_and_margin_top::compute();
justify_content_column_space_around::compute();
justify_content_column_space_between::compute();
justify_content_column_space_evenly::compute();
+ justify_content_colunn_max_height_and_margin::compute();
justify_content_min_max::compute();
justify_content_min_width_with_padding_child_width_greater_than_parent::compute();
justify_content_min_width_with_padding_child_width_lower_than_parent::compute();
diff --git a/test_fixtures/justify_content_column_min_height_and_margin.html b/test_fixtures/justify_content_column_min_height_and_margin.html
new file mode 100644
index 000000000..3fb17ffc2
--- /dev/null
+++ b/test_fixtures/justify_content_column_min_height_and_margin.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/justify_content_colunn_max_height_and_margin.html b/test_fixtures/justify_content_colunn_max_height_and_margin.html
new file mode 100644
index 000000000..a159d44a4
--- /dev/null
+++ b/test_fixtures/justify_content_colunn_max_height_and_margin.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/xjustify_content_column_min_height_and_margin.html b/test_fixtures/xjustify_content_column_min_height_and_margin.html
deleted file mode 100644
index d1716ad1b..000000000
--- a/test_fixtures/xjustify_content_column_min_height_and_margin.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
- Test description
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/test_fixtures/xjustify_content_colunn_max_height_and_margin.html b/test_fixtures/xjustify_content_colunn_max_height_and_margin.html
deleted file mode 100644
index 8d1a2d4ea..000000000
--- a/test_fixtures/xjustify_content_colunn_max_height_and_margin.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
- Test description
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tests/generated/justify_content_column_min_height_and_margin.rs b/tests/generated/justify_content_column_min_height_and_margin.rs
new file mode 100644
index 000000000..f98c9f98f
--- /dev/null
+++ b/tests/generated/justify_content_column_min_height_and_margin.rs
@@ -0,0 +1,53 @@
+#[test]
+fn justify_content_column_min_height_and_margin() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(20f32),
+ height: taffy::style::Dimension::Points(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_direction: taffy::style::FlexDirection::Column,
+ justify_content: Some(taffy::style::JustifyContent::Center),
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) },
+ margin: taffy::geometry::Rect {
+ left: zero(),
+ right: zero(),
+ top: taffy::style::LengthPercentageAuto::Points(100f32),
+ bottom: zero(),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 20f32, size.width);
+ assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 150f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.width);
+ assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node00).unwrap();
+ assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 20f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 20f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.x);
+ assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 15f32, location.y);
+}
diff --git a/tests/generated/justify_content_colunn_max_height_and_margin.rs b/tests/generated/justify_content_colunn_max_height_and_margin.rs
new file mode 100644
index 000000000..02bd315cd
--- /dev/null
+++ b/tests/generated/justify_content_colunn_max_height_and_margin.rs
@@ -0,0 +1,54 @@
+#[test]
+fn justify_content_colunn_max_height_and_margin() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(20f32),
+ height: taffy::style::Dimension::Points(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_direction: taffy::style::FlexDirection::Column,
+ justify_content: Some(taffy::style::JustifyContent::Center),
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) },
+ max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(80f32) },
+ margin: taffy::geometry::Rect {
+ left: zero(),
+ right: zero(),
+ top: taffy::style::LengthPercentageAuto::Points(100f32),
+ bottom: zero(),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 20f32, size.width);
+ assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 180f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.width);
+ assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 80f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node00).unwrap();
+ assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 20f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 20f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.x);
+ assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 30f32, location.y);
+}
diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs
index 829311ccb..67c98943a 100644
--- a/tests/generated/mod.rs
+++ b/tests/generated/mod.rs
@@ -560,11 +560,13 @@ mod grid_size_child_fixed_tracks;
mod justify_content_column_center;
mod justify_content_column_flex_end;
mod justify_content_column_flex_start;
+mod justify_content_column_min_height_and_margin;
mod justify_content_column_min_height_and_margin_bottom;
mod justify_content_column_min_height_and_margin_top;
mod justify_content_column_space_around;
mod justify_content_column_space_between;
mod justify_content_column_space_evenly;
+mod justify_content_colunn_max_height_and_margin;
mod justify_content_min_max;
mod justify_content_min_width_with_padding_child_width_greater_than_parent;
mod justify_content_min_width_with_padding_child_width_lower_than_parent;
From 141491dda203d3d7a9d9bc16e050932f2d6c2755 Mon Sep 17 00:00:00 2001
From: Nico Burns
Date: Mon, 16 Jan 2023 02:24:07 +0000
Subject: [PATCH 2/2] Fix
position_root_with_rtl_should_position_withoutdirection test
---
benches/generated/mod.rs | 2 +
...th_rtl_should_position_withoutdirection.rs | 22 +++++++++++
..._rtl_should_position_withoutdirection.html | 19 ++++++++++
..._rtl_should_position_withoutdirection.html | 15 --------
tests/generated/mod.rs | 1 +
...th_rtl_should_position_withoutdirection.rs | 37 +++++++++++++++++++
6 files changed, 81 insertions(+), 15 deletions(-)
create mode 100644 benches/generated/position_root_with_rtl_should_position_withoutdirection.rs
create mode 100644 test_fixtures/position_root_with_rtl_should_position_withoutdirection.html
delete mode 100644 test_fixtures/xposition_root_with_rtl_should_position_withoutdirection.html
create mode 100644 tests/generated/position_root_with_rtl_should_position_withoutdirection.rs
diff --git a/benches/generated/mod.rs b/benches/generated/mod.rs
index 7b15259aa..f7b7f74b3 100644
--- a/benches/generated/mod.rs
+++ b/benches/generated/mod.rs
@@ -683,6 +683,7 @@ mod percentage_size_based_on_parent_inner_size;
mod percentage_size_of_flex_basis;
mod percentage_width_height;
mod percentage_width_height_undefined_parent_size;
+mod position_root_with_rtl_should_position_withoutdirection;
mod relative_position_should_not_nudge_siblings;
mod rounding_flex_basis_flex_grow_row_prime_number_width;
mod rounding_flex_basis_flex_grow_row_width_of_100;
@@ -1353,6 +1354,7 @@ fn benchmark(c: &mut Criterion) {
percentage_size_of_flex_basis::compute();
percentage_width_height::compute();
percentage_width_height_undefined_parent_size::compute();
+ position_root_with_rtl_should_position_withoutdirection::compute();
relative_position_should_not_nudge_siblings::compute();
rounding_flex_basis_flex_grow_row_prime_number_width::compute();
rounding_flex_basis_flex_grow_row_width_of_100::compute();
diff --git a/benches/generated/position_root_with_rtl_should_position_withoutdirection.rs b/benches/generated/position_root_with_rtl_should_position_withoutdirection.rs
new file mode 100644
index 000000000..aee006c59
--- /dev/null
+++ b/benches/generated/position_root_with_rtl_should_position_withoutdirection.rs
@@ -0,0 +1,22 @@
+pub fn compute() {
+ #[allow(unused_imports)]
+ use taffy::prelude::*;
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(52f32),
+ height: taffy::style::Dimension::Points(52f32),
+ },
+ inset: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentageAuto::Points(72f32),
+ right: auto(),
+ top: auto(),
+ bottom: auto(),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+}
diff --git a/test_fixtures/position_root_with_rtl_should_position_withoutdirection.html b/test_fixtures/position_root_with_rtl_should_position_withoutdirection.html
new file mode 100644
index 000000000..dd06ff5c5
--- /dev/null
+++ b/test_fixtures/position_root_with_rtl_should_position_withoutdirection.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/xposition_root_with_rtl_should_position_withoutdirection.html b/test_fixtures/xposition_root_with_rtl_should_position_withoutdirection.html
deleted file mode 100644
index bedbd0b21..000000000
--- a/test_fixtures/xposition_root_with_rtl_should_position_withoutdirection.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
- Test description
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs
index 67c98943a..5822cbd09 100644
--- a/tests/generated/mod.rs
+++ b/tests/generated/mod.rs
@@ -682,6 +682,7 @@ mod percentage_size_based_on_parent_inner_size;
mod percentage_size_of_flex_basis;
mod percentage_width_height;
mod percentage_width_height_undefined_parent_size;
+mod position_root_with_rtl_should_position_withoutdirection;
mod relative_position_should_not_nudge_siblings;
mod rounding_flex_basis_flex_grow_row_prime_number_width;
mod rounding_flex_basis_flex_grow_row_width_of_100;
diff --git a/tests/generated/position_root_with_rtl_should_position_withoutdirection.rs b/tests/generated/position_root_with_rtl_should_position_withoutdirection.rs
new file mode 100644
index 000000000..95b97d9fd
--- /dev/null
+++ b/tests/generated/position_root_with_rtl_should_position_withoutdirection.rs
@@ -0,0 +1,37 @@
+#[test]
+fn position_root_with_rtl_should_position_withoutdirection() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(52f32),
+ height: taffy::style::Dimension::Points(52f32),
+ },
+ inset: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentageAuto::Points(72f32),
+ right: auto(),
+ top: auto(),
+ bottom: auto(),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 52f32, size.width);
+ assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 52f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 52f32, size.width);
+ assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 52f32, size.height);
+ assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 72f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+}