diff --git a/NOTICE b/NOTICE index 7b7ce42..7ad4e25 100644 --- a/NOTICE +++ b/NOTICE @@ -18,3 +18,12 @@ MoonBit packages. This port is distributed under the same license, the Apache License, Version 2.0 (see LICENSE). It is not affiliated with or endorsed by Zed Industries. + +Third-party material: + +- conformance/chicle/upstream contains layout fixture tests from + Milky2018/moon_taffy 0.5.3 (Apache-2.0, Copyright 2025 International + Digital Economy Academy), which are derived from taffy's generated tests + (https://github.com/DioxusLabs/taffy, MIT). +- The layout package depends on Milky2018/chicle (Apache-2.0), fetched from + mooncakes.io; it is not vendored here. diff --git a/README.md b/README.md index 7933214..ea56089 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,13 @@ roadmap. | `experiments/gpui/scene` | `scene.rs`, `bounds_tree.rs` | Ported (primitives, draw ordering, layers, batching, replay) | | `experiments/gpui/font` | font descriptors in `text_system.rs` | Ported (`Font`, weights, styles, features, fallbacks) | | `experiments/gpui/style` | `style.rs`, `styled.rs`, Refineable, gpui_macros style helpers | Ported (`Style`/`StyleRefinement`, the full `Styled` fluent API) | +| `experiments/gpui/layout` | `taffy.rs` | Ported on [`Milky2018/chicle`](https://mooncakes.io/docs/Milky2018/chicle) (flexbox, grid, block) | ## Example Nothing renders yet. `src/examples/card` resolves a style written with -GPUI's fluent API, paints it into a `Scene` by hand, and prints the draw +GPUI's fluent API, lays the card and its (fake-measured) text out with the +layout engine, paints it into a `Scene`, and prints the layout and the draw batches: ```sh @@ -49,6 +51,12 @@ script or `src/style/styled.mbt`, then run: python3 tools/gen_style.py && moon fmt ``` +## Layout conformance + +`conformance/chicle` is a standalone module with 1,038 taffy layout fixtures +for the layout engine dependency. Run it before changing the chicle version: +`cd conformance/chicle && moon test --target all`. + ## Testing All packages are pure MoonBit and are tested on every backend: diff --git a/conformance/chicle/README.md b/conformance/chicle/README.md new file mode 100644 index 0000000..bf046b1 --- /dev/null +++ b/conformance/chicle/README.md @@ -0,0 +1,25 @@ +# Layout conformance suite + +1,038 layout fixtures, run against `Milky2018/chicle`, the layout engine +behind `experiments/gpui/layout`. They are taffy's generated layout fixtures +(flexbox, grid, block, measured leaves), as ported to MoonBit in +`Milky2018/moon_taffy@0.5.3` (`src/tests/upstream`). That package no longer +compiles on the current MoonBit toolchain; its successor, chicle, does. + +Run this suite before raising the chicle version in the root `moon.mod`: + +```sh +cd conformance/chicle +moon test --target all +``` + +As of chicle 0.6.3 and moon 0.1.20261119, all 1,038 tests pass on wasm, +wasm-gc, js and native, in about 40 seconds. The suite is kept outside the +main module so that `moon test` at the repository root stays fast. + +The only changes from upstream are the renames `TaffyTree` → `ChicleTree` +and `TaffyError` → `ChicleError`, and the import paths in `moon.pkg`. + +License: Apache-2.0. Copyright 2025 International Digital Economy Academy +(see the file headers). The fixtures derive from taffy +(https://github.com/DioxusLabs/taffy, MIT). diff --git a/conformance/chicle/moon.mod b/conformance/chicle/moon.mod new file mode 100644 index 0000000..ab3dc43 --- /dev/null +++ b/conformance/chicle/moon.mod @@ -0,0 +1,11 @@ +// Layout conformance suite for the layout engine dependency. Not part of the +// main module; run on demand (see README.md). +name = "experiments/gpui-layout-conformance" + +version = "0.1.0" + +license = "Apache-2.0" + +import { + "Milky2018/chicle@0.6.3", +} diff --git a/conformance/chicle/upstream/measure_child_with_flex_grow_test.mbt b/conformance/chicle/upstream/measure_child_with_flex_grow_test.mbt new file mode 100644 index 0000000..846fdb7 --- /dev/null +++ b/conformance/chicle/upstream/measure_child_with_flex_grow_test.mbt @@ -0,0 +1,45 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "measure_child_with_flex_grow (upstream: generated/flex/measure_child_with_flex_grow.rs)" { + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "H\u{200B}H\u{200B}H\u{200B}H\u{200B}H", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 50.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/measure_fixtures_test.mbt b/conformance/chicle/upstream/measure_fixtures_test.mbt new file mode 100644 index 0000000..1d35382 --- /dev/null +++ b/conformance/chicle/upstream/measure_fixtures_test.mbt @@ -0,0 +1,170 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +enum WritingMode { + Horizontal + Vertical +} + +///| +struct TextMeasure { + text_content : String + writing_mode : WritingMode +} + +///| +fn[T] unwrap_or_else(x : T?, fallback : () -> T) -> T { + match x { + Some(v) => v + None => fallback() + } +} + +///| +fn to_int_floor(x : Double) -> Int { + x.floor().to_int() +} + +///| +fn measure_text( + known_dimensions : Size[Double?], + available_space : Size[AvailableSpace], + _node_id : NodeId, + node_context : TextMeasure?, + _style : Style, +) -> Size[Double] { + let h_width = 10.0 + let h_height = 10.0 + // U+200B ZERO WIDTH SPACE + let zws = "\u{200B}" + match (known_dimensions.width, known_dimensions.height) { + (Some(w), Some(h)) => return Size(width=w, height=h) + _ => () + } + let ctx = match node_context { + Some(c) => c + None => return Size::zero() + } + let is_horizontal = match ctx.writing_mode { + Horizontal => true + Vertical => false + } + let mut saw_any = false + let mut min_line_length = 0 + let mut max_line_length = 0 + for seg in ctx.text_content.split(zws) { + saw_any = true + let len = seg.length() + if len > min_line_length { + min_line_length = len + } + max_line_length = max_line_length + len + } + if !saw_any { + return Size::zero() + } + let inline_known = if is_horizontal { + known_dimensions.width + } else { + known_dimensions.height + } + let block_known = if is_horizontal { + known_dimensions.height + } else { + known_dimensions.width + } + let inline_avail = if is_horizontal { + available_space.width + } else { + available_space.height + } + let min_inline = min_line_length.to_double() * h_width + let max_inline = max_line_length.to_double() * h_width + let inline_size = unwrap_or_else(inline_known, fn() { + match inline_avail { + AvailMinContent => min_inline + AvailMaxContent => max_inline + AvailDefinite(v) => if v < max_inline { v } else { max_inline } + } + }) + let inline_size = if inline_size > min_inline { + inline_size + } else { + min_inline + } + let block_size = unwrap_or_else(block_known, fn() { + match _style.aspect_ratio { + Some(ratio) => + if ratio > 0.0 { + if is_horizontal { + inline_size / ratio + } else { + inline_size * ratio + } + } else { + let inline_line_length = to_int_floor(inline_size / h_width) + let mut line_count = 1 + let mut current_line_length = 0 + for seg in ctx.text_content.split(zws) { + let len = seg.length() + if current_line_length + len > inline_line_length { + if current_line_length > 0 { + line_count = line_count + 1 + } + current_line_length = len + } else { + current_line_length = current_line_length + len + } + } + line_count.to_double() * h_height + } + None => { + let inline_line_length = to_int_floor(inline_size / h_width) + let mut line_count = 1 + let mut current_line_length = 0 + for seg in ctx.text_content.split(zws) { + let len = seg.length() + if current_line_length + len > inline_line_length { + if current_line_length > 0 { + line_count = line_count + 1 + } + current_line_length = len + } else { + current_line_length = current_line_length + len + } + } + line_count.to_double() * h_height + } + } + }) + if is_horizontal { + Size(width=inline_size, height=block_size) + } else { + Size(width=block_size, height=inline_size) + } +} + +///| +test "measure_text_vertical_smoke" { + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context(Style::default(), { + text_content: "H\u{200B}H\u{200B}H\u{200B}H\u{200B}H", + writing_mode: Vertical, + }) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 10.0) + assert_eq(layout.size.height, 50.0) +} diff --git a/conformance/chicle/upstream/moon.pkg b/conformance/chicle/upstream/moon.pkg new file mode 100644 index 0000000..b4017b2 --- /dev/null +++ b/conformance/chicle/upstream/moon.pkg @@ -0,0 +1,7 @@ +import { + "Milky2018/chicle/geometry" @geometry, + "Milky2018/chicle/style" @style, + "Milky2018/chicle/style_helpers" @style_helpers, + "Milky2018/chicle/tree" @tree, + "moonbitlang/core/json", +} diff --git a/conformance/chicle/upstream/prelude.mbt b/conformance/chicle/upstream/prelude.mbt new file mode 100644 index 0000000..7030519 --- /dev/null +++ b/conformance/chicle/upstream/prelude.mbt @@ -0,0 +1,159 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +pub using @geometry { + abstract_axis_block, + abstract_axis_inline, + type AvailableSpace, + type AbsoluteAxis, + type AbstractAxis, + type Line, + type Point, + type Rect, + type Size, +} + +///| +pub using @style { + length_percentage_auto_auto, + length_percentage_auto_length, + length_percentage_auto_percent, + length_percentage_length, + length_percentage_percent, + type AlignContent, + type AlignItems, + type AlignSelf, + type BoxSizing, + type Dimension, + type Display, + type FlexDirection, + type FlexWrap, + type GridAutoFlow, + type GridPlacement, + type GridTrackRepetition, + type JustifyContent, + type JustifyItems, + type JustifySelf, + type LengthPercentage, + type LengthPercentageAuto, + type MaxTrackSizingFunction, + type MinTrackSizingFunction, + type NonRepeatedTrackSizingFunction, + type Overflow, + type Position, + type Style, + type TrackSizingFunction, +} + +///| +pub using @style_helpers { + align_content_center, + align_content_end, + align_content_flex_end, + align_content_flex_start, + align_content_space_around, + align_content_space_between, + align_content_space_evenly, + align_content_start, + align_content_stretch, + align_items_baseline, + align_items_center, + align_items_end, + align_items_flex_end, + align_items_flex_start, + align_items_start, + align_items_stretch, + auto, + available_space_definite, + box_sizing_border_box, + box_sizing_content_box, + display_block, + display_flex, + display_grid, + display_none, + evenly_sized_tracks, + fit_content, + flex, + flex_direction_column, + flex_direction_column_reverse, + flex_direction_row, + flex_direction_row_reverse, + flex_wrap_no_wrap, + flex_wrap_wrap, + flex_wrap_wrap_reverse, + fr, + grid_auto_flow_column, + grid_auto_flow_column_dense, + grid_auto_flow_row, + grid_auto_flow_row_dense, + grid_max_content, + grid_min_content, + justify_content_center, + justify_content_end, + justify_content_flex_end, + justify_content_flex_start, + justify_content_space_around, + justify_content_space_between, + justify_content_space_evenly, + justify_content_start, + justify_content_stretch, + length, + line, + max_content, + max_track_auto, + max_track_fit_content, + max_track_fixed, + max_track_fraction, + max_track_max_content, + max_track_min_content, + min_content, + min_track_auto, + min_track_fixed, + min_track_max_content, + min_track_min_content, + minmax, + overflow_clip, + overflow_hidden, + overflow_scroll, + overflow_visible, + percent, + place_auto, + position_absolute, + position_relative, + repeat, + repeat_auto_fill, + repeat_auto_fit, + repeat_count, + repeated_track_sizing_function, + span, + track_sizing_function, + zero, +} + +///| +pub using @tree { + layout_input_for_compute_size, + layout_input_for_perform_layout, + requested_axis_from_absolute, + type Layout, + type LayoutInput, + type LayoutOutput, + type NodeId, + type RequestedAxis, + type RunMode, + type SizingMode, + type ChicleError, + type ChicleTree, +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part01_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part01_test.mbt new file mode 100644 index 0000000..5db04a0 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part01_test.mbt @@ -0,0 +1,1001 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 360.0) + assert_eq(c.size.height, 120.0) + assert_eq(c.location.x, 20.0) + assert_eq(c.location.y, 15.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=percent(0.05), right=auto(), top=percent(0.05), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 200.0) + assert_eq(c.size.height, 67.0) + assert_eq(c.location.x, 20.0) + assert_eq(c.location.y, 15.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_height_from_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_height_from_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.05), + bottom=auto(), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 320.0) + assert_eq(c.size.height, 107.0) + assert_eq(c.location.x, 40.0) + assert_eq(c.location.y, 15.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_max_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=length(50.0), height=auto())) + .with_aspect_ratio(3.0), + { + text_content: "HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 17.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_max_width" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(0.5), + { + text_content: "HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 25.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_min_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_min_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=auto())) + .with_aspect_ratio(3.0), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 17.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_min_width" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_min_width.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(0.5), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 25.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_width" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_width.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=auto(), height=percent(0.2))) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=percent(0.05), right=auto(), top=percent(0.05), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 180.0) + assert_eq(c.size.height, 60.0) + assert_eq(c.location.x, 20.0) + assert_eq(c.location.y, 15.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_width_from_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_width_from_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.3), bottom=percent(0.5)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 180.0) + assert_eq(c.size.height, 60.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 90.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_height_overrides_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_height_overrides_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=auto(), height=percent(0.1))) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.3), bottom=percent(0.5)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 90.0) + assert_eq(c.size.height, 30.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 90.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_width_overrides_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_width_overrides_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(0.4), height=auto())) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.05), + bottom=auto(), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 160.0) + assert_eq(c.size.height, 53.0) + assert_eq(c.location.x, 40.0) + assert_eq(c.location.y, 15.0) +} + +///| +test "upstream/generated/block/block_absolute_child_with_margin_x" { + // Ported from taffy-reference/tests/generated/block/block_absolute_child_with_margin_x.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(7.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(7.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(5.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(20.0), height=length(37.0))), + [node0, node1, node2], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 20.0) + assert_eq(root_layout.size.height, 37.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 9.0) + assert_eq(l0.size.height, 9.0) + assert_eq(l0.location.x, 7.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 9.0) + assert_eq(l1.size.height, 9.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 9.0) + assert_eq(l2.size.height, 9.0) + assert_eq(l2.location.x, 10.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_child_with_margin_y" { + // Ported from taffy-reference/tests/generated/block/block_absolute_child_with_margin_y.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(7.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(7.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(20.0), height=length(37.0))), + [node0, node1, node2], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 20.0) + assert_eq(root_layout.size.height, 37.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 9.0) + assert_eq(l0.size.height, 9.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 7.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 9.0) + assert_eq(l1.size.height, 9.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 9.0) + assert_eq(l2.size.height, 9.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_child_with_max_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_child_with_max_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(150.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=length(20.0)), + ), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 200.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 80.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 150.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_child_order" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_child_order.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 110.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 60.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 40.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_no_size" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_no_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default().with_position(position_absolute()), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 0.0) + assert_eq(c.size.height, 0.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_percentage_bottom_based_on_parent_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_percentage_bottom_based_on_parent_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.5), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=percent(0.5)), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=auto())) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.1), bottom=percent(0.1)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 200.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 100.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 90.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 160.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_percentage_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_percentage_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=percent(0.5))) + .with_inset( + Rect(left=length(10.0), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_row_width_height_end_bottom" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_row_width_height_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 80.0) + assert_eq(c.location.y, 80.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_start_top_end_bottom" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_start_top_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 80.0) + assert_eq(c.size.height, 80.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_width_height_end_bottom" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_width_height_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 80.0) + assert_eq(c.location.y, 80.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_width_height_start_top" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_width_height_start_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=length(10.0), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_width_height_start_top_end_bottom" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_width_height_start_top_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_within_border" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_within_border.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0, node1, node2, node3], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 40.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 30.0) + assert_eq(l3.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_bottom_and_top_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_bottom_and_top_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=length(20.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 70.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part02_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part02_test.mbt new file mode 100644 index 0000000..3579621 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part02_test.mbt @@ -0,0 +1,894 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/block/block_absolute_margin_auto_bottom_and_top_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_bottom_and_top_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_bottom_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_bottom_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=length(0.0), bottom=auto()), + ) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=length(20.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_bottom_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_bottom_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_and_right_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_and_right_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 70.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_and_right_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_and_right_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, -40.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(10.0), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, -50.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(10.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 130.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_multiple_children_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_multiple_children_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(20.0), right=length(10.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 20.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_multiple_children_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_multiple_children_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_right_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_right_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_right_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_right_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_top_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_top_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ) + .with_inset( + Rect(left=auto(), right=auto(), top=length(20.0), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 140.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_top_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_top_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_bottom_left_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_bottom_left_with_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect( + left=length(20.0), + right=length(10.0), + top=length(10.0), + bottom=length(20.0), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 30.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_bottom_left_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_bottom_left_without_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_minmax_bottom_right_max" { + // Ported from taffy-reference/tests/generated/block/block_absolute_minmax_bottom_right_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 40.0) + assert_eq(c.size.height, 30.0) + assert_eq(c.location.x, 50.0) + assert_eq(c.location.y, 60.0) +} + +///| +test "upstream/generated/block/block_absolute_minmax_bottom_right_min_max" { + // Ported from taffy-reference/tests/generated/block/block_absolute_minmax_bottom_right_min_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 60.0) + assert_eq(c.location.x, 40.0) + assert_eq(c.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_absolute_minmax_bottom_right_min_max_preferred" { + // Ported from taffy-reference/tests/generated/block/block_absolute_minmax_bottom_right_min_max_preferred.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 60.0) + assert_eq(c.location.x, 40.0) + assert_eq(c.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_absolute_minmax_top_left_bottom_right_max" { + // Ported from taffy-reference/tests/generated/block/block_absolute_minmax_top_left_bottom_right_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 40.0) + assert_eq(c.size.height, 30.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part03_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part03_test.mbt new file mode 100644 index 0000000..de8fd20 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part03_test.mbt @@ -0,0 +1,1086 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/block/block_absolute_minmax_top_left_bottom_right_min_max" { + // Ported from taffy-reference/tests/generated/block/block_absolute_minmax_top_left_bottom_right_min_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 60.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_no_styles" { + // Ported from taffy-reference/tests/generated/block/block_absolute_no_styles.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 10.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/block/block_absolute_padding_border_overrides_max_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 0.0) + assert_eq(root_layout.size.height, 0.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 22.0) + assert_eq(c.size.height, 14.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/block/block_absolute_padding_border_overrides_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 0.0) + assert_eq(root_layout.size.height, 0.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 22.0) + assert_eq(c.size.height, 14.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 30.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child_margin" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 35.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 5.0) + assert_eq(l10.location.y, 5.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child_margin_percent" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child_margin_percent.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=percent(0.01), + right=percent(0.01), + top=percent(0.01), + bottom=percent(0.01), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 35.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 1.0) + assert_eq(l10.location.y, 1.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child_padding" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child_padding.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 45.0) + assert_eq(l1.location.y, 35.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 5.0) + assert_eq(l10.location.y, 5.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child_top" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 30.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child_top2" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child_top2.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))) + .with_inset(Rect(left=auto(), right=auto(), top=length(5.0), bottom=auto())), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 35.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_align_baseline_double_nested_child" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_double_nested_child.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(15.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 30.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 15.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_height" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 40.0) + assert_eq(c.size.height, 20.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_max_height" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_max_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 40.0) + assert_eq(c.size.height, 20.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_max_width" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_max_size(Size(width=auto(), height=length(20.0))) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 40.0) + assert_eq(c.size.height, 20.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_min_height" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_min_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_min_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 100.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_min_width" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_min_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + { text_content: "", writing_mode: Horizontal }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 100.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_width" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_width.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 80.0) + assert_eq(c.size.height, 40.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_basic" { + // Ported from taffy-reference/tests/generated/block/block_basic.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 20.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 50.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_border_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_border_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 50.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 38.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 8.0) + assert_eq(c0.location.y, 2.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 38.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, 8.0) + assert_eq(c1.location.y, 12.0) +} + +///| +test "upstream/generated/block/block_border_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_border_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 62.0) + assert_eq(layout.size.height, 28.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 8.0) + assert_eq(c0.location.y, 2.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 50.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, 8.0) + assert_eq(c1.location.y, 12.0) +} + +///| +test "upstream/generated/block/block_border_percentage_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_border_percentage_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_block()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 50.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c00 = taffy.layout(node00) + assert_eq(c00.size.width, 50.0) + assert_eq(c00.size.height, 10.0) + assert_eq(c00.location.x, 0.0) + assert_eq(c00.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_border_percentage_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_border_percentage_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_block()), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 0.0) + assert_eq(layout.size.height, 10.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 0.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c00 = taffy.layout(node00) + assert_eq(c00.size.width, 0.0) + assert_eq(c00.size.height, 10.0) + assert_eq(c00.location.x, 0.0) + assert_eq(c00.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_display_none" { + // Ported from taffy-reference/tests/generated/block/block_display_none.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_none()) + .with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 20.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 0.0) + assert_eq(c1.size.height, 0.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 0.0) + let c2 = taffy.layout(node2) + assert_eq(c2.size.width, 50.0) + assert_eq(c2.size.height, 10.0) + assert_eq(c2.location.x, 0.0) + assert_eq(c2.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_display_none_with_child" { + // Ported from taffy-reference/tests/generated/block/block_display_none_with_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node10 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(20.0), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_with_children( + Style::default().with_display(display_none()), + [node10], + ) + let node2 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 100.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 0.0) + assert_eq(c1.size.height, 0.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 0.0) + let c10 = taffy.layout(node10) + assert_eq(c10.size.width, 0.0) + assert_eq(c10.size.height, 0.0) + assert_eq(c10.location.x, 0.0) + assert_eq(c10.location.y, 0.0) + let c2 = taffy.layout(node2) + assert_eq(c2.size.width, 100.0) + assert_eq(c2.size.height, 10.0) + assert_eq(c2.location.x, 0.0) + assert_eq(c2.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_display_none_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_display_none_with_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_none()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 100.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 0.0) + assert_eq(c1.size.height, 0.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part04_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part04_test.mbt new file mode 100644 index 0000000..011ca01 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part04_test.mbt @@ -0,0 +1,986 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/block/block_display_none_with_margin" { + // Ported from taffy-reference/tests/generated/block/block_display_none_with_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_none()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 0.0) + assert_eq(c0.size.height, 0.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 100.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_display_none_with_position_absolute" { + // Ported from taffy-reference/tests/generated/block/block_display_none_with_position_absolute.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_none()) + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(100.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 0.0) + assert_eq(c0.size.height, 0.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_inset_fixed" { + // Ported from taffy-reference/tests/generated/block/block_inset_fixed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=length(2.0), right=auto(), top=length(4.0), bottom=auto()), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=length(6.0), top=auto(), bottom=length(8.0)), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect( + left=length(2.0), + right=length(6.0), + top=length(4.0), + bottom=length(8.0), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 30.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 2.0) + assert_eq(c0.location.y, 4.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 50.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, -6.0) + assert_eq(c1.location.y, 2.0) + let c2 = taffy.layout(node2) + assert_eq(c2.size.width, 50.0) + assert_eq(c2.size.height, 10.0) + assert_eq(c2.location.x, 2.0) + assert_eq(c2.location.y, 24.0) +} + +///| +test "upstream/generated/block/block_inset_percentage" { + // Ported from taffy-reference/tests/generated/block/block_inset_percentage.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=percent(0.02), right=auto(), top=percent(0.04), bottom=auto()), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=percent(0.06), top=auto(), bottom=percent(0.08)), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect( + left=percent(0.02), + right=percent(0.06), + top=percent(0.04), + bottom=percent(0.08), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 30.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 1.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 50.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, -3.0) + assert_eq(c1.location.y, 10.0) + let c2 = taffy.layout(node2) + assert_eq(c2.size.width, 50.0) + assert_eq(c2.size.height, 10.0) + assert_eq(c2.location.x, 1.0) + assert_eq(c2.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_intrinsic_width" { + // Ported from taffy-reference/tests/generated/block/block_intrinsic_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 20.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 50.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_item_max_width" { + // Ported from taffy-reference/tests/generated/block/block_item_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_max_size(Size(width=length(100.0), height=auto())), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_max_size(Size(width=length(300.0), height=auto())), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 200.0) + assert_eq(layout.size.height, 200.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 100.0) + assert_eq(c0.size.height, 50.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 200.0) + assert_eq(c1.size.height, 50.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_item_min_width_overrides_max_width" { + // Ported from taffy-reference/tests/generated/block/block_item_min_width_overrides_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_min_size(Size(width=length(200.0), height=auto())) + .with_max_size(Size(width=length(50.0), height=auto())), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 200.0) + assert_eq(c0.size.height, 50.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_auto_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_auto_bottom_and_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_bottom_and_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 150.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left_and_right" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left_and_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 75.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left_and_right_with_auto_width" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left_and_right_with_auto_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_max_size(Size(width=length(100.0), height=auto())) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 100.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 50.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left_child_bigger_than_parent.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left_fix_right_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left_fix_right_child_bigger_than_parent.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(10.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left_right_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left_right_child_bigger_than_parent.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_auto_multiple_children" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_multiple_children.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 100.0) +} + +///| +test "upstream/generated/block/block_margin_auto_right" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_auto_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_auto_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_auto_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(10.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_auto_left" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_auto_left.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(10.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 30.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_auto_left_and_right" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_auto_left_and_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(10.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 15.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_auto_right" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_auto_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(10.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_auto_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_auto_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(10.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_size_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_size_negative.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(-10.0), + right=length(-5.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 65.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_size_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_size_positive.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(5.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 35.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part05_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part05_test.mbt new file mode 100644 index 0000000..4fa8fdb --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part05_test.mbt @@ -0,0 +1,1631 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/block/block_margin_x_intrinsic_size_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_intrinsic_size_negative.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(-10.0), + right=length(-5.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 0.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 15.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_intrinsic_size_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_intrinsic_size_positive.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(5.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 15.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 15.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_fixed_size_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_fixed_size_negative.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=percent(-0.2), + right=percent(-0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 65.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_fixed_size_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_fixed_size_positive.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 35.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_intrinsic_size_other_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_negative.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=percent(-0.2), + right=percent(-0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 130.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, -20.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_intrinsic_size_other_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_positive.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 70.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_intrinsic_size_self_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_negative.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(10.0))) + .with_margin( + Rect( + left=percent(-0.2), + right=percent(-0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 10.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, -20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_intrinsic_size_self_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_positive.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(10.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 10.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_complex" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_complex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(-5.0), + ), + ), + ) + let node11 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(7.0), + bottom=length(3.0), + ), + ), + ) + let node12 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-6.0), + bottom=length(9.0), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + [node10, node11, node12], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(-5.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 0.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, -10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, -10.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 0.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, -5.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 0.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 0.0) + assert_eq(l11.location.y, 7.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 0.0) + assert_eq(l12.size.height, 10.0) + assert_eq(l12.location.x, 0.0) + assert_eq(l12.location.y, -6.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, -10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, -10.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_aspect_ratio" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_aspect_ratio.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_aspect_ratio(2.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 65.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 25.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 55.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_border_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 30.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_border_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 30.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_height" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(1.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 41.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 1.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 31.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_line_box" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + { text_content: "HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 50.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 40.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(0.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + { text_content: "HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_max_size(Size(width=auto(), height=length(0.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + { text_content: "HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_min_height" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_min_size(Size(width=auto(), height=length(1.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 41.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 1.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 31.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_hidden(), y=overflow_visible())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_hidden())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_padding_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(1.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 41.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 1.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 31.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_padding_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(1.0), + bottom=length(0.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 41.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 1.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 31.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-5.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-7.0), + bottom=length(-3.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-2.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 13.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 3.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 3.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_positive.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 30.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part06_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part06_test.mbt new file mode 100644 index 0000000..9bd0eee --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part06_test.mbt @@ -0,0 +1,1880 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/block/block_margin_y_collapse_through_positive_and_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_positive_and_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(-4.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(7.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 17.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 5.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 7.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_with_absolute_child" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_with_absolute_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node10 = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_display(display_block()), + { text_content: "HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node10], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 30.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_border_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_border_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ) + .with_overflow(Point(x=overflow_hidden(), y=overflow_visible())), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 10.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 45.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 35.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 10.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 10.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 35.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 10.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 35.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_padding_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_padding_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(1.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 31.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 21.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 11.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_negative_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_negative_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_negative_parent_larger" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_negative_parent_smaller" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_not_blocked_by_border_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_border_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(1.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 21.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 11.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_positive_and_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_positive_and_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node100 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node10 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(0.0), + ), + ), + [node100], + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node10], + ) + let node200 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node20 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node200], + ) + let node2 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(0.0), + ), + ), + [node20], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 5.0) + let l_node10 = taffy.layout(node10) + assert_eq(l_node10.size.width, 50.0) + assert_eq(l_node10.size.height, 10.0) + assert_eq(l_node10.location.x, 0.0) + assert_eq(l_node10.location.y, 0.0) + let l_node100 = taffy.layout(node100) + assert_eq(l_node100.size.width, 50.0) + assert_eq(l_node100.size.height, 10.0) + assert_eq(l_node100.location.x, 0.0) + assert_eq(l_node100.location.y, 0.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 20.0) + let l_node20 = taffy.layout(node20) + assert_eq(l_node20.size.width, 50.0) + assert_eq(l_node20.size.height, 10.0) + assert_eq(l_node20.location.x, 0.0) + assert_eq(l_node20.location.y, 0.0) + let l_node200 = taffy.layout(node200) + assert_eq(l_node200.size.width, 50.0) + assert_eq(l_node200.size.height, 10.0) + assert_eq(l_node200.location.x, 0.0) + assert_eq(l_node200.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_positive_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_positive_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_positive_parent_larger" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_positive_parent_smaller" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_granchild_collapse_positive_and_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_granchild_collapse_positive_and_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node000 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node0000], + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node1000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node100 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-2.0), + bottom=length(0.0), + ), + ), + [node1000], + ) + let node10 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(0.0), + ), + ), + [node100], + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node10], + ) + let node2000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node200 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(15.0), + bottom=length(0.0), + ), + ), + [node2000], + ) + let node20 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(0.0), + ), + ), + [node200], + ) + let node2 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node20], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) + let l_node0000 = taffy.layout(node0000) + assert_eq(l_node0000.size.width, 50.0) + assert_eq(l_node0000.size.height, 10.0) + assert_eq(l_node0000.location.x, 0.0) + assert_eq(l_node0000.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 5.0) + let l_node10 = taffy.layout(node10) + assert_eq(l_node10.size.width, 50.0) + assert_eq(l_node10.size.height, 10.0) + assert_eq(l_node10.location.x, 0.0) + assert_eq(l_node10.location.y, 0.0) + let l_node100 = taffy.layout(node100) + assert_eq(l_node100.size.width, 50.0) + assert_eq(l_node100.size.height, 10.0) + assert_eq(l_node100.location.x, 0.0) + assert_eq(l_node100.location.y, 0.0) + let l_node1000 = taffy.layout(node1000) + assert_eq(l_node1000.size.width, 50.0) + assert_eq(l_node1000.size.height, 10.0) + assert_eq(l_node1000.location.x, 0.0) + assert_eq(l_node1000.location.y, 0.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 20.0) + let l_node20 = taffy.layout(node20) + assert_eq(l_node20.size.width, 50.0) + assert_eq(l_node20.size.height, 10.0) + assert_eq(l_node20.location.x, 0.0) + assert_eq(l_node20.location.y, 0.0) + let l_node200 = taffy.layout(node200) + assert_eq(l_node200.size.width, 50.0) + assert_eq(l_node200.size.height, 10.0) + assert_eq(l_node200.location.x, 0.0) + assert_eq(l_node200.location.y, 0.0) + let l_node2000 = taffy.layout(node2000) + assert_eq(l_node2000.size.width, 50.0) + assert_eq(l_node2000.size.height, 10.0) + assert_eq(l_node2000.location.x, 0.0) + assert_eq(l_node2000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_granchild_collapse_positive_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_granchild_collapse_positive_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node000 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node0000], + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) + let l_node0000 = taffy.layout(node0000) + assert_eq(l_node0000.size.width, 50.0) + assert_eq(l_node0000.size.height, 10.0) + assert_eq(l_node0000.location.x, 0.0) + assert_eq(l_node0000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_border_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_border_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_hidden(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 45.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 35.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 35.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 35.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_padding_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_padding_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(1.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 31.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 21.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part07_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part07_test.mbt new file mode 100644 index 0000000..ddb5d55 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part07_test.mbt @@ -0,0 +1,1894 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_negative_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_negative_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_negative_parent_larger" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_negative_parent_smaller" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_not_blocked_by_border_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_border_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_not_blocked_by_padding_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_padding_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(1.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 21.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 11.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 1.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_positive_and_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_positive_and_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node00], + ) + let node100 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node10 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(5.0), + ), + ), + [node100], + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node10], + ) + let node200 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node20 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node200], + ) + let node2 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-5.0), + ), + ), + [node20], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 10.0) + let l_node10 = taffy.layout(node10) + assert_eq(l_node10.size.width, 50.0) + assert_eq(l_node10.size.height, 10.0) + assert_eq(l_node10.location.x, 0.0) + assert_eq(l_node10.location.y, 0.0) + let l_node100 = taffy.layout(node100) + assert_eq(l_node100.size.width, 50.0) + assert_eq(l_node100.size.height, 10.0) + assert_eq(l_node100.location.x, 0.0) + assert_eq(l_node100.location.y, 0.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 15.0) + let l_node20 = taffy.layout(node20) + assert_eq(l_node20.size.width, 50.0) + assert_eq(l_node20.size.height, 10.0) + assert_eq(l_node20.location.x, 0.0) + assert_eq(l_node20.location.y, 0.0) + let l_node200 = taffy.layout(node200) + assert_eq(l_node200.size.width, 50.0) + assert_eq(l_node200.size.height, 10.0) + assert_eq(l_node200.location.x, 0.0) + assert_eq(l_node200.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_positive_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_positive_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_positive_parent_larger" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_positive_parent_smaller" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_granchild_collapse_positive_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_granchild_collapse_positive_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node000 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node0000], + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) + let l_node0000 = taffy.layout(node0000) + assert_eq(l_node0000.size.width, 50.0) + assert_eq(l_node0000.size.height, 10.0) + assert_eq(l_node0000.location.x, 0.0) + assert_eq(l_node0000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(-5.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, -10.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, -10.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, -10.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_negative_percentage" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_negative_percentage.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.05), + bottom=percent(-0.05), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 15.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 5.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_positive.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 90.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 30.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 50.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, 70.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_positive_and_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(5.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(-10.0), + ), + ), + ) + let node5 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(-5.0), + ), + ), + ) + let node6 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 90.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 35.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, 40.0) + let l_node4 = taffy.layout(node4) + assert_eq(l_node4.size.width, 50.0) + assert_eq(l_node4.size.height, 10.0) + assert_eq(l_node4.location.x, 0.0) + assert_eq(l_node4.location.y, 50.0) + let l_node5 = taffy.layout(node5) + assert_eq(l_node5.size.width, 50.0) + assert_eq(l_node5.size.height, 10.0) + assert_eq(l_node5.location.x, 0.0) + assert_eq(l_node5.location.y, 55.0) + let l_node6 = taffy.layout(node6) + assert_eq(l_node6.size.width, 50.0) + assert_eq(l_node6.size.height, 10.0) + assert_eq(l_node6.location.x, 0.0) + assert_eq(l_node6.location.y, 70.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_positive_and_negative_percentage" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative_percentage.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(0.1), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.05), + bottom=percent(0.05), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(-0.1), + ), + ), + ) + let node5 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.05), + bottom=percent(-0.05), + ), + ), + ) + let node6 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 80.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 15.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 28.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, 35.0) + let l_node4 = taffy.layout(node4) + assert_eq(l_node4.size.width, 50.0) + assert_eq(l_node4.size.height, 10.0) + assert_eq(l_node4.location.x, 0.0) + assert_eq(l_node4.location.y, 45.0) + let l_node5 = taffy.layout(node5) + assert_eq(l_node5.size.width, 50.0) + assert_eq(l_node5.size.height, 10.0) + assert_eq(l_node5.location.x, 0.0) + assert_eq(l_node5.location.y, 53.0) + let l_node6 = taffy.layout(node6) + assert_eq(l_node6.size.width, 50.0) + assert_eq(l_node6.size.height, 10.0) + assert_eq(l_node6.location.x, 0.0) + assert_eq(l_node6.location.y, 65.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_positive_percentage" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_positive_percentage.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 65.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 35.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, -10.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_negative_percentage_other" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_negative_percentage_other.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_negative_percentage_self" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_negative_percentage_self.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_positive.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 40.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_positive_percentage_other" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_positive_percentage_other.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_positive_percentage_self" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_positive_percentage_self.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_margin_y_total_collapse" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_total_collapse.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node01 = taffy.layout(node01) + assert_eq(l_node01.size.width, 50.0) + assert_eq(l_node01.size.height, 0.0) + assert_eq(l_node01.location.x, 0.0) + assert_eq(l_node01.location.y, 20.0) + let l_node02 = taffy.layout(node02) + assert_eq(l_node02.size.width, 50.0) + assert_eq(l_node02.size.height, 10.0) + assert_eq(l_node02.location.x, 0.0) + assert_eq(l_node02.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_margin_y_total_collapse_complex" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_total_collapse_complex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(-5.0), + ), + ), + ) + let node11 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(7.0), + bottom=length(3.0), + ), + ), + ) + let node12 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-6.0), + bottom=length(9.0), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + [node10, node11, node12], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(-5.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, -10.0) + let l_node10 = taffy.layout(node10) + assert_eq(l_node10.size.width, 0.0) + assert_eq(l_node10.size.height, 10.0) + assert_eq(l_node10.location.x, 0.0) + assert_eq(l_node10.location.y, -5.0) + let l_node11 = taffy.layout(node11) + assert_eq(l_node11.size.width, 0.0) + assert_eq(l_node11.size.height, 10.0) + assert_eq(l_node11.location.x, 0.0) + assert_eq(l_node11.location.y, 7.0) + let l_node12 = taffy.layout(node12) + assert_eq(l_node12.size.width, 0.0) + assert_eq(l_node12.size.height, 10.0) + assert_eq(l_node12.location.x, 0.0) + assert_eq(l_node12.location.y, -6.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, -10.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, -10.0) +} + +///| +test "upstream/generated/block/block_overflow_scrollbars_overridden_by_available_space" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_overridden_by_available_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 2.0) + assert_eq(l_node0.size.height, 15.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 0.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part08_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part08_test.mbt new file mode 100644 index 0000000..3fd2e87 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part08_test.mbt @@ -0,0 +1,1068 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/block/block_overflow_scrollbars_overridden_by_max_size" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_overridden_by_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_max_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 0.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_overflow_scrollbars_overridden_by_size" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_overridden_by_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 0.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_overflow_scrollbars_take_up_space_both_axis" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_take_up_space_both_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 35.0) + assert_eq(l_node0.size.height, 35.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_overflow_scrollbars_take_up_space_cross_axis" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_take_up_space_cross_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 35.0) + assert_eq(l_node0.size.height, 50.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_overflow_scrollbars_take_up_space_main_axis" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_take_up_space_main_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 35.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_padding_border_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_padding( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 28.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 15.0) + assert_eq(l_node0.location.y, 3.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 28.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 15.0) + assert_eq(l_node1.location.y, 13.0) +} + +///| +test "upstream/generated/block/block_padding_border_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 72.0) + assert_eq(l_node.size.height, 34.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 15.0) + assert_eq(l_node0.location.y, 3.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 15.0) + assert_eq(l_node1.location.y, 13.0) +} + +///| +test "upstream/generated/block/block_padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_overrides_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 22.0) + assert_eq(l_node0.size.height, 14.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 0.0) + assert_eq(l_node00.location.x, 15.0) + assert_eq(l_node00.location.y, 3.0) +} + +///| +test "upstream/generated/block/block_padding_border_overrides_min_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_overrides_min_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_min_size(Size(width=length(0.0), height=length(0.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 22.0) + assert_eq(l_node0.size.height, 14.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 0.0) + assert_eq(l_node00.location.x, 15.0) + assert_eq(l_node00.location.y, 3.0) +} + +///| +test "upstream/generated/block/block_padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_overrides_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 22.0) + assert_eq(l_node0.size.height, 14.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 0.0) + assert_eq(l_node00.location.x, 15.0) + assert_eq(l_node00.location.y, 3.0) +} + +///| +test "upstream/generated/block/block_padding_border_percentage_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_percentage_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=percent(0.04), + right=percent(0.02), + top=percent(0.01), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 12.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 47.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 2.0) + assert_eq(l_node00.location.y, 1.0) +} + +///| +test "upstream/generated/block/block_padding_border_percentage_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_percentage_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=percent(0.04), + right=percent(0.02), + top=percent(0.01), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 0.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_padding_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 38.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 8.0) + assert_eq(l_node0.location.y, 2.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 38.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 8.0) + assert_eq(l_node1.location.y, 12.0) +} + +///| +test "upstream/generated/block/block_padding_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 62.0) + assert_eq(l_node.size.height, 28.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 8.0) + assert_eq(l_node0.location.y, 2.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 8.0) + assert_eq(l_node1.location.y, 12.0) +} + +///| +test "upstream/generated/block/block_padding_percentage_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_percentage_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=percent(0.04), + right=percent(0.02), + top=percent(0.01), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 12.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 47.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 2.0) + assert_eq(l_node00.location.y, 1.0) +} + +///| +test "upstream/generated/block/block_padding_percentage_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_percentage_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=percent(0.04), + right=percent(0.02), + top=percent(0.01), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 0.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) +} + +///| +test "upstream/generated/block/mod" { + // Upstream module declaration file; no runnable test vectors. + () +} + +///| +test "upstream/generated/blockflex/blockflex_block_in_flex_column" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_block_in_flex_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_display(display_block())) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(50.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 200.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 200.0) + assert_eq(l_node0.size.height, 0.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) +} + +///| +test "upstream/generated/blockflex/blockflex_block_in_flex_row" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_block_in_flex_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_display(display_block())) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(200.0), height=length(50.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 200.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 50.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 50.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) +} + +///| +test "upstream/generated/blockflex/blockflex_flex_in_block" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_flex_in_block.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_flex()), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 200.0) + assert_eq(l_node.size.height, 70.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 200.0) + assert_eq(l_node0.size.height, 50.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 50.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 20.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 50.0) +} + +///| +test "upstream/generated/blockflex/blockflex_margin_y_collapse_through_blocked_by_flex" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_margin_y_collapse_through_blocked_by_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_flex()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 40.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/blockflex/blockflex_margin_y_first_child_collapse_blocked_by_flex" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_margin_y_first_child_collapse_blocked_by_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 10.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 0.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/blockflex/blockflex_margin_y_last_child_collapse_blocked_by_flex" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_margin_y_last_child_collapse_blocked_by_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 0.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/blockflex/blockflex_overflow_hidden" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_overflow_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_flex_grow(1.0), + { text_content: "HHHH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()).with_flex_grow(1.0), + { text_content: "HHHH\u{200B}HH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(20.0), height=length(50.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 50.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 40.0) + assert_eq(l_node1.size.height, 50.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) +} + +///| +test "upstream/generated/blockflex/mod" { + // Upstream module declaration file; no runnable test vectors. + () +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part09_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part09_test.mbt new file mode 100644 index 0000000..9cfe885 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part09_test.mbt @@ -0,0 +1,912 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_auto" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_auto.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([auto()]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 40.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 40.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 40.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 10.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_larger" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([fit_content(length(50.0))]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 40.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 40.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 40.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 10.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_middle" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_middle.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([fit_content(length(30.0))]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 30.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 30.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 30.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_smaller" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([fit_content(length(10.0))]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 20.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 20.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_larger" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([length(50.0)]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 10.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_middle" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_middle.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([length(30.0)]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 30.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 30.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 30.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_smaller" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([length(10.0)]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 10.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 10.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 10.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fr" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fr.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([fr(1.0)]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 40.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 40.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 40.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 10.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_max_content" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_max_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_min_content()]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 20.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 20.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_min_content" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_min_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_min_content()]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 20.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 20.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_grid_in_block" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_grid_in_block.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 200.0) + assert_eq(l_node.size.height, 70.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_margin_y_collapse_through_blocked_by_grid" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_margin_y_collapse_through_blocked_by_grid.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_grid()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 40.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_margin_y_first_child_collapse_blocked_by_grid" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_margin_y_first_child_collapse_blocked_by_grid.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 10.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 50.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_margin_y_last_child_collapse_blocked_by_grid" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_margin_y_last_child_collapse_blocked_by_grid.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 50.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/blockgrid/mod" { + // Upstream mod.rs only declares submodules; no standalone runnable vector. + () +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 360.0) + assert_eq(l0.size.height, 120.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 15.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=percent(0.05), right=auto(), top=percent(0.05), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 67.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 15.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_height_from_inset" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_height_from_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.05), + bottom=auto(), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 320.0) + assert_eq(l0.size.height, 107.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 15.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_max_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=length(50.0), height=auto())) + .with_aspect_ratio(3.0), + { + text_content: "HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 17.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_max_width" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(0.5), + { + text_content: "HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 25.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_min_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=auto())) + .with_aspect_ratio(3.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 17.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_min_width" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(0.5), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 25.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_width" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=auto(), height=percent(0.2))) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=percent(0.05), right=auto(), top=percent(0.05), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 180.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 15.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_width_from_inset" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_width_from_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.3), bottom=percent(0.5)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 180.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_height_overrides_inset" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_height_overrides_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=auto(), height=percent(0.1))) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.3), bottom=percent(0.5)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 90.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part10_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part10_test.mbt new file mode 100644 index 0000000..780a1a0 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part10_test.mbt @@ -0,0 +1,857 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/absolute_aspect_ratio_width_overrides_inset" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_width_overrides_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(0.4), height=auto())) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.05), + bottom=auto(), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 160.0) + assert_eq(l0.size.height, 53.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 15.0) +} + +///| +test "upstream/generated/flex/absolute_child_with_cross_margin" { + // Ported from taffy-reference/tests/generated/flex/absolute_child_with_cross_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(28.0), height=length(27.0))), + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_align_content(align_content_stretch()) + .with_flex_grow(0.0) + .with_flex_shrink(1.0) + .with_size(Size(width=percent(1.0), height=length(15.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(4.0), + bottom=length(0.0), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(25.0), height=length(27.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_between()) + .with_min_size(Size(width=length(311.0), height=length(0.0))) + .with_max_size( + Size(width=length(311.0), height=length(36893500000000000000.0)), + ), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 311.0) + assert_eq(l_node.size.height, 27.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 28.0) + assert_eq(l0.size.height, 27.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 311.0) + assert_eq(l1.size.height, 15.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 4.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 25.0) + assert_eq(l2.size.height, 27.0) + assert_eq(l2.location.x, 286.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_child_with_main_margin" { + // Ported from taffy-reference/tests/generated/flex/absolute_child_with_main_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(7.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(20.0), height=length(37.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 37.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 9.0) + assert_eq(l0.size.height, 9.0) + assert_eq(l0.location.x, 7.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_child_with_max_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_child_with_max_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(30.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_position(position_absolute()) + .with_flex_direction(flex_direction_column()) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=length(20.0)), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 200.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 150.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 30.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_child_with_max_height_larger_shrinkable_grandchild" { + // Ported from taffy-reference/tests/generated/flex/absolute_child_with_max_height_larger_shrinkable_grandchild.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(1.0) + .with_flex_basis(length(150.0)) + .with_size(Size(width=length(100.0), height=auto())), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_position(position_absolute()) + .with_flex_direction(flex_direction_column()) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=length(20.0)), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 200.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 80.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_center" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 25.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_center_and_bottom_position" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 25.0) + assert_eq(l0.location.y, 50.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_center_and_left_position" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_left_position.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))) + .with_inset(Rect(left=length(5.0), right=auto(), top=auto(), bottom=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_center_and_right_position" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_right_position.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))) + .with_inset(Rect(left=auto(), right=length(5.0), top=auto(), bottom=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 45.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_center_and_top_position" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_top_position.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 25.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_flex_end" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_flex_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_end()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 60.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_center" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_center_on_child_only" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_center_on_child_only.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_center()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_child_order" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_child_order.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 55.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 30.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 25.0) + assert_eq(l1.location.y, 30.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 55.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 55.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_in_wrap_reverse_column_container" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 80.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_layout_in_wrap_reverse_column_container_flex_end" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container_flex_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_flex_end()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_layout_in_wrap_reverse_row_container" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 80.0) +} + +///| +test "upstream/generated/flex/absolute_layout_in_wrap_reverse_row_container_flex_end" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container_flex_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_flex_end()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_layout_justify_content_center" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_justify_content_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 25.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_layout_no_size" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_no_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_position(position_absolute()), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_layout_percentage_bottom_based_on_parent_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_percentage_bottom_based_on_parent_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.5), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=percent(0.5)), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=auto())) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.1), bottom=percent(0.1)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 200.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 100.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 90.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 160.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/flex/absolute_layout_percentage_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_percentage_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=percent(0.5))) + .with_inset( + Rect(left=length(10.0), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 200.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_layout_row_width_height_end_bottom" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_row_width_height_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 80.0) + assert_eq(l0.location.y, 80.0) +} + +///| +test "upstream/generated/flex/absolute_layout_start_top_end_bottom" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_start_top_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_layout_width_height_end_bottom" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_width_height_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 80.0) + assert_eq(l0.location.y, 80.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part11_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part11_test.mbt new file mode 100644 index 0000000..b3433af --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part11_test.mbt @@ -0,0 +1,1255 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/absolute_layout_width_height_start_top" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_width_height_start_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=length(10.0), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_layout_width_height_start_top_end_bottom" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_width_height_start_top_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_layout_within_border" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_within_border.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0, node1, node2, node3], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 40.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 30.0) + assert_eq(l3.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_margin_bottom_left" { + // Ported from taffy-reference/tests/generated/flex/absolute_margin_bottom_left.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 80.0) +} + +///| +test "upstream/generated/flex/absolute_minmax_bottom_right_max" { + // Ported from taffy-reference/tests/generated/flex/absolute_minmax_bottom_right_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 60.0) +} + +///| +test "upstream/generated/flex/absolute_minmax_bottom_right_min_max" { + // Ported from taffy-reference/tests/generated/flex/absolute_minmax_bottom_right_min_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_minmax_bottom_right_min_max_preferred" { + // Ported from taffy-reference/tests/generated/flex/absolute_minmax_bottom_right_min_max_preferred.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_minmax_top_left_bottom_right_max" { + // Ported from taffy-reference/tests/generated/flex/absolute_minmax_top_left_bottom_right_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_minmax_top_left_bottom_right_min_max" { + // Ported from taffy-reference/tests/generated/flex/absolute_minmax_top_left_bottom_right_min_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/flex/absolute_padding_border_overrides_max_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 0.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/flex/absolute_padding_border_overrides_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 0.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline" { + // Ported from taffy-reference/tests/generated/flex/align_baseline.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 30.0) +} + +///| +test "upstream/generated/flex/align_baseline_child" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_margin" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 5.0) + assert_eq(l10.location.y, 5.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_margin_percent" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_margin_percent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=percent(0.01), + right=percent(0.01), + top=percent(0.01), + bottom=percent(0.01), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 45.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 1.0) + assert_eq(l10.location.y, 1.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_multiline" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_multiline.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(60.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node12 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node13 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(50.0), height=auto())), + [node10, node11, node12, node13], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 80.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 25.0) + assert_eq(l10.size.height, 20.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 25.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 25.0) + assert_eq(l11.location.y, 0.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 25.0) + assert_eq(l12.size.height, 20.0) + assert_eq(l12.location.x, 0.0) + assert_eq(l12.location.y, 20.0) + let l13 = taffy.layout(node13) + assert_eq(l13.size.width, 25.0) + assert_eq(l13.size.height, 10.0) + assert_eq(l13.location.x, 25.0) + assert_eq(l13.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_multiline_no_override_on_secondline" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_multiline_no_override_on_secondline.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(60.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node12 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node13 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_baseline()) + .with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(50.0), height=length(25.0))), + [node10, node11, node12, node13], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 25.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 25.0) + assert_eq(l10.size.height, 20.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 25.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 25.0) + assert_eq(l11.location.y, 0.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 25.0) + assert_eq(l12.size.height, 20.0) + assert_eq(l12.location.x, 0.0) + assert_eq(l12.location.y, 20.0) + let l13 = taffy.layout(node13) + assert_eq(l13.size.width, 25.0) + assert_eq(l13.size.height, 10.0) + assert_eq(l13.location.x, 25.0) + assert_eq(l13.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_multiline_override" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_multiline_override.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(60.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node11 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_baseline()) + .with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node12 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node13 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_baseline()) + .with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(50.0), height=length(25.0))), + [node10, node11, node12, node13], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 25.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 50.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 25.0) + assert_eq(l10.size.height, 20.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 25.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 25.0) + assert_eq(l11.location.y, 0.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 25.0) + assert_eq(l12.size.height, 20.0) + assert_eq(l12.location.x, 0.0) + assert_eq(l12.location.y, 20.0) + let l13 = taffy.layout(node13) + assert_eq(l13.size.width, 25.0) + assert_eq(l13.size.height, 10.0) + assert_eq(l13.location.x, 25.0) + assert_eq(l13.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_padding" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 45.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 5.0) + assert_eq(l10.location.y, 5.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_top" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_top2" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_top2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(50.0), height=length(20.0))) + .with_inset(Rect(left=auto(), right=auto(), top=length(5.0), bottom=auto())), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 45.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline_column" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/flex/align_baseline_double_nested_child" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_double_nested_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(15.0))), + ) + let node1 = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 5.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 15.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline_multiline" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_multiline.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node20 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node20], + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 100.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 50.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 60.0) +} + +///| +test "upstream/generated/flex/align_baseline_multiline_column" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_multiline_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(30.0), height=length(50.0))), + [node10], + ) + let node20 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(40.0), height=length(70.0))), + [node20], + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 20.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 40.0) + assert_eq(l2.size.height, 70.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 0.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 10.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 70.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part12_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part12_test.mbt new file mode 100644 index 0000000..6fb34c9 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part12_test.mbt @@ -0,0 +1,1526 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/align_baseline_multiline_column2" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_multiline_column2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(30.0), height=length(50.0))), + [node10], + ) + let node20 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(40.0), height=length(70.0))), + [node20], + ) + let node3 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 20.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 40.0) + assert_eq(l2.size.height, 70.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 0.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 10.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 70.0) +} + +///| +test "upstream/generated/flex/align_baseline_multiline_row_and_column" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_multiline_row_and_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node10], + ) + let node20 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node20], + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 100.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 50.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_baseline_nested_child" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_nested_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline_nested_column" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_nested_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(60.0))), + ) + let node100 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(30.0))), + ) + let node101 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(40.0))), + ) + let node10 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(80.0))), + [node100, node101], + ) + let node1 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 80.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 30.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 80.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l100 = taffy.layout(node100) + assert_eq(l100.size.width, 50.0) + assert_eq(l100.size.height, 30.0) + assert_eq(l100.location.x, 0.0) + assert_eq(l100.location.y, 0.0) + let l101 = taffy.layout(node101) + assert_eq(l101.size.width, 50.0) + assert_eq(l101.size.height, 40.0) + assert_eq(l101.location.x, 0.0) + assert_eq(l101.location.y, 30.0) +} + +///| +test "upstream/generated/flex/align_center_should_size_based_on_content" { + // Ported from taffy-reference/tests/generated/flex/align_center_should_size_based_on_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_flex_grow(0.0) + .with_flex_shrink(1.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 40.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 20.0) + assert_eq(l000.size.height, 20.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_center_single_line" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_single_line.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_center()) + .with_size(Size(width=length(120.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 120.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 20.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 40.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 60.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 80.0) + assert_eq(l4.location.y, 0.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 100.0) + assert_eq(l5.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_center_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_center_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_center_wrapped" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_wrapped.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let mk = fn() { + taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + } + let node0 = mk() + let node1 = mk() + let node2 = mk() + let node3 = mk() + let node4 = mk() + let node5 = mk() + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_center()) + .with_size(Size(width=length(120.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 120.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 35.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 35.0) + let l2 = taffy.layout(node2) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 45.0) + let l3 = taffy.layout(node3) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 45.0) + let l4 = taffy.layout(node4) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 55.0) + let l5 = taffy.layout(node5) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 55.0) +} + +///| +test "upstream/generated/flex/align_content_center_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -25.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -5.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 15.0) +} + +///| +test "upstream/generated/flex/align_content_center_wrapped_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_wrapped_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -35.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -5.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 25.0) +} + +///| +test "upstream/generated/flex/align_content_end" { + // Ported from taffy-reference/tests/generated/flex/align_content_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 30.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_end_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_end_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_end()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_end_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_end_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_end()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_end_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_end_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_end()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -50.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, -10.0) +} + +///| +test "upstream/generated/flex/align_content_end_wrapped_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_end_wrapped_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_end()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -70.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -40.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, -10.0) +} + +///| +test "upstream/generated/flex/align_content_flex_end" { + // Ported from taffy-reference/tests/generated/flex/align_content_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 30.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(130.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 130.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_content_flex_start_with_flex" { + // Ported from taffy-reference/tests/generated/flex/align_content_flex_start_with_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(0.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(0.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(120.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 120.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 0.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 80.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 80.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 0.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 120.0) +} + +///| +test "upstream/generated/flex/align_content_flex_start_without_height_on_children" { + // Ported from taffy-reference/tests/generated/flex/align_content_flex_start_without_height_on_children.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 0.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 0.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_content_not_stretch_with_align_items_stretch" { + // Ported from taffy-reference/tests/generated/flex/align_content_not_stretch_with_align_items_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(272.0), height=length(44.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(56.0), height=length(44.0))), + ) + let node1 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(328.0), height=length(52.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 328.0) + assert_eq(lnode.size.height, 52.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 272.0) + assert_eq(l0.size.height, 44.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 272.0) + assert_eq(l00.size.height, 44.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 56.0) + assert_eq(l1.size.height, 44.0) + assert_eq(l1.location.x, 272.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 56.0) + assert_eq(l10.size.height, 44.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_around_single_line" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_single_line.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_space_around()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 17.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 16.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 17.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 17.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 33.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 17.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 16.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 67.0) + assert_eq(l4.location.y, 0.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 17.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 83.0) + assert_eq(l5.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_around_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_around()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_around_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_around()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_around_wrapped" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_wrapped.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_around()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 12.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 12.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 45.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 45.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 78.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 50.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 78.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part13_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part13_test.mbt new file mode 100644 index 0000000..82ad83c --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part13_test.mbt @@ -0,0 +1,1548 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/align_content_space_around_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_around()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_space_around_wrapped_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_wrapped_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_around()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_single_line" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_single_line.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_space_between()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 10.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 30.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 10.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 40.0) + assert_eq(l4.location.y, 0.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 10.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_between()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_between()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_wrapped" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_wrapped.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let mk = fn() { + taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + } + let node0 = mk() + let node1 = mk() + let node2 = mk() + let node3 = mk() + let node4 = mk() + let node5 = mk() + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_between()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 45.0) + let l3 = taffy.layout(node3) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 45.0) + let l4 = taffy.layout(node4) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 90.0) + let l5 = taffy.layout(node5) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_between()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_wrapped_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_wrapped_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_between()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_single_line" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_single_line.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_space_evenly()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 10.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 30.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 10.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 40.0) + assert_eq(l4.location.y, 0.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 10.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_evenly()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_evenly()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_wrapped" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_wrapped.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_evenly()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 18.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 18.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 45.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 45.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 73.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 50.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 73.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_evenly()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_wrapped_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_wrapped_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_evenly()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/align_content_spacearound" { + // Ported from taffy-reference/tests/generated/flex/align_content_spacearound.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_around()) + .with_size(Size(width=length(140.0), height=length(120.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 140.0) + assert_eq(lnode.size.height, 120.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 15.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 15.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 55.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 55.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 95.0) +} + +///| +test "upstream/generated/flex/align_content_spacebetween" { + // Ported from taffy-reference/tests/generated/flex/align_content_spacebetween.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_between()) + .with_size(Size(width=length(130.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 130.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 45.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 45.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_content_start" { + // Ported from taffy-reference/tests/generated/flex/align_content_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_start()) + .with_size(Size(width=length(130.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 130.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_content_start_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_start_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_start()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_start_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_start_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_start()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_start_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_start_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_start()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_stretch" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 0.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 0.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 0.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_column" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(50.0))), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=auto(), height=length(50.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(100.0), height=length(150.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 150.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 50.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 100.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_is_not_overriding_align_items" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_is_not_overriding_align_items.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_align_content(align_content_stretch()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 45.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 50.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 50.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_children" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_children.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=auto())), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 50.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 50.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part14_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part14_test.mbt new file mode 100644 index 0000000..43728b4 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part14_test.mbt @@ -0,0 +1,1394 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/align_content_stretch_row_with_fixed_height" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_fixed_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(60.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 80.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 80.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 80.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_flex" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 0.0) + assert_eq(l3.size.height, 100.0) + assert_eq(l3.location.x, 100.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 100.0) + assert_eq(l4.location.x, 100.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_flex_no_shrink" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_flex_no_shrink.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(0.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 0.0) + assert_eq(l3.size.height, 100.0) + assert_eq(l3.location.x, 100.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 100.0) + assert_eq(l4.location.x, 100.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_margin" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 60.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 40.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 60.0) + assert_eq(l3.location.y, 50.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 80.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_max_height" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 50.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 50.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_min_height" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(80.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 90.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 90.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 90.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 90.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_padding" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 50.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 50.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_single_row" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_single_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_flex_start_with_shrinking_children" { + // Ported from taffy-reference/tests/generated/flex/align_flex_start_with_shrinking_children.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_flex_start()), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 500.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 0.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 0.0) + assert_eq(l000.size.height, 0.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_flex_start_with_shrinking_children_with_stretch" { + // Ported from taffy-reference/tests/generated/flex/align_flex_start_with_shrinking_children_with_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_align_items(align_items_stretch()) + .with_flex_grow(1.0) + .with_flex_shrink(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_flex_start()), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 500.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 0.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 0.0) + assert_eq(l000.size.height, 0.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_flex_start_with_stretching_children" { + // Ported from taffy-reference/tests/generated/flex/align_flex_start_with_stretching_children.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_stretch()), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 500.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 500.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 0.0) + assert_eq(l000.size.height, 500.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_center" { + // Ported from taffy-reference/tests/generated/flex/align_items_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 45.0) +} + +///| +test "upstream/generated/flex/align_items_center_child_with_margin_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_child_with_margin_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_center()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 70.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 10.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_center_child_without_margin_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_child_without_margin_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(70.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_center()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 70.0) + assert_eq(l0.size.height, 70.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, -10.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 70.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_center_justify_content_center" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_justify_content_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node00 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=percent(1.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(50.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 500.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 245.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 10.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_items_center_min_max_with_padding" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_min_max_with_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(62.0), height=length(62.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_min_size(Size(width=length(320.0), height=length(72.0))) + .with_max_size(Size(width=length(320.0), height=length(504.0))) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(8.0), + bottom=length(8.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 78.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 62.0) + assert_eq(l0.size.height, 62.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 8.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_child_margin" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_child_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 50.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_child_top" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_child_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 55.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_height_with_padding_border_with_wrap" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_height_with_padding_border_with_wrap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node10, node11], + ) + let node = taffy.new_with_children(Style::default(), [node0, node1]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 5.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 10.0) + assert_eq(l01.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 100.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 10.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 45.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 10.0) + assert_eq(l11.size.height, 20.0) + assert_eq(l11.location.x, 10.0) + assert_eq(l11.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_max_size(Size(width=auto(), height=percent(0.5))), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 20.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 10.0) + assert_eq(l01.location.y, 15.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_max_height_with_align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_max_height_with_align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(150.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 25.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 150.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, -25.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_max_height_with_padding_border" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_max_height_with_padding_border.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(150.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(150.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node10, node11], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 45.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 150.0) + assert_eq(l01.location.x, 30.0) + assert_eq(l01.location.y, -25.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 100.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 10.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 20.0) + assert_eq(l10.location.y, 90.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 10.0) + assert_eq(l11.size.height, 150.0) + assert_eq(l11.location.x, 30.0) + assert_eq(l11.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=percent(1.0))), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 45.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 10.0) + assert_eq(l01.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_min_height_with_align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 45.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))), + [node10, node11], + ) + let node20 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node21 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))), + [node20, node21], + ) + let node30 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node31 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node3 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))), + [node30, node31], + ) + let node = taffy.new_with_children(Style::default(), [ + node0, node1, node2, node3, + ]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 400.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 5.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 10.0) + assert_eq(l01.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 100.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 10.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 45.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 10.0) + assert_eq(l11.size.height, 20.0) + assert_eq(l11.location.x, 10.0) + assert_eq(l11.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 200.0) + assert_eq(l2.location.y, 0.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 10.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 45.0) + let l21 = taffy.layout(node21) + assert_eq(l21.size.width, 10.0) + assert_eq(l21.size.height, 20.0) + assert_eq(l21.location.x, 10.0) + assert_eq(l21.location.y, 40.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 100.0) + assert_eq(l3.size.height, 100.0) + assert_eq(l3.location.x, 300.0) + assert_eq(l3.location.y, 0.0) + let l30 = taffy.layout(node30) + assert_eq(l30.size.width, 10.0) + assert_eq(l30.size.height, 10.0) + assert_eq(l30.location.x, 0.0) + assert_eq(l30.location.y, 45.0) + let l31 = taffy.layout(node31) + assert_eq(l31.size.width, 10.0) + assert_eq(l31.size.height, 20.0) + assert_eq(l31.location.x, 10.0) + assert_eq(l31.location.y, 40.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part15_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part15_test.mbt new file mode 100644 index 0000000..65842af --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part15_test.mbt @@ -0,0 +1,1087 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/align_items_center_with_min_height_with_padding_border" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_min_height_with_padding_border.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(8.0), + top=length(8.0), + bottom=length(8.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(7.0), + top=length(7.0), + bottom=length(7.0), + ), + ), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(8.0), + top=length(8.0), + bottom=length(8.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(7.0), + top=length(7.0), + bottom=length(7.0), + ), + ), + [node10, node11], + ) + let node = taffy.new_with_children(Style::default(), [node0, node1]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 15.0) + assert_eq(l00.location.y, 45.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 25.0) + assert_eq(l01.location.y, 40.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 100.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 10.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 15.0) + assert_eq(l10.location.y, 20.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 10.0) + assert_eq(l11.size.height, 20.0) + assert_eq(l11.location.x, 25.0) + assert_eq(l11.location.y, 15.0) +} + +///| +test "upstream/generated/flex/align_items_flex_end" { + // Ported from taffy-reference/tests/generated/flex/align_items_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_items_flex_end_child_with_margin_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/align_items_flex_end_child_with_margin_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_flex_end()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 70.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 10.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_flex_end_child_without_margin_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/align_items_flex_end_child_without_margin_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(70.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_flex_end()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 70.0) + assert_eq(l0.size.height, 70.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, -10.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 70.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_items_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_min_max" { + // Ported from taffy-reference/tests/generated/flex/align_items_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_size(Size(width=auto(), height=length(100.0))) + .with_min_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=length(200.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_stretch" { + // Ported from taffy-reference/tests/generated/flex/align_items_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_stretch_min_cross" { + // Ported from taffy-reference/tests/generated/flex/align_items_stretch_min_cross.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=auto(), height=length(36.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_min_size(Size(width=length(400.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 400.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 400.0) + assert_eq(l0.size.height, 36.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_self_baseline" { + // Ported from taffy-reference/tests/generated/flex/align_self_baseline.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_baseline()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_align_self(align_items_baseline()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_self_center" { + // Ported from taffy-reference/tests/generated/flex/align_self_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 45.0) +} + +///| +test "upstream/generated/flex/align_self_center_undefined_max_height" { + // Ported from taffy-reference/tests/generated/flex/align_self_center_undefined_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(240.0), height=length(44.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_size(Size(width=length(40.0), height=length(56.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(280.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(52.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 280.0) + assert_eq(lnode.size.height, 56.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 240.0) + assert_eq(l0.size.height, 44.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 40.0) + assert_eq(l1.size.height, 56.0) + assert_eq(l1.location.x, 240.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_self_flex_end" { + // Ported from taffy-reference/tests/generated/flex/align_self_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_flex_end()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_self_flex_end_override_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_self_flex_end_override_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_flex_end()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_self_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_self_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_flex_start()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_stretch_should_size_based_on_parent" { + // Ported from taffy-reference/tests/generated/flex/align_stretch_should_size_based_on_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_flex_grow(0.0) + .with_flex_shrink(1.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 20.0) + assert_eq(l000.size.height, 20.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/android_news_feed" { + // Ported from taffy-reference/tests/generated/flex/android_news_feed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000000 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(0.0) + .with_size(Size(width=length(120.0), height=length(120.0))), + ) + let node00000 = taffy.new_with_children( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(0.0), + [node000000], + ) + let node000010 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0), + ) + let node000011 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0), + ) + let node00001 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(36.0), + top=length(0.0), + bottom=length(0.0), + ), + ) + .with_padding( + Rect( + left=length(36.0), + right=length(36.0), + top=length(21.0), + bottom=length(18.0), + ), + ), + [node000010, node000011], + ) + let node0000 = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_start()) + .with_align_content(align_content_stretch()) + .with_margin( + Rect( + left=length(36.0), + right=length(0.0), + top=length(24.0), + bottom=length(0.0), + ), + ), + [node00000, node00001], + ) + let node000 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()), + [node0000], + ) + let node001000 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(0.0) + .with_size(Size(width=length(72.0), height=length(72.0))), + ) + let node00100 = taffy.new_with_children( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(0.0), + [node001000], + ) + let node001010 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0), + ) + let node001011 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0), + ) + let node00101 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(36.0), + top=length(0.0), + bottom=length(0.0), + ), + ) + .with_padding( + Rect( + left=length(36.0), + right=length(36.0), + top=length(21.0), + bottom=length(18.0), + ), + ), + [node001010, node001011], + ) + let node0010 = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_start()) + .with_align_content(align_content_stretch()) + .with_margin( + Rect( + left=length(174.0), + right=length(0.0), + top=length(24.0), + bottom=length(0.0), + ), + ), + [node00100, node00101], + ) + let node001 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()), + [node0010], + ) + let node00 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()), + [node000, node001], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_shrink(0.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()) + .with_flex_shrink(0.0) + .with_size(Size(width=length(1080.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 1080.0) + assert_eq(lnode.size.height, 240.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 1080.0) + assert_eq(l0.size.height, 240.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 1080.0) + assert_eq(l00.size.height, 240.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 1080.0) + assert_eq(l000.size.height, 144.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l0000 = taffy.layout(node0000) + assert_eq(l0000.size.width, 1044.0) + assert_eq(l0000.size.height, 120.0) + assert_eq(l0000.location.x, 36.0) + assert_eq(l0000.location.y, 24.0) + let l00000 = taffy.layout(node00000) + assert_eq(l00000.size.width, 120.0) + assert_eq(l00000.size.height, 120.0) + assert_eq(l00000.location.x, 0.0) + assert_eq(l00000.location.y, 0.0) + let l000000 = taffy.layout(node000000) + assert_eq(l000000.size.width, 120.0) + assert_eq(l000000.size.height, 120.0) + assert_eq(l000000.location.x, 0.0) + assert_eq(l000000.location.y, 0.0) + let l00001 = taffy.layout(node00001) + assert_eq(l00001.size.width, 72.0) + assert_eq(l00001.size.height, 39.0) + assert_eq(l00001.location.x, 120.0) + assert_eq(l00001.location.y, 0.0) + let l000010 = taffy.layout(node000010) + assert_eq(l000010.size.width, 0.0) + assert_eq(l000010.size.height, 0.0) + assert_eq(l000010.location.x, 36.0) + assert_eq(l000010.location.y, 21.0) + let l000011 = taffy.layout(node000011) + assert_eq(l000011.size.width, 0.0) + assert_eq(l000011.size.height, 0.0) + assert_eq(l000011.location.x, 36.0) + assert_eq(l000011.location.y, 21.0) + let l001 = taffy.layout(node001) + assert_eq(l001.size.width, 1080.0) + assert_eq(l001.size.height, 96.0) + assert_eq(l001.location.x, 0.0) + assert_eq(l001.location.y, 144.0) + let l0010 = taffy.layout(node0010) + assert_eq(l0010.size.width, 906.0) + assert_eq(l0010.size.height, 72.0) + assert_eq(l0010.location.x, 174.0) + assert_eq(l0010.location.y, 24.0) + let l00100 = taffy.layout(node00100) + assert_eq(l00100.size.width, 72.0) + assert_eq(l00100.size.height, 72.0) + assert_eq(l00100.location.x, 0.0) + assert_eq(l00100.location.y, 0.0) + let l001000 = taffy.layout(node001000) + assert_eq(l001000.size.width, 72.0) + assert_eq(l001000.size.height, 72.0) + assert_eq(l001000.location.x, 0.0) + assert_eq(l001000.location.y, 0.0) + let l00101 = taffy.layout(node00101) + assert_eq(l00101.size.width, 72.0) + assert_eq(l00101.size.height, 39.0) + assert_eq(l00101.location.x, 72.0) + assert_eq(l00101.location.y, 0.0) + let l001010 = taffy.layout(node001010) + assert_eq(l001010.size.width, 0.0) + assert_eq(l001010.size.height, 0.0) + assert_eq(l001010.location.x, 36.0) + assert_eq(l001010.location.y, 21.0) + let l001011 = taffy.layout(node001011) + assert_eq(l001011.size.width, 0.0) + assert_eq(l001011.size.height, 0.0) + assert_eq(l001011.location.x, 36.0) + assert_eq(l001011.location.y, 21.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_max_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_max_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=auto(), height=length(20.0))) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_min_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_min_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_min_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_width_flex" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_width_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_stretch_fill_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_stretch_fill_max_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part16_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part16_test.mbt new file mode 100644 index 0000000..5bfd592 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part16_test.mbt @@ -0,0 +1,1166 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_stretch_fill_max_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=auto(), height=length(20.0))) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_stretch_fill_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_max_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_max_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=auto(), height=length(20.0))) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_min_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_min_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_min_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_width_flex" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_width_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_stretch_fill_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_stretch_fill_max_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_stretch_fill_max_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=auto(), height=length(20.0))) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_stretch_fill_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_10343_block" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_10343_block.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf(Style::default()) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_flex()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_space_around()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 210.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 90.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 90.0) + assert_eq(l000.size.height, 0.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_10343_flex" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_10343_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf(Style::default()) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_flex()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_space_around()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 210.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 90.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 0.0) + assert_eq(l000.size.height, 200.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_10343_grid" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_10343_grid.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf(Style::default()) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_flex()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_space_around()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 210.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 90.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 90.0) + assert_eq(l000.size.height, 200.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_7976_3_level" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_7976_3_level.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(1.0), height=percent(1.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_min_size(Size(width=length(40.0), height=length(40.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_start()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 190.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 30.0) + assert_eq(l00.size.height, 180.0) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) +} + +///| +test "upstream/generated/flex/bevy_issue_7976_4_level" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_7976_4_level.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf(Style::default()) + let node00 = taffy.new_with_children( + Style::default() + .with_size(Size(width=percent(1.0), height=percent(1.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_min_size(Size(width=length(40.0), height=length(40.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_start()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 190.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 30.0) + assert_eq(l00.size.height, 180.0) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 0.0) + assert_eq(l000.size.height, 170.0) + assert_eq(l000.location.x, 5.0) + assert_eq(l000.location.y, 5.0) +} + +///| +test "upstream/generated/flex/bevy_issue_7976_reduced" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_7976_reduced.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_start()) + .with_size(Size(width=auto(), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 40.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 200.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_8017" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_8017.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_gap(Size(width=length(8.0), height=length(8.0))) + .with_size(Size(width=percent(1.0), height=percent(0.5))), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_gap(Size(width=length(8.0), height=length(8.0))) + .with_size(Size(width=percent(1.0), height=percent(0.5))), + [node10, node11], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_gap(Size(width=length(8.0), height=length(8.0))) + .with_size(Size(width=length(400.0), height=length(400.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(8.0), + top=length(8.0), + bottom=length(8.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 400.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 384.0) + assert_eq(l0.size.height, 188.0) + assert_eq(l0.location.x, 8.0) + assert_eq(l0.location.y, 8.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 188.0) + assert_eq(l00.size.height, 188.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 188.0) + assert_eq(l01.size.height, 188.0) + assert_eq(l01.location.x, 196.0) + assert_eq(l01.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 384.0) + assert_eq(l1.size.height, 188.0) + assert_eq(l1.location.x, 8.0) + assert_eq(l1.location.y, 204.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 188.0) + assert_eq(l10.size.height, 188.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 188.0) + assert_eq(l11.size.height, 188.0) + assert_eq(l11.location.x, 196.0) + assert_eq(l11.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_8017_reduced" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_8017_reduced.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=auto(), height=percent(0.5))), + [node00], + ) + let node10 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_with_children( + Style::default().with_size(Size(width=auto(), height=percent(0.5))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_gap(Size(width=length(8.0), height=length(8.0))) + .with_size(Size(width=length(200.0), height=length(400.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 196.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 196.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 196.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 204.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 0.0) + assert_eq(l10.size.height, 196.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_8082" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_8082.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node03 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_flex_start()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_stretch()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_flex_start()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 140.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 40.0) + assert_eq(l00.location.y, 10.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 50.0) + assert_eq(l01.size.height, 50.0) + assert_eq(l01.location.x, 110.0) + assert_eq(l01.location.y, 10.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 50.0) + assert_eq(l02.size.height, 50.0) + assert_eq(l02.location.x, 40.0) + assert_eq(l02.location.y, 80.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 50.0) + assert_eq(l03.size.height, 50.0) + assert_eq(l03.location.x, 110.0) + assert_eq(l03.location.y, 80.0) +} + +///| +test "upstream/generated/flex/bevy_issue_8082_percent" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_8082_percent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node02 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node03 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_flex_start()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=percent(0.5), height=auto())), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_stretch()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_flex_start()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 50.0) + assert_eq(l01.size.height, 50.0) + assert_eq(l01.location.x, 50.0) + assert_eq(l01.location.y, 0.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 50.0) + assert_eq(l02.size.height, 50.0) + assert_eq(l02.location.x, 0.0) + assert_eq(l02.location.y, 50.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 50.0) + assert_eq(l03.size.height, 50.0) + assert_eq(l03.location.x, 50.0) + assert_eq(l03.location.y, 50.0) +} + +///| +test "upstream/generated/flex/bevy_issue_9530" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_9530.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=percent(1.0), height=length(20.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=length(50.0))), + ) + let node11 = taffy.new_leaf_with_context( + Style::default() + .with_align_items(align_items_center()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + { + text_content: "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", + writing_mode: Horizontal, + }, + ) + let node12 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=length(50.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=percent(1.0), height=auto())) + .with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ) + .with_padding( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + [node10, node11, node12], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_align_content(align_content_center()) + .with_size(Size(width=length(300.0), height=length(300.0))) + .with_margin(Rect(left=auto(), right=auto(), top=auto(), bottom=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 300.0) + assert_eq(lnode.size.height, 300.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 300.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 300.0) + assert_eq(l1.size.height, 420.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 260.0) + assert_eq(l10.size.height, 50.0) + assert_eq(l10.location.x, 20.0) + assert_eq(l10.location.y, 20.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 220.0) + assert_eq(l11.size.height, 240.0) + assert_eq(l11.location.x, 40.0) + assert_eq(l11.location.y, 90.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 260.0) + assert_eq(l12.size.height, 50.0) + assert_eq(l12.location.x, 20.0) + assert_eq(l12.location.y, 350.0) +} + +///| +test "upstream/generated/flex/bevy_issue_9530_reduced" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_9530_reduced.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context( + Style::default().with_flex_grow(1.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(40.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 40.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 40.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part17_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part17_test.mbt new file mode 100644 index 0000000..225ec04 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part17_test.mbt @@ -0,0 +1,887 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/bevy_issue_9530_reduced2" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_9530_reduced2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context( + Style::default().with_flex_grow(1.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(80.0), height=auto())) + .with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 120.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 80.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_9530_reduced3" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_9530_reduced3.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(80.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 40.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_9530_reduced4" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_9530_reduced4.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(80.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 80.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 20.0) +} + +///| +test "upstream/generated/flex/blitz_issue_88" { + // Ported from taffy-reference/tests/generated/flex/blitz_issue_88.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)), + { + text_content: "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", + writing_mode: Horizontal, + }, + ) + let node00 = taffy.new_with_children( + Style::default().with_display(display_flex()).with_flex_grow(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_start()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(600.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 600.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 600.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 600.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 600.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/border_center_child" { + // Ported from taffy-reference/tests/generated/flex/border_center_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_border( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(20.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 45.0) + assert_eq(l0.location.y, 40.0) +} + +///| +test "upstream/generated/flex/border_container_match_child" { + // Ported from taffy-reference/tests/generated/flex/border_container_match_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 30.0) + assert_eq(lnode.size.height, 30.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/border_flex_child" { + // Ported from taffy-reference/tests/generated/flex/border_flex_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/border_no_child" { + // Ported from taffy-reference/tests/generated/flex/border_no_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default().with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/border_no_size" { + // Ported from taffy-reference/tests/generated/flex/border_no_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/border_stretch_child" { + // Ported from taffy-reference/tests/generated/flex/border_stretch_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/child_min_max_width_flexing" { + // Ported from taffy-reference/tests/generated/flex/child_min_max_width_flexing.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(0.0) + .with_flex_basis(length(0.0)) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(0.0) + .with_flex_basis(percent(0.5)) + .with_max_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_stretch()) + .with_size(Size(width=length(120.0), height=length(50.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 120.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 100.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/child_with_padding_align_end" { + // Ported from taffy-reference/tests/generated/flex/child_with_padding_align_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_flex_end()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 100.0) + assert_eq(l0.location.y, 100.0) +} + +///| +test "upstream/generated/flex/container_with_unsized_child" { + // Ported from taffy-reference/tests/generated/flex/container_with_unsized_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/content_size" { + // Ported from taffy-reference/tests/generated/flex/content_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_flex_shrink(0.0) + .with_size(Size(width=percent(1.0), height=length(20.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(-10.0), bottom=auto()), + ), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=auto(), height=length(30.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 85.0, 30.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 85.0, 20.0, 0.0, -10.0) +} + +///| +test "upstream/generated/flex/display_none" { + // Ported from taffy-reference/tests/generated/flex/display_none.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node1 = taffy.new_leaf( + Style::default().with_display(display_none()).with_flex_grow(1.0), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/display_none_absolute_child" { + // Ported from taffy-reference/tests/generated/flex/display_none_absolute_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_none()) + .with_position(position_absolute()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_inset( + Rect(left=length(10.0), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/display_none_fixed_size" { + // Ported from taffy-reference/tests/generated/flex/display_none_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_none()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/display_none_only_node" { + // Ported from taffy-reference/tests/generated/flex/display_none_only_node.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 0.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/display_none_with_child" { + // Ported from taffy-reference/tests/generated/flex/display_none_with_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_none()) + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + [node10], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 0.0) + assert_eq(l10.size.height, 0.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/display_none_with_margin" { + // Ported from taffy-reference/tests/generated/flex/display_none_with_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_none()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/display_none_with_position" { + // Ported from taffy-reference/tests/generated/flex/display_none_with_position.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_none()) + .with_flex_grow(1.0) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/display_none_with_position_absolute" { + // Ported from taffy-reference/tests/generated/flex/display_none_with_position_absolute.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_none()) + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" { + // Ported from taffy-reference/tests/generated/flex/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_position(position_absolute()) + .with_flex_direction(flex_direction_column()) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 100.0, 100.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_and_main_dimen_set_when_flexing" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_and_main_dimen_set_when_flexing.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(10.0)) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(10.0)) + .with_size(Size(width=length(0.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_flex_grow_column" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_flex_grow_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(length(50.0)), + ) + let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 75.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 25.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 75.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part18_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part18_test.mbt new file mode 100644 index 0000000..71c9a1e --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part18_test.mbt @@ -0,0 +1,987 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/flex_basis_flex_grow_row" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_flex_grow_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(length(50.0)), + ) + let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 75.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 25.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 75.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_flex_shrink_column" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_flex_shrink_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_basis(length(100.0))) + let node1 = taffy.new_leaf(Style::default().with_flex_basis(length(50.0))) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 67.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 33.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 67.0) +} + +///| +test "upstream/generated/flex/flex_basis_flex_shrink_row" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_flex_shrink_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_basis(length(100.0))) + let node1 = taffy.new_leaf(Style::default().with_flex_basis(length(50.0))) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 67.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 33.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 67.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_larger_than_content_column" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_larger_than_content_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_basis(length(50.0)), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_larger_than_content_row" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_larger_than_content_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_basis(length(50.0)), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_overrides_main_size" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_overrides_main_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(50.0)) + .with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 60.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 80.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(length(60.0)), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(100.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)), + [node10], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 80.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 100.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_smaller_than_content_column" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_than_content_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_basis(length(50.0)), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_smaller_than_content_row" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_than_content_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_basis(length(50.0)), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_smaller_than_main_dimen_column" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_than_main_dimen_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(10.0)) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_smaller_than_main_dimen_row" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_than_main_dimen_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(10.0)) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_smaller_then_content_with_flex_grow_large_size" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_large_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(100.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)), + [node10], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 70.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 70.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 100.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_smaller_then_content_with_flex_grow_small_size" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_small_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(100.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)), + [node10], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(10.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 10.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 70.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 70.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 100.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(100.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)), + [node10], + ) + let node = taffy.new_with_children(Style::default(), [node0, node1]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 90.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 70.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 70.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 100.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_smaller_then_content_with_flex_grow_very_large_size" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(100.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)), + [node10], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 100.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 100.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_unconstraint_column" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_unconstraint_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(50.0)) + .with_size(Size(width=length(100.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_unconstraint_row" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_unconstraint_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(50.0)) + .with_size(Size(width=auto(), height=length(100.0))), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_basis_zero_undefined_main_size" { + // Ported from taffy-reference/tests/generated/flex/flex_basis_zero_undefined_main_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(50.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_basis(length(0.0)), + [node00], + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_column_relative_all_sides" { + // Ported from taffy-reference/tests/generated/flex/flex_column_relative_all_sides.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/flex_direction_column" { + // Ported from taffy-reference/tests/generated/flex/flex_direction_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/flex/flex_direction_column_no_height" { + // Ported from taffy-reference/tests/generated/flex/flex_direction_column_no_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 30.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/flex/flex_direction_column_reverse" { + // Ported from taffy-reference/tests/generated/flex/flex_direction_column_reverse.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 80.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 70.0) +} + +///| +test "upstream/generated/flex/flex_direction_column_reverse_no_height" { + // Ported from taffy-reference/tests/generated/flex/flex_direction_column_reverse_no_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column_reverse()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 30.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 20.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_direction_row" { + // Ported from taffy-reference/tests/generated/flex/flex_direction_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_direction_row_no_width" { + // Ported from taffy-reference/tests/generated/flex/flex_direction_row_no_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=auto(), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 30.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part19_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part19_test.mbt new file mode 100644 index 0000000..f506386 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part19_test.mbt @@ -0,0 +1,1003 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/flex_direction_row_reverse" { + // Ported from taffy-reference/tests/generated/flex/flex_direction_row_reverse.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_row_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 90.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 80.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 70.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_child" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)) + .with_size(Size(width=auto(), height=length(100.0))), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_flex_basis_percent_min_max" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_flex_basis_percent_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(0.0) + .with_flex_basis(length(0.0)) + .with_size(Size(width=auto(), height=length(20.0))) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(0.0) + .with_flex_basis(percent(0.5)) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_max_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(120.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 120.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 100.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_height_maximized" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_height_maximized.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(length(200.0)), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(500.0))), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 500.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 400.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 100.0) + assert_eq(l01.size.height, 100.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 400.0) +} + +///| +test "upstream/generated/flex/flex_grow_in_at_most_container" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_in_at_most_container.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(length(0.0)), + ) + let node0 = taffy.new_with_children(Style::default(), [node00]) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 0.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_less_than_factor_one" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_less_than_factor_one.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(0.2) + .with_flex_shrink(0.0) + .with_flex_basis(length(40.0)), + ) + let node1 = taffy.new_leaf( + Style::default().with_flex_grow(0.2).with_flex_shrink(0.0), + ) + let node2 = taffy.new_leaf( + Style::default().with_flex_grow(0.4).with_flex_shrink(0.0), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 132.0) + assert_eq(l0.size.height, 200.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 92.0) + assert_eq(l1.size.height, 200.0) + assert_eq(l1.location.x, 132.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 184.0) + assert_eq(l2.size.height, 200.0) + assert_eq(l2.location.x, 224.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_root_minimized" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_root_minimized.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(length(200.0)), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(500.0))), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 300.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 300.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 100.0) + assert_eq(l01.size.height, 100.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 200.0) +} + +///| +test "upstream/generated/flex/flex_grow_shrink_at_most" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_shrink_at_most.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node0 = taffy.new_with_children(Style::default(), [node00]) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_to_min" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_to_min.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(500.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_constrained_max_column" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_max_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_shrink(1.0).with_flex_basis(length(100.0)), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 67.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 33.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 67.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_constrained_max_row" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_max_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_flex_shrink(1.0).with_flex_basis(length(100.0)), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=length(100.0), height=auto())), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 67.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 33.0) + assert_eq(l01.size.height, 100.0) + assert_eq(l01.location.x, 67.0) + assert_eq(l01.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_constrained_max_width" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_max_size(Size(width=length(300.0), height=auto())), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 200.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_constrained_min_column" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_min_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_min_size(Size(width=auto(), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_constrained_min_max_column" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_min_max_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_constrained_min_row" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_min_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=auto(), height=length(100.0))) + .with_min_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_max_width" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_max_size(Size(width=length(100.0), height=auto())), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_row_relative_all_sides" { + // Ported from taffy-reference/tests/generated/flex/flex_row_relative_all_sides.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/flex_shrink_by_outer_margin_with_max_size" { + // Ported from taffy-reference/tests/generated/flex/flex_shrink_by_outer_margin_with_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(100.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(80.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 80.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 100.0) +} + +///| +test "upstream/generated/flex/flex_shrink_flex_grow_child_flex_shrink_other_child" { + // Ported from taffy-reference/tests/generated/flex/flex_shrink_flex_grow_child_flex_shrink_other_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(0.0) + .with_flex_shrink(1.0) + .with_size(Size(width=length(500.0), height=length(100.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_size(Size(width=length(500.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 250.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 250.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 250.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_shrink_flex_grow_row" { + // Ported from taffy-reference/tests/generated/flex/flex_shrink_flex_grow_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(0.0) + .with_flex_shrink(1.0) + .with_size(Size(width=length(500.0), height=length(100.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(0.0) + .with_flex_shrink(1.0) + .with_size(Size(width=length(500.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 250.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 250.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 250.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_shrink_to_zero" { + // Ported from taffy-reference/tests/generated/flex/flex_shrink_to_zero.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_shrink(1.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(75.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 75.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_wrap_align_stretch_fits_one_row" { + // Ported from taffy-reference/tests/generated/flex/flex_wrap_align_stretch_fits_one_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_wrap_children_with_min_main_overriding_flex_basis" { + // Ported from taffy-reference/tests/generated/flex/flex_wrap_children_with_min_main_overriding_flex_basis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(50.0)) + .with_size(Size(width=auto(), height=length(50.0))) + .with_min_size(Size(width=length(55.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(50.0)) + .with_size(Size(width=auto(), height=length(50.0))) + .with_min_size(Size(width=length(55.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 55.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 55.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/flex/flex_wrap_wrap_to_child_height" { + // Ported from taffy-reference/tests/generated/flex/flex_wrap_wrap_to_child_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=auto())), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_flex_start()), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 100.0) + assert_eq(l000.size.height, 100.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 100.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_child_margins" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_child_margins.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect( + left=length(2.0), + right=length(2.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect( + left=length(15.0), + right=length(15.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(80.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 2.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 2.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 2.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 26.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 2.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 63.0) + assert_eq(l2.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part20_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part20_test.mbt new file mode 100644 index 0000000..252382e --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part20_test.mbt @@ -0,0 +1,1311 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/gap_column_gap_determines_parent_width" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_determines_parent_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_stretch()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=auto(), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 20.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_flexible" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_flexible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(80.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_flexible_undefined_parent" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_flexible_undefined_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=auto(), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 0.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_inflexible" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_inflexible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(80.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_inflexible_undefined_parent" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_inflexible_undefined_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=auto(), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_justify_center" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 40.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 70.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_justify_flex_end" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_flex_end()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 80.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_justify_flex_start" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_flex_start()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_justify_space_around" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_space_around.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_around()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 3.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 40.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 77.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_justify_space_between" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_space_between.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_between()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 40.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 80.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_justify_space_evenly" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_space_evenly.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_evenly()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 40.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 75.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_mixed_flexible" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_mixed_flexible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(80.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_cyclic_partially_shrinkable" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_cyclic_partially_shrinkable.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default().with_gap(Size(width=percent(0.5), height=length(0.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 60.0) + assert_eq(lnode.size.height, 40.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 80.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_cyclic_shrinkable" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_cyclic_shrinkable.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default().with_gap(Size(width=percent(0.2), height=length(0.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 60.0) + assert_eq(lnode.size.height, 40.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 12.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 12.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 24.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 12.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 48.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_cyclic_unshrinkable" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_cyclic_unshrinkable.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default().with_gap(Size(width=percent(0.2), height=length(0.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 60.0) + assert_eq(lnode.size.height, 40.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 32.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 64.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_flexible" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_flexible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=percent(0.1), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 27.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 26.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 37.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 27.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 73.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_flexible_with_padding" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_flexible_with_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=percent(0.1), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 21.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 22.0) + assert_eq(l1.size.height, 80.0) + assert_eq(l1.location.x, 39.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 21.0) + assert_eq(l2.size.height, 80.0) + assert_eq(l2.location.x, 69.0) + assert_eq(l2.location.y, 10.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_inflexible" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_inflexible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=percent(0.2), height=length(0.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 40.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 80.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_row_gap_wrapping" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_row_gap_wrapping.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node6 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node8 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(80.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 40.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 40.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 40.0) + let l6 = taffy.layout(node6) + assert_eq(l6.size.width, 20.0) + assert_eq(l6.size.height, 20.0) + assert_eq(l6.location.x, 0.0) + assert_eq(l6.location.y, 80.0) + let l7 = taffy.layout(node7) + assert_eq(l7.size.width, 20.0) + assert_eq(l7.size.height, 20.0) + assert_eq(l7.location.x, 30.0) + assert_eq(l7.location.y, 80.0) + let l8 = taffy.layout(node8) + assert_eq(l8.size.width, 20.0) + assert_eq(l8.size.height, 20.0) + assert_eq(l8.location.x, 60.0) + assert_eq(l8.location.y, 80.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_start_index" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_start_index.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(80.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 30.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 60.0) + assert_eq(l3.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_center" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_center()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 20.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 60.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 60.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 60.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_flex_end" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_end()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 40.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 40.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 80.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 80.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 80.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_flex_start" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_start()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 40.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 40.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 40.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_space_around" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_space_around.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_around()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 70.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 70.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 70.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_space_between" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_space_between.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_between()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 80.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 80.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 80.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part21_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part21_test.mbt new file mode 100644 index 0000000..65b8dc9 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part21_test.mbt @@ -0,0 +1,1301 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_stretch" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_gap(Size(width=length(5.0), height=length(0.0))) + .with_size(Size(width=length(300.0), height=length(300.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 300.0) + assert_eq(lnode.size.height, 300.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 71.0) + assert_eq(l0.size.height, 150.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 72.0) + assert_eq(l1.size.height, 150.0) + assert_eq(l1.location.x, 76.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 71.0) + assert_eq(l2.size.height, 150.0) + assert_eq(l2.location.x, 153.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 71.0) + assert_eq(l3.size.height, 150.0) + assert_eq(l3.location.x, 229.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 300.0) + assert_eq(l4.size.height, 150.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 150.0) +} + +///| +test "upstream/generated/flex/gap_column_row_gap_wrapping" { + // Ported from taffy-reference/tests/generated/flex/gap_column_row_gap_wrapping.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node6 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node8 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(80.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 40.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 40.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 40.0) + let l6 = taffy.layout(node6) + assert_eq(l6.size.width, 20.0) + assert_eq(l6.size.height, 20.0) + assert_eq(l6.location.x, 0.0) + assert_eq(l6.location.y, 80.0) + let l7 = taffy.layout(node7) + assert_eq(l7.size.width, 20.0) + assert_eq(l7.size.height, 20.0) + assert_eq(l7.location.x, 30.0) + assert_eq(l7.location.y, 80.0) + let l8 = taffy.layout(node8) + assert_eq(l8.size.width, 20.0) + assert_eq(l8.size.height, 20.0) + assert_eq(l8.location.x, 60.0) + assert_eq(l8.location.y, 80.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_align_items_end" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_align_items_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_flex_end()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 90.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 0.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 90.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 0.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 200.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 0.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 200.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 0.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 200.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_align_items_stretch" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_align_items_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_stretch()) + .with_align_content(align_content_stretch()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 90.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 90.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 90.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 90.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 110.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 90.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 110.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 90.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 110.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_column_child_margins" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_column_child_margins.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(2.0), + bottom=length(2.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(15.0), + bottom=length(15.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_gap(Size(width=length(0.0), height=length(10.0))) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 42.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 2.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 42.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 66.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 42.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 143.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_determines_parent_height" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_determines_parent_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(30.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_stretch()) + .with_gap(Size(width=length(0.0), height=length(10.0))) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 80.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 50.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_percentage_wrapping" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_percentage_wrapping.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node6 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node8 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_gap(Size(width=length(10.0), height=percent(0.1))) + .with_size(Size(width=length(80.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 60.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 20.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 20.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 20.0) + let l6 = taffy.layout(node6) + assert_eq(l6.size.width, 20.0) + assert_eq(l6.size.height, 20.0) + assert_eq(l6.location.x, 0.0) + assert_eq(l6.location.y, 40.0) + let l7 = taffy.layout(node7) + assert_eq(l7.size.width, 20.0) + assert_eq(l7.size.height, 20.0) + assert_eq(l7.location.x, 30.0) + assert_eq(l7.location.y, 40.0) + let l8 = taffy.layout(node8) + assert_eq(l8.size.width, 20.0) + assert_eq(l8.size.height, 20.0) + assert_eq(l8.location.x, 60.0) + assert_eq(l8.location.y, 40.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_row_wrap_child_margins" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_row_wrap_child_margins.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(60.0), height=auto())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(2.0), + bottom=length(2.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(60.0), height=auto())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(60.0), height=auto())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(15.0), + bottom=length(15.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_gap(Size(width=length(0.0), height=length(10.0))) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 42.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 2.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 42.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 66.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 60.0) + assert_eq(l2.size.height, 42.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 143.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_cross_size_column" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_cross_size_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default().with_flex_direction(flex_direction_column()), + { text_content: "HH\u{200b}HH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 40.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_column" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default().with_flex_direction(flex_direction_column()), + { text_content: "HH\u{200b}HH", writing_mode: Vertical }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 10.0) + assert_eq(lnode.size.height, 40.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_column_nested" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_column_nested.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_flex_direction(flex_direction_column()), + { text_content: "HH\u{200b}HH", writing_mode: Vertical }, + ) + let node = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 10.0) + assert_eq(lnode.size.height, 40.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_column_wrap" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_column_wrap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_flex_direction(flex_direction_column()), + { text_content: "HH\u{200b}HH", writing_mode: Vertical }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_flex_direction(flex_direction_column()), + { text_content: "HH\u{200b}HH", writing_mode: Vertical }, + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 10.0) + assert_eq(lnode.size.height, 80.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 40.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_row" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200b}HH", + writing_mode: Horizontal, + }) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 40.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_row_nested" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_row_nested.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200b}HH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 40.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_row_wrap" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_row_wrap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200b}HH", + writing_mode: Horizontal, + }) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200b}HH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default().with_flex_wrap(flex_wrap_wrap()), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 40.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 40.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_column_center" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 35.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 45.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 55.0) +} + +///| +test "upstream/generated/flex/justify_content_column_center_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_center_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -25.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -5.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 15.0) +} + +///| +test "upstream/generated/flex/justify_content_column_center_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_center_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -35.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -5.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 25.0) +} + +///| +test "upstream/generated/flex/justify_content_column_end" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 80.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 90.0) +} + +///| +test "upstream/generated/flex/justify_content_column_end_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_end_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_end()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -50.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, -10.0) +} + +///| +test "upstream/generated/flex/justify_content_column_end_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_end_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_end()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -70.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -40.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, -10.0) +} + +///| +test "upstream/generated/flex/justify_content_column_end_reverse" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_end_reverse.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 80.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 90.0) +} + +///| +test "upstream/generated/flex/justify_content_column_flex_end" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 80.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 90.0) +} + +///| +test "upstream/generated/flex/justify_content_column_flex_end_reverse" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_flex_end_reverse.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column_reverse()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 20.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_column_flex_start" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part22_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part22_test.mbt new file mode 100644 index 0000000..af6793b --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part22_test.mbt @@ -0,0 +1,1319 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/justify_content_column_flex_start_reverse" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_flex_start_reverse.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column_reverse()) + .with_justify_content(justify_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 80.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 70.0) +} + +///| +test "upstream/generated/flex/justify_content_column_max_height_and_margin" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_max_height_and_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(80.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(100.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 180.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 100.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 30.0) +} + +///| +test "upstream/generated/flex/justify_content_column_min_height_and_margin" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_min_height_and_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=auto(), height=length(50.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(100.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 150.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 100.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 15.0) +} + +///| +test "upstream/generated/flex/justify_content_column_min_height_and_margin_bottom" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_min_height_and_margin_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=auto(), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/justify_content_column_min_height_and_margin_top" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_min_height_and_margin_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=auto(), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 20.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_around" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_around.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_space_around()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 12.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 45.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 78.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_around_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_around_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_around()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_around_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_around_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_around()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_between" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_between.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_space_between()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 45.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 90.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_between_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_between_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_between()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_between_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_between_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_between()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_evenly" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_evenly.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_space_evenly()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 18.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 45.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 73.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_evenly_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_evenly_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_evenly()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_evenly_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_evenly_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_evenly()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/justify_content_column_start" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/flex/justify_content_column_start_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_start_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_start()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/justify_content_column_start_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_start_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_start()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/justify_content_column_start_reverse" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_start_reverse.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column_reverse()) + .with_justify_content(justify_content_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 20.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_min_max" { + // Ported from taffy-reference/tests/generated/flex/justify_content_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 20.0) +} + +///| +test "upstream/generated/flex/justify_content_min_width_with_padding_child_width_greater_than_parent" { + // Ported from taffy-reference/tests/generated/flex/justify_content_min_width_with_padding_child_width_greater_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(300.0), height=length(100.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_align_content(align_content_stretch()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=length(400.0), height=auto())) + .with_padding( + Rect( + left=length(100.0), + right=length(100.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_align_content(align_content_stretch()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(1000.0), height=length(1584.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 1000.0) + assert_eq(lnode.size.height, 1584.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 1000.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 500.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 300.0) + assert_eq(l000.size.height, 100.0) + assert_eq(l000.location.x, 100.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_min_width_with_padding_child_width_lower_than_parent" { + // Ported from taffy-reference/tests/generated/flex/justify_content_min_width_with_padding_child_width_lower_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(199.0), height=length(100.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_align_content(align_content_stretch()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=length(400.0), height=auto())) + .with_padding( + Rect( + left=length(100.0), + right=length(100.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_align_content(align_content_stretch()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(1080.0), height=length(1584.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 1080.0) + assert_eq(lnode.size.height, 1584.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 1080.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 400.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 199.0) + assert_eq(l000.size.height, 100.0) + assert_eq(l000.location.x, 101.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_overflow_min_max" { + // Ported from taffy-reference/tests/generated/flex/justify_content_overflow_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(110.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 110.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, -20.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 30.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 80.0) +} + +///| +test "upstream/generated/flex/justify_content_row_center" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 35.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 45.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 55.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_flex_end" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 70.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 80.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 90.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_flex_start" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part23_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part23_test.mbt new file mode 100644 index 0000000..b279040 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part23_test.mbt @@ -0,0 +1,955 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/justify_content_row_max_width_and_margin" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_max_width_and_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(100.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=length(80.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 80.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 90.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_min_width_and_margin" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_min_width_and_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_space_around" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_space_around.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_around()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 12.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 45.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 78.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_space_between" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_space_between.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_between()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 45.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 90.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_space_evenly" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_space_evenly.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_evenly()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 25.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 0.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 75.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_and_flex_column" { + // Ported from taffy-reference/tests/generated/flex/margin_and_flex_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/margin_and_flex_row" { + // Ported from taffy-reference/tests/generated/flex/margin_and_flex_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_and_stretch_column" { + // Ported from taffy-reference/tests/generated/flex/margin_and_stretch_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_and_stretch_row" { + // Ported from taffy-reference/tests/generated/flex/margin_and_stretch_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/margin_auto_bottom" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_bottom_and_top" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_bottom_and_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 75.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_bottom_and_top_justify_center" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_bottom_and_top_justify_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 75.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 100.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 100.0) + assert_eq(l0.location.y, 75.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_and_right" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_and_right.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 150.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_and_right_column" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_and_right_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 75.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_and_right_column_and_center" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_and_right_column_and_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 75.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_and_right_stretch" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_and_right_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_stretch()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 150.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_child_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 52.0) + assert_eq(lnode.size.height, 52.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 52.0) + assert_eq(l0.size.height, 72.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_fix_right_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_fix_right_child_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(10.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 52.0) + assert_eq(lnode.size.height, 52.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 42.0) + assert_eq(l0.size.height, 72.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_right_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_right_child_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 52.0) + assert_eq(lnode.size.height, 52.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 52.0) + assert_eq(l0.size.height, 72.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_stretching_child" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_stretching_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 150.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 100.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_multiple_children_column" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_multiple_children_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 75.0) + assert_eq(l0.location.y, 25.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 75.0) + assert_eq(l1.location.y, 100.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 75.0) + assert_eq(l2.location.y, 150.0) +} + +///| +test "upstream/generated/flex/margin_auto_multiple_children_row" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_multiple_children_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 75.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 75.0) + assert_eq(l1.location.y, 75.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 150.0) + assert_eq(l2.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_right" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_right.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 75.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_top" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 150.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 75.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part24_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part24_test.mbt new file mode 100644 index 0000000..59fcdd0 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part24_test.mbt @@ -0,0 +1,769 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/margin_auto_top_and_bottom_stretch" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_top_and_bottom_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_stretch()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 50.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 150.0) +} + +///| +test "upstream/generated/flex/margin_auto_top_stretching_child" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_top_stretching_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 150.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 200.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_bottom" { + // Ported from taffy-reference/tests/generated/flex/margin_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 80.0) +} + +///| +test "upstream/generated/flex/margin_fix_left_auto_right_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/margin_fix_left_auto_right_child_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=length(10.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 52.0) + assert_eq(lnode.size.height, 52.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 42.0) + assert_eq(l0.size.height, 72.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_left" { + // Ported from taffy-reference/tests/generated/flex/margin_left.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(10.0), height=auto())) + .with_margin( + Rect( + left=length(10.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_right" { + // Ported from taffy-reference/tests/generated/flex/margin_right.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(10.0), height=auto())) + .with_margin( + Rect( + left=length(0.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 80.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_should_not_be_part_of_max_height" { + // Ported from taffy-reference/tests/generated/flex/margin_should_not_be_part_of_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(20.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(250.0), height=length(250.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 250.0) + assert_eq(lnode.size.height, 250.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 20.0) +} + +///| +test "upstream/generated/flex/margin_should_not_be_part_of_max_width" { + // Ported from taffy-reference/tests/generated/flex/margin_should_not_be_part_of_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_max_size(Size(width=length(100.0), height=auto())) + .with_margin( + Rect( + left=length(20.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(250.0), height=length(250.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 250.0) + assert_eq(lnode.size.height, 250.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_top" { + // Ported from taffy-reference/tests/generated/flex/margin_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/margin_with_sibling_column" { + // Ported from taffy-reference/tests/generated/flex/margin_with_sibling_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 45.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 45.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 55.0) +} + +///| +test "upstream/generated/flex/margin_with_sibling_row" { + // Ported from taffy-reference/tests/generated/flex/margin_with_sibling_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 45.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 45.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 55.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/max_height" { + // Ported from taffy-reference/tests/generated/flex/max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(10.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/max_height_overrides_height" { + // Ported from taffy-reference/tests/generated/flex/max_height_overrides_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(200.0))) + .with_max_size(Size(width=auto(), height=length(100.0))), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/max_height_overrides_height_on_root" { + // Ported from taffy-reference/tests/generated/flex/max_height_overrides_height_on_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(200.0))) + .with_max_size(Size(width=auto(), height=length(100.0))), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/max_width" { + // Ported from taffy-reference/tests/generated/flex/max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_max_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/max_width_overrides_width" { + // Ported from taffy-reference/tests/generated/flex/max_width_overrides_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(200.0), height=auto())) + .with_max_size(Size(width=length(100.0), height=auto())), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 0.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/max_width_overrides_width_on_root" { + // Ported from taffy-reference/tests/generated/flex/max_width_overrides_width_on_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(200.0), height=auto())) + .with_max_size(Size(width=length(100.0), height=auto())), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 0.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_child" { + // Ported from taffy-reference/tests/generated/flex/measure_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 60.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_child_absolute" { + // Ported from taffy-reference/tests/generated/flex/measure_child_absolute.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_position(position_absolute()), + { text_content: "HHHHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_child_constraint" { + // Ported from taffy-reference/tests/generated/flex/measure_child_constraint.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_child_constraint_padding_parent" { + // Ported from taffy-reference/tests/generated/flex/measure_child_constraint_padding_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 120.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/measure_child_with_flex_grow" { + // Ported from taffy-reference/tests/generated/flex/measure_child_with_flex_grow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "H\u{200b}H\u{200b}H\u{200b}H\u{200b}H", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_child_with_flex_shrink" { + // Ported from taffy-reference/tests/generated/flex/measure_child_with_flex_shrink.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_child_with_flex_shrink_hidden" { + // Ported from taffy-reference/tests/generated/flex/measure_child_with_flex_shrink_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0), + { + text_content: "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 100.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 9.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 91.0, 50.0, 9.0, 0.0) +} + +///| +test "upstream/generated/flex/measure_child_with_min_size_greater_than_available_space" { + // Ported from taffy-reference/tests/generated/flex/measure_child_with_min_size_greater_than_available_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_min_size(Size(width=length(200.0), height=auto())), + { text_content: "HHHHHHHH\u{200b}HHHHHHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part25_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part25_test.mbt new file mode 100644 index 0000000..5c2c946 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part25_test.mbt @@ -0,0 +1,710 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/measure_flex_basis_overrides_measure" { + // Ported from taffy-reference/tests/generated/flex/measure_flex_basis_overrides_measure.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "H", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_height_overrides_measure" { + // Ported from taffy-reference/tests/generated/flex/measure_height_overrides_measure.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(5.0))), + { text_content: "H", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 10.0) + assert_eq(lnode.size.height, 5.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 5.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_remeasure_child_after_growing" { + // Ported from taffy-reference/tests/generated/flex/measure_remeasure_child_after_growing.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_remeasure_child_after_shrinking" { + // Ported from taffy-reference/tests/generated/flex/measure_remeasure_child_after_shrinking.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_start()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_remeasure_child_after_stretching" { + // Ported from taffy-reference/tests/generated/flex/measure_remeasure_child_after_stretching.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_root" { + // Ported from taffy-reference/tests/generated/flex/measure_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHH", + writing_mode: Horizontal, + }) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 60.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_stretch_overrides_measure" { + // Ported from taffy-reference/tests/generated/flex/measure_stretch_overrides_measure.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(length(5.0)), + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_flex_grow(1.0).with_flex_basis(length(5.0)), + { text_content: "H", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(20.0), height=length(10.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_width_overrides_measure" { + // Ported from taffy-reference/tests/generated/flex/measure_width_overrides_measure.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(50.0), height=auto())), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_height" { + // Ported from taffy-reference/tests/generated/flex/min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=auto(), height=length(60.0))), + ) + let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 60.0) +} + +///| +test "upstream/generated/flex/min_height_larger_than_height" { + // Ported from taffy-reference/tests/generated/flex/min_height_larger_than_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(25.0))) + .with_min_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_height_overrides_height" { + // Ported from taffy-reference/tests/generated/flex/min_height_overrides_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_min_size(Size(width=auto(), height=length(100.0))), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_height_overrides_height_on_root" { + // Ported from taffy-reference/tests/generated/flex/min_height_overrides_height_on_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_min_size(Size(width=auto(), height=length(100.0))), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_height_overrides_max_height" { + // Ported from taffy-reference/tests/generated/flex/min_height_overrides_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_height_with_nested_fixed_height" { + // Ported from taffy-reference/tests/generated/flex/min_height_with_nested_fixed_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=length(40.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_self(align_items_flex_start()) + .with_flex_shrink(0.0) + .with_min_size(Size(width=auto(), height=length(28.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(8.0), + bottom=length(9.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(320.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(44.0))) + .with_padding( + Rect( + left=length(16.0), + right=length(16.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 57.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 16.0) + assert_eq(l0.location.y, 8.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 40.0) + assert_eq(l00.size.height, 40.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_max_percent_different_width_height" { + // Ported from taffy-reference/tests/generated/flex/min_max_percent_different_width_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_min_size(Size(width=percent(0.1), height=percent(0.1))) + .with_max_size(Size(width=percent(0.1), height=percent(0.1))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_flex_start()) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_max_percent_no_width_height" { + // Ported from taffy-reference/tests/generated/flex/min_max_percent_no_width_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=percent(0.1), height=percent(0.1))) + .with_max_size(Size(width=percent(0.1), height=percent(0.1))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_width" { + // Ported from taffy-reference/tests/generated/flex/min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 40.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 60.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_width_larger_than_width" { + // Ported from taffy-reference/tests/generated/flex/min_width_larger_than_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(25.0), height=auto())) + .with_min_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_width_overrides_max_width" { + // Ported from taffy-reference/tests/generated/flex/min_width_overrides_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 0.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_width_overrides_width" { + // Ported from taffy-reference/tests/generated/flex/min_width_overrides_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_min_size(Size(width=length(100.0), height=auto())), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 0.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_width_overrides_width_on_root" { + // Ported from taffy-reference/tests/generated/flex/min_width_overrides_width_on_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_min_size(Size(width=length(100.0), height=auto())), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 0.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/mod" { + // Ported from taffy-reference/tests/generated/flex/mod.rs + () +} + +///| +test "upstream/generated/flex/nested_overflowing_child" { + // Ported from taffy-reference/tests/generated/flex/nested_overflowing_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(200.0), height=length(200.0))), + ) + let node0 = taffy.new_with_children(Style::default(), [node00]) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 200.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/nested_overflowing_child_in_constraint_parent" { + // Ported from taffy-reference/tests/generated/flex/nested_overflowing_child_in_constraint_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(200.0), height=length(200.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/only_shrinkable_item_with_flex_basis_zero" { + // Ported from taffy-reference/tests/generated/flex/only_shrinkable_item_with_flex_basis_zero.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_shrink(1.0).with_flex_basis(length(0.0)), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_flex_basis(length(93.0)) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(6.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_flex_shrink(0.0).with_flex_basis(length(764.0)), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(480.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(764.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 480.0) + assert_eq(lnode.size.height, 764.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 480.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 480.0) + assert_eq(l1.size.height, 93.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 480.0) + assert_eq(l2.size.height, 764.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 99.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part26_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part26_test.mbt new file mode 100644 index 0000000..98fe620 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part26_test.mbt @@ -0,0 +1,732 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/overflow_cross_axis" { + // Ported from taffy-reference/tests/generated/flex/overflow_cross_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(200.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 200.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/overflow_main_axis" { + // Ported from taffy-reference/tests/generated/flex/overflow_main_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(200.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/overflow_main_axis_shrink_hidden" { + // Ported from taffy-reference/tests/generated/flex/overflow_main_axis_shrink_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_flex_shrink(1.0), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 50.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_main_axis_shrink_scroll" { + // Ported from taffy-reference/tests/generated/flex/overflow_main_axis_shrink_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_flex_shrink(1.0), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 50.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_main_axis_shrink_visible" { + // Ported from taffy-reference/tests/generated/flex/overflow_main_axis_shrink_visible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_flex_shrink(1.0), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 50.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scroll_main_axis_justify_content_end" { + // Ported from taffy-reference/tests/generated/flex/overflow_scroll_main_axis_justify_content_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(200.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, -100.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_overridden_by_available_space" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_overridden_by_available_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node0 = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_flex_grow(1.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_overridden_by_max_size" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_overridden_by_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_max_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_overridden_by_size" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_overridden_by_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_take_up_space_both_axis" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_take_up_space_both_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 35.0, 35.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_take_up_space_cross_axis" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_take_up_space_cross_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 35.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_take_up_space_main_axis" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_take_up_space_main_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 50.0, 35.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/padding_align_end_child" { + // Ported from taffy-reference/tests/generated/flex/padding_align_end_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_end()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 100.0) + assert_eq(l0.location.y, 100.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 22.0) + assert_eq(lnode.size.height, 14.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_min_size" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_min_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(0.0), height=length(0.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 22.0) + assert_eq(lnode.size.height, 14.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 22.0) + assert_eq(lnode.size.height, 14.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_size_flex_basis_0" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_size_flex_basis_0.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(0.0)) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(0.0)) + .with_size(Size(width=length(12.0), height=length(12.0))), + ) + let node = taffy.new_with_children(Style::default(), [node0, node1]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 34.0) + assert_eq(lnode.size.height, 14.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 12.0) + assert_eq(l1.location.x, 22.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_size_flex_basis_0_growable" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_size_flex_basis_0_growable.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)) + .with_size(Size(width=length(12.0), height=length(12.0))), + ) + let node = taffy.new_with_children(Style::default(), [node0, node1]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 34.0) + assert_eq(lnode.size.height, 14.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 28.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 6.0) + assert_eq(l1.size.height, 12.0) + assert_eq(l1.location.x, 28.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_size_root" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_size_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 22.0) + assert_eq(lnode.size.height, 14.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 15.0) + assert_eq(l0.location.y, 3.0) +} + +///| +test "upstream/generated/flex/padding_center_child" { + // Ported from taffy-reference/tests/generated/flex/padding_center_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(20.0), + top=length(10.0), + bottom=length(20.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 40.0) +} + +///| +test "upstream/generated/flex/padding_container_match_child" { + // Ported from taffy-reference/tests/generated/flex/padding_container_match_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 30.0) + assert_eq(lnode.size.height, 30.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/padding_flex_child" { + // Ported from taffy-reference/tests/generated/flex/padding_flex_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/padding_no_child" { + // Ported from taffy-reference/tests/generated/flex/padding_no_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default().with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_no_size" { + // Ported from taffy-reference/tests/generated/flex/padding_no_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default().with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 20.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_stretch_child" { + // Ported from taffy-reference/tests/generated/flex/padding_stretch_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part27_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part27_test.mbt new file mode 100644 index 0000000..15df8b2 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part27_test.mbt @@ -0,0 +1,1082 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/parent_wrap_child_size_overflowing_parent" { + // Ported from taffy-reference/tests/generated/flex/parent_wrap_child_size_overflowing_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(200.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percent_absolute_position" { + // Ported from taffy-reference/tests/generated/flex/percent_absolute_position.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=auto())), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=auto())), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(1.0), height=length(50.0))) + .with_inset( + Rect(left=percent(0.5), right=auto(), top=auto(), bottom=auto()), + ), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(60.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 60.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 30.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 30.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 30.0) + assert_eq(l01.size.height, 50.0) + assert_eq(l01.location.x, 30.0) + assert_eq(l01.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percent_within_flex_grow" { + // Ported from taffy-reference/tests/generated/flex/percent_within_flex_grow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=auto())), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=auto())), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0), + [node10], + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(350.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 350.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 150.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 100.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 150.0) + assert_eq(l10.size.height, 0.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 250.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_absolute_position" { + // Ported from taffy-reference/tests/generated/flex/percentage_absolute_position.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=percent(0.3), right=auto(), top=percent(0.1), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/percentage_container_in_wrapping_container" { + // Ported from taffy-reference/tests/generated/flex/percentage_container_in_wrapping_container.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node001 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=percent(1.0), height=auto())), + [node000, node001], + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 75.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 50.0) + assert_eq(l000.size.height, 50.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l001 = taffy.layout(node001) + assert_eq(l001.size.width, 50.0) + assert_eq(l001.size.height, 50.0) + assert_eq(l001.location.x, 50.0) + assert_eq(l001.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_different_width_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_different_width_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=percent(0.3))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=percent(0.3))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(300.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 300.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 90.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 90.0) + assert_eq(l1.location.x, 200.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_different_width_height_column" { + // Ported from taffy-reference/tests/generated/flex/percentage_different_width_height_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=percent(0.3))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(300.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 300.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 210.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 90.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 210.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(percent(0.5)), + ) + let node1 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(percent(0.25)), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 125.0) + assert_eq(l0.size.height, 200.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 75.0) + assert_eq(l1.size.height, 200.0) + assert_eq(l1.location.x, 125.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_cross" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_cross.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(percent(0.5)), + ) + let node1 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(percent(0.25)), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 250.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 150.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 250.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_cross_max_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_cross_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=auto(), height=percent(0.6))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=auto(), height=percent(0.2))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 240.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 80.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 240.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_cross_max_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_cross_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=percent(0.6), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.15)) + .with_max_size(Size(width=percent(0.2), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 120.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 40.0) + assert_eq(l1.size.height, 300.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 100.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_cross_min_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_cross_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=auto(), height=percent(0.6))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(2.0) + .with_min_size(Size(width=auto(), height=percent(0.1))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 240.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 160.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 240.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_cross_min_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_cross_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.1)) + .with_min_size(Size(width=percent(0.6), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.15)) + .with_min_size(Size(width=percent(0.2), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 300.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 100.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_main_max_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_main_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=auto(), height=percent(0.6))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=auto(), height=percent(0.2))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(400.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 52.0) + assert_eq(l0.size.height, 240.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 148.0) + assert_eq(l1.size.height, 80.0) + assert_eq(l1.location.x, 52.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_main_max_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_main_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.15)) + .with_max_size(Size(width=percent(0.6), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=percent(0.2), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(400.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 120.0) + assert_eq(l0.size.height, 400.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 40.0) + assert_eq(l1.size.height, 400.0) + assert_eq(l1.location.x, 120.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_main_min_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_main_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.15)) + .with_min_size(Size(width=percent(0.6), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.1)) + .with_min_size(Size(width=percent(0.2), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(400.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 120.0) + assert_eq(l0.size.height, 400.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 80.0) + assert_eq(l1.size.height, 400.0) + assert_eq(l1.location.x, 120.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_main_max_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_main_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default().with_flex_basis(length(15.0))) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(48.0)) + .with_max_size(Size(width=auto(), height=percent(0.33))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_flex_start()) + .with_size(Size(width=auto(), height=length(151.0))), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(71.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 71.0) + assert_eq(lnode.size.height, 151.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 71.0) + assert_eq(l0.size.height, 151.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 15.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 0.0) + assert_eq(l01.size.height, 48.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 15.0) +} + +///| +test "upstream/generated/flex/percentage_margin_should_calculate_based_only_on_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_margin_should_calculate_based_only_on_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_margin( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 160.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 20.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_moderate_complexity" { + // Ported from taffy-reference/tests/generated/flex/percentage_moderate_complexity.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=percent(0.03), + right=percent(0.03), + top=percent(0.03), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=auto())) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) +} + +///| +test "upstream/generated/flex/percentage_moderate_complexity2" { + // Ported from taffy-reference/tests/generated/flex/percentage_moderate_complexity2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_padding( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 20.0) +} + +///| +test "upstream/generated/flex/percentage_multiple_nested_with_padding_margin_and_percentage_values" { + // Ported from taffy-reference/tests/generated/flex/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=percent(0.03), + right=percent(0.03), + top=percent(0.03), + bottom=percent(0.03), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(percent(0.1)) + .with_min_size(Size(width=percent(0.6), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.15)) + .with_min_size(Size(width=percent(0.2), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 190.0) + assert_eq(l0.size.height, 48.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 92.0) + assert_eq(l00.size.height, 25.0) + assert_eq(l00.location.x, 8.0) + assert_eq(l00.location.y, 8.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 36.0) + assert_eq(l000.size.height, 6.0) + assert_eq(l000.location.x, 10.0) + assert_eq(l000.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 142.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 58.0) +} + +///| +test "upstream/generated/flex/percentage_padding_should_calculate_based_only_on_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_padding_should_calculate_based_only_on_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_padding( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 20.0) +} + +///| +test "upstream/generated/flex/percentage_position_bottom_right" { + // Ported from taffy-reference/tests/generated/flex/percentage_position_bottom_right.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.55), height=percent(0.15))) + .with_inset( + Rect(left=auto(), right=percent(0.2), top=auto(), bottom=percent(0.1)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 275.0) + assert_eq(l0.size.height, 75.0) + assert_eq(l0.location.x, -100.0) + assert_eq(l0.location.y, -50.0) +} + +///| +test "upstream/generated/flex/percentage_position_left_top" { + // Ported from taffy-reference/tests/generated/flex/percentage_position_left_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=percent(0.55))) + .with_inset( + Rect(left=percent(0.1), right=auto(), top=percent(0.2), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(400.0), height=length(400.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 400.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 180.0) + assert_eq(l0.size.height, 220.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 80.0) +} + +///| +test "upstream/generated/flex/percentage_size_based_on_parent_inner_size" { + // Ported from taffy-reference/tests/generated/flex/percentage_size_based_on_parent_inner_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(0.5), height=percent(0.5))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))) + .with_padding( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 80.0) + assert_eq(l0.size.height, 180.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 20.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part28_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part28_test.mbt new file mode 100644 index 0000000..cfaf0a0 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part28_test.mbt @@ -0,0 +1,1252 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/percentage_size_of_flex_basis" { + // Ported from taffy-reference/tests/generated/flex/percentage_size_of_flex_basis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_basis(length(50.0)), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_sizes_should_not_prevent_flex_shrinking" { + // Ported from taffy-reference/tests/generated/flex/percentage_sizes_should_not_prevent_flex_shrinking.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=percent(1.2), height=auto())), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 200.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_width_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_width_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(0.3), height=percent(0.3))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(400.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 400.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 120.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_width_height_undefined_parent_size" { + // Ported from taffy-reference/tests/generated/flex/percentage_width_height_undefined_parent_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(0.5), height=percent(0.5))), + ) + let node = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 0.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/position_root_with_rtl_should_position_withoutdirection" { + // Ported from taffy-reference/tests/generated/flex/position_root_with_rtl_should_position_withoutdirection.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(52.0), height=length(52.0))) + .with_inset( + Rect(left=length(72.0), right=auto(), top=auto(), bottom=auto()), + ), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 52.0) + assert_eq(lnode.size.height, 52.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 52.0) + assert_eq(l0.size.height, 52.0) + assert_eq(l0.location.x, 72.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/relative_position_should_not_nudge_siblings" { + // Ported from taffy-reference/tests/generated/flex/relative_position_should_not_nudge_siblings.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(15.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(15.0), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 15.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 25.0) +} + +///| +test "upstream/generated/flex/rounding_flex_basis_flex_grow_row_prime_number_width" { + // Ported from taffy-reference/tests/generated/flex/rounding_flex_basis_flex_grow_row_prime_number_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node2 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node3 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node4 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(113.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 113.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 23.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 22.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 23.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 23.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 45.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 22.0) + assert_eq(l3.size.height, 100.0) + assert_eq(l3.location.x, 68.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 23.0) + assert_eq(l4.size.height, 100.0) + assert_eq(l4.location.x, 90.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_flex_basis_flex_grow_row_width_of_100" { + // Ported from taffy-reference/tests/generated/flex/rounding_flex_basis_flex_grow_row_width_of_100.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node2 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 33.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 34.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 33.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 33.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 67.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_flex_basis_flex_shrink_row" { + // Ported from taffy-reference/tests/generated/flex/rounding_flex_basis_flex_shrink_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_shrink(1.0).with_flex_basis(length(100.0)), + ) + let node1 = taffy.new_leaf(Style::default().with_flex_basis(length(25.0))) + let node2 = taffy.new_leaf(Style::default().with_flex_basis(length(25.0))) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(101.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 101.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 67.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 17.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 67.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 17.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 84.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_flex_basis_overrides_main_size" { + // Ported from taffy-reference/tests/generated/flex/rounding_flex_basis_overrides_main_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(50.0)) + .with_size(Size(width=auto(), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(113.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 113.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 64.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 25.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 64.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_1" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_1.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(50.0)) + .with_size(Size(width=auto(), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(113.4))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 113.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 64.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 25.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 64.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_2" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(50.0)) + .with_size(Size(width=auto(), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(113.6))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 114.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 65.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 24.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 65.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 25.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_3" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_3.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(50.0)) + .with_size(Size(width=auto(), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(113.4))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 113.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 64.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 25.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 64.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_4" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_4.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(50.0)) + .with_size(Size(width=auto(), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(113.4))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 113.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 64.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 25.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 64.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_5" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_5.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.3), height=length(100.3))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.3), height=length(100.3))), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(963.333), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 963.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 101.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 381.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 482.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_6" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_6.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(2.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(2.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.5), height=auto())), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(2.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(2.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.5), height=auto())), + [node10, node11], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(7.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 7.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 4.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 2.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 2.0) + assert_eq(l01.size.height, 10.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 3.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 4.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 2.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 2.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 0.0) + assert_eq(l11.location.y, 10.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_7" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_7.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.25), height=auto())), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.25), height=auto())), + [node10, node11], + ) + let node20 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node21 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.25), height=auto())), + [node20, node21], + ) + let node30 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node31 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node3 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.25), height=auto())), + [node30, node31], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(7.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 7.0) + assert_eq(lnode.size.height, 20.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 2.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 1.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 1.0) + assert_eq(l01.size.height, 10.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 2.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 2.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 1.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 1.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 0.0) + assert_eq(l11.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 1.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 4.0) + assert_eq(l2.location.y, 0.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 1.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 0.0) + let l21 = taffy.layout(node21) + assert_eq(l21.size.width, 1.0) + assert_eq(l21.size.height, 10.0) + assert_eq(l21.location.x, 0.0) + assert_eq(l21.location.y, 10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 2.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 5.0) + assert_eq(l3.location.y, 0.0) + let l30 = taffy.layout(node30) + assert_eq(l30.size.width, 1.0) + assert_eq(l30.size.height, 10.0) + assert_eq(l30.location.x, 0.0) + assert_eq(l30.location.y, 0.0) + let l31 = taffy.layout(node31) + assert_eq(l31.size.width, 1.0) + assert_eq(l31.size.height, 10.0) + assert_eq(l31.location.x, 0.0) + assert_eq(l31.location.y, 10.0) +} + +///| +test "upstream/generated/flex/rounding_inner_node_controversy_combined" { + // Ported from taffy-reference/tests/generated/flex/rounding_inner_node_controversy_combined.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=percent(1.0))), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=percent(1.0), height=auto())), + ) + let node110 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=percent(1.0), height=auto())), + ) + let node11 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=percent(1.0), height=auto())), + [node110], + ) + let node12 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=percent(1.0), height=auto())), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=percent(1.0))), + [node10, node11, node12], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=percent(1.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(640.0), height=length(320.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 640.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 213.0) + assert_eq(l0.size.height, 320.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 214.0) + assert_eq(l1.size.height, 320.0) + assert_eq(l1.location.x, 213.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 214.0) + assert_eq(l10.size.height, 107.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 214.0) + assert_eq(l11.size.height, 106.0) + assert_eq(l11.location.x, 0.0) + assert_eq(l11.location.y, 107.0) + let l110 = taffy.layout(node110) + assert_eq(l110.size.width, 214.0) + assert_eq(l110.size.height, 106.0) + assert_eq(l110.location.x, 0.0) + assert_eq(l110.location.y, 0.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 214.0) + assert_eq(l12.size.height, 107.0) + assert_eq(l12.location.x, 0.0) + assert_eq(l12.location.y, 213.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 213.0) + assert_eq(l2.size.height, 320.0) + assert_eq(l2.location.x, 427.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_inner_node_controversy_horizontal" { + // Ported from taffy-reference/tests/generated/flex/rounding_inner_node_controversy_horizontal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + [node10], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(320.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 107.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 106.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 107.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 106.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 107.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 213.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_inner_node_controversy_vertical" { + // Ported from taffy-reference/tests/generated/flex/rounding_inner_node_controversy_vertical.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(10.0), height=auto())), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(10.0), height=auto())), + [node10], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(10.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(320.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 10.0) + assert_eq(lnode.size.height, 320.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 107.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 106.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 107.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 10.0) + assert_eq(l10.size.height, 106.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 107.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 213.0) +} + +///| +test "upstream/generated/flex/rounding_total_fractial" { + // Ported from taffy-reference/tests/generated/flex/rounding_total_fractial.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(0.7) + .with_flex_basis(length(50.3)) + .with_size(Size(width=auto(), height=length(20.3))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.6) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.1) + .with_size(Size(width=auto(), height=length(10.7))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(87.4), height=length(113.4))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 87.0) + assert_eq(lnode.size.height, 113.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 87.0) + assert_eq(l0.size.height, 59.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 87.0) + assert_eq(l1.size.height, 30.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 59.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 87.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_total_fractial_nested" { + // Ported from taffy-reference/tests/generated/flex/rounding_total_fractial_nested.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(0.3)) + .with_size(Size(width=auto(), height=length(9.9))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=length(13.3)), + ), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(length(0.3)) + .with_size(Size(width=auto(), height=length(1.1))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(13.3), bottom=auto()), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(0.7) + .with_flex_basis(length(50.3)) + .with_size(Size(width=auto(), height=length(20.3))), + [node00, node01], + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.6) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.1) + .with_size(Size(width=auto(), height=length(10.7))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(87.4), height=length(113.4))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 87.0) + assert_eq(lnode.size.height, 113.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 87.0) + assert_eq(l0.size.height, 59.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 87.0) + assert_eq(l00.size.height, 12.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, -13.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 87.0) + assert_eq(l01.size.height, 47.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 25.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 87.0) + assert_eq(l1.size.height, 30.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 59.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 87.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/scroll_size" { + // Ported from taffy-reference/tests/generated/flex/scroll_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_align_items(align_items_start()) + .with_justify_content(justify_content_start()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 100.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/simple_child" { + // Ported from taffy-reference/tests/generated/flex/simple_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + [node000], + ) + let node010 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node011 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_with_children(Style::default(), [node010, node011]) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 10.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 20.0) + assert_eq(l01.size.height, 100.0) + assert_eq(l01.location.x, 10.0) + assert_eq(l01.location.y, 0.0) + let l010 = taffy.layout(node010) + assert_eq(l010.size.width, 10.0) + assert_eq(l010.size.height, 10.0) + assert_eq(l010.location.x, 0.0) + assert_eq(l010.location.y, 45.0) + let l011 = taffy.layout(node011) + assert_eq(l011.size.width, 10.0) + assert_eq(l011.size.height, 10.0) + assert_eq(l011.location.x, 10.0) + assert_eq(l011.location.y, 45.0) +} + +///| +test "upstream/generated/flex/single_flex_child_after_absolute_child" { + // Ported from taffy-reference/tests/generated/flex/single_flex_child_after_absolute_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(1.0), height=percent(1.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node2 = taffy.new_leaf( + Style::default().with_flex_shrink(0.0).with_flex_basis(length(174.0)), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(428.0), height=length(845.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 428.0) + assert_eq(lnode.size.height, 845.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 428.0) + assert_eq(l0.size.height, 845.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 428.0) + assert_eq(l1.size.height, 671.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 428.0) + assert_eq(l2.size.height, 174.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 671.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part29_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part29_test.mbt new file mode 100644 index 0000000..e146264 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part29_test.mbt @@ -0,0 +1,1188 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/size_defined_by_child" { + // Ported from taffy-reference/tests/generated/flex/size_defined_by_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/size_defined_by_child_with_border" { + // Ported from taffy-reference/tests/generated/flex/size_defined_by_child_with_border.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 30.0) + assert_eq(lnode.size.height, 30.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/size_defined_by_child_with_padding" { + // Ported from taffy-reference/tests/generated/flex/size_defined_by_child_with_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 30.0) + assert_eq(lnode.size.height, 30.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/size_defined_by_grand_child" { + // Ported from taffy-reference/tests/generated/flex/size_defined_by_grand_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children(Style::default(), [node00]) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/undefined_height_with_min_max" { + // Ported from taffy-reference/tests/generated/flex/undefined_height_with_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=auto(), height=length(0.0))) + .with_max_size(Size(width=auto(), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(0.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 0.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 320.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/undefined_width_with_min_max" { + // Ported from taffy-reference/tests/generated/flex/undefined_width_with_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(0.0), height=auto())) + .with_max_size(Size(width=length(100.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/undefined_width_with_min_max_row" { + // Ported from taffy-reference/tests/generated/flex/undefined_width_with_min_max_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_min_size(Size(width=length(60.0), height=auto())) + .with_max_size(Size(width=length(300.0), height=auto())), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 60.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 30.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/width_smaller_then_content_with_flex_grow_large_size" { + // Ported from taffy-reference/tests/generated/flex/width_smaller_then_content_with_flex_grow_large_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(0.0), height=auto())), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(100.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(0.0), height=auto())), + [node10], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 100.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/width_smaller_then_content_with_flex_grow_small_size" { + // Ported from taffy-reference/tests/generated/flex/width_smaller_then_content_with_flex_grow_small_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(0.0), height=auto())), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(100.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(0.0), height=auto())), + [node10], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(10.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 10.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 5.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 5.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 5.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 100.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/width_smaller_then_content_with_flex_grow_unconstraint_size" { + // Ported from taffy-reference/tests/generated/flex/width_smaller_then_content_with_flex_grow_unconstraint_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(0.0), height=auto())), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(100.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(0.0), height=auto())), + [node10], + ) + let node = taffy.new_with_children(Style::default(), [node0, node1]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 0.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 100.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/width_smaller_then_content_with_flex_grow_very_large_size" { + // Ported from taffy-reference/tests/generated/flex/width_smaller_then_content_with_flex_grow_very_large_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(0.0), height=auto())), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(100.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(0.0), height=auto())), + [node10], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 100.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 100.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_child" { + // Ported from taffy-reference/tests/generated/flex/wrap_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_column" { + // Ported from taffy-reference/tests/generated/flex/wrap_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(31.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(32.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(33.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(34.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 30.0) + assert_eq(l0.size.height, 31.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 32.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 31.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 33.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 63.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 34.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_grandchild" { + // Ported from taffy-reference/tests/generated/flex/wrap_grandchild.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children(Style::default(), [node00]) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_nodes_with_content_sizing_margin_cross" { + // Ported from taffy-reference/tests/generated/flex/wrap_nodes_with_content_sizing_margin_cross.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=length(40.0))), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node000], + ) + let node010 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=length(40.0))), + ) + let node01 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node010], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(70.0), height=auto())), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 70.0) + assert_eq(l0.size.height, 90.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 40.0) + assert_eq(l00.size.height, 40.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 40.0) + assert_eq(l000.size.height, 40.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 40.0) + assert_eq(l01.size.height, 40.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 50.0) + let l010 = taffy.layout(node010) + assert_eq(l010.size.width, 40.0) + assert_eq(l010.size.height, 40.0) + assert_eq(l010.location.x, 0.0) + assert_eq(l010.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_nodes_with_content_sizing_overflowing_margin" { + // Ported from taffy-reference/tests/generated/flex/wrap_nodes_with_content_sizing_overflowing_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=length(40.0))), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node000], + ) + let node010 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=length(40.0))), + ) + let node01 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_margin( + Rect( + left=length(0.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node010], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(85.0), height=auto())), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 85.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 40.0) + assert_eq(l00.size.height, 40.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 40.0) + assert_eq(l000.size.height, 40.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 40.0) + assert_eq(l01.size.height, 40.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 40.0) + let l010 = taffy.layout(node010) + assert_eq(l010.size.width, 40.0) + assert_eq(l010.size.height, 40.0) + assert_eq(l010.location.x, 0.0) + assert_eq(l010.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_column" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(31.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(32.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(33.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(34.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 30.0) + assert_eq(l0.size.height, 31.0) + assert_eq(l0.location.x, 70.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 32.0) + assert_eq(l1.location.x, 70.0) + assert_eq(l1.location.y, 31.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 33.0) + assert_eq(l2.location.x, 70.0) + assert_eq(l2.location.y, 63.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 34.0) + assert_eq(l3.location.x, 20.0) + assert_eq(l3.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_column_fixed_size" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_column_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 135.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 135.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 135.0) + assert_eq(l2.location.y, 30.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 135.0) + assert_eq(l3.location.y, 60.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 35.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(31.0), height=length(30.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(32.0), height=length(30.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(33.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(34.0), height=length(30.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 60.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 31.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 30.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 32.0) + assert_eq(l1.size.height, 30.0) + assert_eq(l1.location.x, 31.0) + assert_eq(l1.location.y, 30.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 33.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 63.0) + assert_eq(l2.location.y, 30.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 34.0) + assert_eq(l3.size.height, 30.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row_align_content_center" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row_align_content_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_content(align_content_center()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 80.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 60.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 50.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row_align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row_align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 80.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 60.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 50.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row_align_content_space_around" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row_align_content_space_around.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_content(align_content_space_around()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 80.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 60.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 50.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row_align_content_stretch" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row_align_content_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 80.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 60.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 50.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row_single_line_different_size" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row_single_line_different_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(300.0), height=auto())), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 300.0) + assert_eq(lnode.size.height, 50.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 40.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 30.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 90.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 120.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_row" { + // Ported from taffy-reference/tests/generated/flex/wrap_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(31.0), height=length(30.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(32.0), height=length(30.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(33.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(34.0), height=length(30.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 60.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 31.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 32.0) + assert_eq(l1.size.height, 30.0) + assert_eq(l1.location.x, 31.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 33.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 63.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 34.0) + assert_eq(l3.size.height, 30.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 30.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part30_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part30_test.mbt new file mode 100644 index 0000000..12d706d --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part30_test.mbt @@ -0,0 +1,1483 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/flex/wrap_row_align_items_center" { + // Ported from taffy-reference/tests/generated/flex/wrap_row_align_items_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 60.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 5.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 30.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 30.0) +} + +///| +test "upstream/generated/flex/wrap_row_align_items_flex_end" { + // Ported from taffy-reference/tests/generated/flex/wrap_row_align_items_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_flex_end()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 100.0) + assert_eq(lnode.size.height, 60.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 20.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 30.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 30.0) +} + +///| +test "upstream/generated/flex/wrapped_column_max_height" { + // Ported from taffy-reference/tests/generated/flex/wrapped_column_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(500.0))) + .with_max_size(Size(width=auto(), height=length(200.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(700.0), height=length(500.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 700.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 200.0) + assert_eq(l0.location.x, 250.0) + assert_eq(l0.location.y, 30.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 200.0) + assert_eq(l1.location.x, 200.0) + assert_eq(l1.location.y, 250.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 420.0) + assert_eq(l2.location.y, 200.0) +} + +///| +test "upstream/generated/flex/wrapped_column_max_height_flex" { + // Ported from taffy-reference/tests/generated/flex/wrapped_column_max_height_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(100.0), height=length(500.0))) + .with_max_size(Size(width=auto(), height=length(200.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(700.0), height=length(500.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 700.0) + assert_eq(lnode.size.height, 500.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 180.0) + assert_eq(l0.location.x, 300.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 180.0) + assert_eq(l1.location.x, 250.0) + assert_eq(l1.location.y, 200.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 300.0) + assert_eq(l2.location.y, 400.0) +} + +///| +test "upstream/generated/flex/wrapped_row_within_align_items_center" { + // Ported from taffy-reference/tests/generated/flex/wrapped_row_within_align_items_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(150.0), height=length(80.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(80.0), height=length(80.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_wrap(flex_wrap_wrap()), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 160.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 150.0) + assert_eq(l00.size.height, 80.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 80.0) + assert_eq(l01.size.height, 80.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 80.0) +} + +///| +test "upstream/generated/flex/wrapped_row_within_align_items_flex_end" { + // Ported from taffy-reference/tests/generated/flex/wrapped_row_within_align_items_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(150.0), height=length(80.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(80.0), height=length(80.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_wrap(flex_wrap_wrap()), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_flex_end()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 160.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 150.0) + assert_eq(l00.size.height, 80.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 80.0) + assert_eq(l01.size.height, 80.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 80.0) +} + +///| +test "upstream/generated/flex/wrapped_row_within_align_items_flex_start" { + // Ported from taffy-reference/tests/generated/flex/wrapped_row_within_align_items_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(150.0), height=length(80.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(80.0), height=length(80.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_wrap(flex_wrap_wrap()), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_flex_start()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 200.0) + assert_eq(lnode.size.height, 200.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 160.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 150.0) + assert_eq(l00.size.height, 80.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 80.0) + assert_eq(l01.size.height, 80.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 80.0) +} + +///| +test "upstream/generated/grid/chrome_issue_325928327" { + // Ported from taffy-reference/tests/generated/grid/chrome_issue_325928327.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=percent(1.0))) + .with_aspect_ratio(1.0), + ) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=auto(), height=percent(1.0))), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_center()) + .with_size(Size(width=percent(1.0), height=length(40.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_absolute_align_self_sized_all" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_align_self_sized_all.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_start()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_end()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_end()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_center()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_center()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node6 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_stretch()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_stretch()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2, node3, node4, node5, node6, node7], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let expected_w = [20.0, 60.0, 20.0, 60.0, 20.0, 60.0, 20.0, 60.0] + let expected_h = [20.0, 60.0, 20.0, 60.0, 20.0, 60.0, 20.0, 60.0] + let expected_x = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] + let expected_y = [0.0, 0.0, 100.0, 60.0, 50.0, 30.0, 0.0, 0.0] + for i in 0..<8 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_column_end" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_column_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_grid_column(Line(start=place_auto(), end=line(1))) + .with_inset( + Rect( + left=length(4.0), + right=length(3.0), + top=length(1.0), + bottom=length(2.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let n = taffy.layout(node0) + assert_eq(n.size.width, 33.0) + assert_eq(n.size.height, 157.0) + assert_eq(n.location.x, 4.0) + assert_eq(n.location.y, 1.0) +} + +///| +test "upstream/generated/grid/grid_absolute_column_start" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_column_start.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_inset( + Rect( + left=length(4.0), + right=length(3.0), + top=length(1.0), + bottom=length(2.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let n = taffy.layout(node0) + assert_eq(n.size.width, 133.0) + assert_eq(n.size.height, 157.0) + assert_eq(n.location.x, 44.0) + assert_eq(n.location.y, 1.0) +} + +///| +test "upstream/generated/grid/grid_absolute_container_bottom_left" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_bottom_left.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=length(0.0), right=auto(), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [160.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_bottom_left_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_bottom_left_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=length(0.0), right=auto(), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [10.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [10.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [4.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [147.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_left_overrides_right" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_left_overrides_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=auto())) + .with_inset( + Rect(left=length(5.0), right=length(2.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [10.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [5.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [0.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_left_right" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_left_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=length(5.0), right=length(2.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [173.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [5.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [0.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_left_right_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_left_right_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=length(5.0), right=length(2.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [167.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [9.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [1.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_negative_position" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_negative_position.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=auto(), right=length(-15.0), top=length(-5.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=length(-35.0), right=auto(), top=auto(), bottom=length(-25.0)), + ), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [195.0, -35.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0] + let expected_y = [-5.0, 185.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_negative_position_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_negative_position_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(-15.0), top=length(-5.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=length(-35.0), right=auto(), top=auto(), bottom=length(-25.0)), + ), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [193.0, -31.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0] + let expected_y = [-4.0, 182.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_top_bottom" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_top_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=auto(), right=auto(), top=length(2.0), bottom=length(5.0)), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [153.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [2.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_top_bottom_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_top_bottom_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=auto(), right=auto(), top=length(2.0), bottom=length(5.0)), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [149.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [4.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [3.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_top_right" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_top_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [180.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [0.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_top_right_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_top_right_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [178.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [1.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_justify_self_sized_all" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_justify_self_sized_all.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_center()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_center()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node6 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2, node3, node4, node5, node6, node7], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let expected_w = [20.0, 60.0, 20.0, 60.0, 20.0, 60.0, 20.0, 60.0] + let expected_h = [20.0, 60.0, 20.0, 60.0, 20.0, 60.0, 20.0, 60.0] + let expected_x = [0.0, 0.0, 100.0, 60.0, 50.0, 30.0, 0.0, 0.0] + let expected_y = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] + for i in 0..<8 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_layout_within_border" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_layout_within_border.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0, node1, node2, node3], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3] + let expected_w = [50.0, 50.0, 50.0, 50.0] + let expected_h = [50.0, 50.0, 50.0, 50.0] + let expected_x = [10.0, 40.0, 20.0, 30.0] + let expected_y = [10.0, 40.0, 20.0, 30.0] + for i in 0..<4 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_layout_within_border_static" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_layout_within_border_static.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_end()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_end()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0, node1, node2, node3], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3] + let expected_w = [50.0, 50.0, 50.0, 50.0] + let expected_h = [50.0, 50.0, 50.0, 50.0] + let expected_x = [10.0, 40.0, 20.0, 30.0] + let expected_y = [10.0, 40.0, 20.0, 30.0] + for i in 0..<4 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part31_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part31_test.mbt new file mode 100644 index 0000000..71b6b1f --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part31_test.mbt @@ -0,0 +1,486 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/grid/grid_absolute_row_end" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_row_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_grid_row(Line(start=place_auto(), end=line(1))) + .with_inset( + Rect( + left=length(4.0), + right=length(3.0), + top=length(1.0), + bottom=length(2.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let n = taffy.layout(node0) + assert_eq(n.size.width, 173.0) + assert_eq(n.size.height, 7.0) + assert_eq(n.location.x, 4.0) + assert_eq(n.location.y, 1.0) +} + +///| +test "upstream/generated/grid/grid_absolute_row_start" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_row_start.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_inset( + Rect( + left=length(4.0), + right=length(3.0), + top=length(1.0), + bottom=length(2.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let n = taffy.layout(node0) + assert_eq(n.size.width, 173.0) + assert_eq(n.size.height, 147.0) + assert_eq(n.location.x, 4.0) + assert_eq(n.location.y, 11.0) +} + +///| +test "upstream/generated/grid/grid_absolute_top_overrides_bottom" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_top_overrides_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(2.0), bottom=length(5.0)), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [10.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [2.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_with_padding" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_with_padding.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=length(10.0), right=auto(), top=auto(), bottom=length(10.0)), + ), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [180.0, 10.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0] + let expected_y = [0.0, 150.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_with_padding_and_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_with_padding_and_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=length(10.0), right=auto(), top=auto(), bottom=length(10.0)), + ), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [178.0, 14.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0] + let expected_y = [1.0, 147.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_align_content_center" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_center.rs + run_grid_align_content_test(align_content_center(), [40.0, 80.0, 120.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_center_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_center_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test(align_content_center(), [ + -10.0, 40.0, 90.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_end" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_end.rs + run_grid_align_content_test(align_content_end(), [80.0, 120.0, 160.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_end_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_end_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test(align_content_end(), [ + -20.0, 30.0, 80.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_end_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_end_with_padding_border.rs + run_grid_align_content_with_padding_border_test(align_content_end(), [ + 44.0, 84.0, 124.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_around" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_around.rs + run_grid_align_content_test(align_content_space_around(), [13.0, 80.0, 147.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_around_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_around_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test(align_content_space_around(), [ + 0.0, 50.0, 100.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_around_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_around_with_padding_border.rs + run_grid_align_content_with_padding_border_test( + align_content_space_around(), + [17.0, 68.0, 119.0], + ) +} + +///| +test "upstream/generated/grid/grid_align_content_space_between" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_between.rs + run_grid_align_content_test(align_content_space_between(), [0.0, 80.0, 160.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_between_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_between_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test( + align_content_space_between(), + [0.0, 50.0, 100.0], + ) +} + +///| +test "upstream/generated/grid/grid_align_content_space_between_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_between_with_padding_border.rs + run_grid_align_content_with_padding_border_test( + align_content_space_between(), + [12.0, 68.0, 124.0], + ) +} + +///| +test "upstream/generated/grid/grid_align_content_space_evenly" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_evenly.rs + run_grid_align_content_test(align_content_space_evenly(), [20.0, 80.0, 140.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_evenly_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_evenly_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test(align_content_space_evenly(), [ + 0.0, 50.0, 100.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_evenly_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_evenly_with_padding_border.rs + run_grid_align_content_with_padding_border_test( + align_content_space_evenly(), + [20.0, 68.0, 116.0], + ) +} + +///| +test "upstream/generated/grid/grid_align_content_start" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_start.rs + run_grid_align_content_test(align_content_start(), [0.0, 40.0, 80.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_start_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_start_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test(align_content_start(), [ + 0.0, 50.0, 100.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_start_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_start_with_padding_border.rs + run_grid_align_content_with_padding_border_test(align_content_start(), [ + 12.0, 52.0, 92.0, + ]) +} + +///| +fn[C] assert_layout_xywh( + taffy : ChicleTree[C], + node : NodeId, + width : Double, + height : Double, + x : Double, + y : Double, +) -> Unit raise Error { + let layout = taffy.layout(node) + assert_eq(layout.size.width, width) + assert_eq(layout.size.height, height) + assert_eq(layout.location.x, x) + assert_eq(layout.location.y, y) +} + +///| +fn[C] assert_nodes_layout_xywh( + taffy : ChicleTree[C], + nodes : Array[NodeId], + expected_w : Array[Double], + expected_h : Array[Double], + expected_x : Array[Double], + expected_y : Array[Double], +) -> Unit raise Error { + for i in 0.. Array[NodeId] { + [ + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + ] +} + +///| +fn assert_grid_positions( + taffy : ChicleTree[Unit], + nodes : Array[NodeId], + expected_x : Array[Double], + expected_y : Array[Double], + item_width : Double, + item_height : Double, +) -> Unit raise Error { + for row in 0..<3 { + for col in 0..<3 { + let idx = row * 3 + col + let layout = taffy.layout(nodes[idx]) + assert_eq(layout.size.width, item_width) + assert_eq(layout.size.height, item_height) + assert_eq(layout.location.x, expected_x[col]) + assert_eq(layout.location.y, expected_y[row]) + } + } +} + +///| +fn run_grid_align_content_test( + align_content : AlignContent, + expected_y : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_align_content(align_content) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(200.0), height=length(200.0))), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + assert_grid_positions(taffy, nodes, [0.0, 40.0, 80.0], expected_y, 40.0, 40.0) +} + +///| +fn run_grid_align_content_with_padding_border_test( + align_content : AlignContent, + expected_y : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_align_content(align_content) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + assert_grid_positions( + taffy, + nodes, + [48.0, 88.0, 128.0], + expected_y, + 40.0, + 40.0, + ) +} + +///| +fn run_grid_align_content_negative_space_gap_test( + align_content : AlignContent, + expected_y : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let inner = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_align_content(align_content) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(20.0), length(20.0), length(20.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + nodes, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(240.0), height=length(240.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [inner], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 240.0) + assert_eq(root_layout.size.height, 240.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let inner_layout = taffy.layout(inner) + assert_eq(inner_layout.size.width, 120.0) + assert_eq(inner_layout.size.height, 120.0) + assert_eq(inner_layout.location.x, 60.0) + assert_eq(inner_layout.location.y, 60.0) + assert_grid_positions( + taffy, + nodes, + [20.0, 50.0, 80.0], + expected_y, + 20.0, + 40.0, + ) +} + +///| +fn run_grid_justify_content_test( + justify_content : JustifyContent, + expected_x : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_content(justify_content) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(200.0), height=length(200.0))), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + assert_grid_positions(taffy, nodes, expected_x, [0.0, 40.0, 80.0], 40.0, 40.0) +} + +///| +fn run_grid_justify_content_with_padding_border_test( + justify_content : JustifyContent, + expected_x : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_content(justify_content) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + assert_grid_positions( + taffy, + nodes, + expected_x, + [12.0, 52.0, 92.0], + 40.0, + 40.0, + ) +} + +///| +fn run_grid_justify_content_negative_space_gap_test( + justify_content : JustifyContent, + expected_x : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let inner = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_grid_template_rows([length(20.0), length(20.0), length(20.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + nodes, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(240.0), height=length(240.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [inner], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 240.0) + assert_eq(root_layout.size.height, 240.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let inner_layout = taffy.layout(inner) + assert_eq(inner_layout.size.width, 120.0) + assert_eq(inner_layout.size.height, 120.0) + assert_eq(inner_layout.location.x, 60.0) + assert_eq(inner_layout.location.y, 60.0) + assert_grid_positions( + taffy, + nodes, + expected_x, + [20.0, 50.0, 80.0], + 40.0, + 20.0, + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_center" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_center.rs + run_grid_justify_content_test(justify_content_center(), [40.0, 80.0, 120.0]) +} + +///| +test "upstream/generated/grid/grid_justify_content_center_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_center_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test(justify_content_center(), [ + -10.0, 40.0, 90.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_center_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_center_with_padding_border.rs + run_grid_justify_content_with_padding_border_test(justify_content_center(), [ + 52.0, 92.0, 132.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_end" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_end.rs + run_grid_justify_content_test(justify_content_end(), [80.0, 120.0, 160.0]) +} + +///| +test "upstream/generated/grid/grid_justify_content_end_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_end_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test(justify_content_end(), [ + -20.0, 30.0, 80.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_end_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_end_with_padding_border.rs + run_grid_justify_content_with_padding_border_test(justify_content_end(), [ + 56.0, 96.0, 136.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_around" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_around.rs + run_grid_justify_content_test(justify_content_space_around(), [ + 13.0, 80.0, 147.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_around_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_around_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test( + justify_content_space_around(), + [0.0, 50.0, 100.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_around_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_around_with_padding_border.rs + run_grid_justify_content_with_padding_border_test( + justify_content_space_around(), + [49.0, 92.0, 135.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_between" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_between.rs + run_grid_justify_content_test(justify_content_space_between(), [ + 0.0, 80.0, 160.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_between_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_between_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test( + justify_content_space_between(), + [0.0, 50.0, 100.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_between_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_between_with_padding_border.rs + run_grid_justify_content_with_padding_border_test( + justify_content_space_between(), + [48.0, 92.0, 136.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_evenly" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_evenly.rs + run_grid_justify_content_test(justify_content_space_evenly(), [ + 20.0, 80.0, 140.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_evenly_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_evenly_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test( + justify_content_space_evenly(), + [0.0, 50.0, 100.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_evenly_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_evenly_with_padding_border.rs + run_grid_justify_content_with_padding_border_test( + justify_content_space_evenly(), + [50.0, 92.0, 134.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_start" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_start.rs + run_grid_justify_content_test(justify_content_start(), [0.0, 40.0, 80.0]) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part36_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part36_test.mbt new file mode 100644 index 0000000..e020f1c --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part36_test.mbt @@ -0,0 +1,1228 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/grid/grid_justify_content_start_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_start_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test(justify_content_start(), [ + 0.0, 50.0, 100.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_start_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_start_with_padding_border.rs + run_grid_justify_content_with_padding_border_test(justify_content_start(), [ + 48.0, 88.0, 128.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_items_sized_center" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_items_sized_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row_start(1) + .with_grid_column_start(1) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row_start(3) + .with_grid_column_start(3) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_center()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 70.0) + assert_eq(l1.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_justify_items_sized_end" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_items_sized_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row_start(1) + .with_grid_column_start(1) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row_start(3) + .with_grid_column_start(3) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_end()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 60.0) + assert_eq(l1.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_justify_items_sized_start" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_items_sized_start.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row_start(1) + .with_grid_column_start(1) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row_start(3) + .with_grid_column_start(3) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_start()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 80.0) + assert_eq(l1.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_justify_items_sized_stretch" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_items_sized_stretch.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row_start(1) + .with_grid_column_start(1) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row_start(3) + .with_grid_column_start(3) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_stretch()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 80.0) + assert_eq(l1.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_justify_self_sized_all" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_self_sized_all.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_start()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_end()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_end()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_center()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_center()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node6 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2, node3, node4, node5, node6, node7], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 40.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 60.0) + assert_eq(l3.size.height, 60.0) + assert_eq(l3.location.x, -20.0) + assert_eq(l3.location.y, 40.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 40.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 60.0) + assert_eq(l5.size.height, 60.0) + assert_eq(l5.location.x, 70.0) + assert_eq(l5.location.y, 40.0) + let l6 = taffy.layout(node6) + assert_eq(l6.size.width, 20.0) + assert_eq(l6.size.height, 20.0) + assert_eq(l6.location.x, 0.0) + assert_eq(l6.location.y, 80.0) + let l7 = taffy.layout(node7) + assert_eq(l7.size.width, 60.0) + assert_eq(l7.size.height, 60.0) + assert_eq(l7.location.x, 40.0) + assert_eq(l7.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_margins_auto_margins" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_auto_margins.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=auto())) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_start()) + .with_size(Size(width=auto(), height=length(20.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin(Rect(left=auto(), right=auto(), top=auto(), bottom=auto())), + ) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 20.0, 40.0, 40.0, 40.0, 20.0, 40.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 20.0, 40.0, 20.0, 40.0, 40.0] + let expected_x = [40.0, 80.0, 130.0, 40.0, 80.0, 120.0, 50.0, 80.0, 120.0] + let expected_y = [10.0, 10.0, 10.0, 50.0, 60.0, 50.0, 100.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_auto_margins_override_stretch" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_auto_margins_override_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_stretch()) + .with_justify_self(align_items_stretch()) + .with_margin(Rect(left=auto(), right=auto(), top=auto(), bottom=auto())), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 10.0, 40.0, 40.0] + let expected_x = [40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0] + let expected_y = [10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 105.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_fixed_center" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_fixed_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_justify_self(align_items_center()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [52.0, 80.0, 120.0, 40.0, 80.0, 120.0] + let expected_y = [18.0, 10.0, 10.0, 50.0, 50.0, 50.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_fixed_end" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_fixed_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_end()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [58.0, 80.0, 120.0, 40.0, 80.0, 120.0] + let expected_y = [27.0, 10.0, 10.0, 50.0, 50.0, 50.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_fixed_start" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_fixed_start.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [44.0, 80.0, 120.0, 40.0, 80.0, 120.0] + let expected_y = [11.0, 10.0, 10.0, 50.0, 50.0, 50.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_fixed_stretch" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_fixed_stretch.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_stretch()) + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [44.0, 80.0, 120.0, 40.0, 80.0, 120.0] + let expected_y = [11.0, 10.0, 10.0, 50.0, 50.0, 50.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_percent_center" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_percent_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_justify_self(align_items_center()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(20.0), length(20.0), length(20.0)]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 60.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 20.0, 20.0, 20.0, 20.0, 20.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [1.0, 20.0, 40.0, 0.0, 20.0, 40.0] + let expected_y = [9.0, 0.0, 0.0, 40.0, 40.0, 40.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_percent_end" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_percent_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_end()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(20.0), length(20.0), length(20.0)]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 60.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 20.0, 20.0, 20.0, 20.0, 20.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [-2.0, 20.0, 40.0, 0.0, 20.0, 40.0] + let expected_y = [17.0, 0.0, 0.0, 40.0, 40.0, 40.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_percent_start" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_percent_start.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(20.0), length(20.0), length(20.0)]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 60.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 20.0, 20.0, 20.0, 20.0, 20.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [4.0, 20.0, 40.0, 0.0, 20.0, 40.0] + let expected_y = [1.0, 0.0, 0.0, 40.0, 40.0, 40.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_percent_stretch" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_percent_stretch.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_stretch()) + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(20.0), length(20.0), length(20.0)]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 60.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 20.0, 20.0, 20.0, 20.0, 20.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [4.0, 20.0, 40.0, 0.0, 20.0, 40.0] + let expected_y = [1.0, 0.0, 0.0, 40.0, 40.0, 40.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_maximum_single_item" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_maximum_single_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(0.0), grid_max_content()), + length(40.0), + ]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0] + let expected_y = [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_max_content(), length(40.0)]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0] + let expected_y = [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_margin_auto" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_margin_auto.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_margin( + Rect(left=auto(), right=auto(), top=auto(), bottom=auto()), + ), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_max_content(), length(40.0)]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [40.0, 10.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0] + let expected_y = [0.0, 15.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_margin_fixed" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_margin_fixed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_margin( + Rect( + left=length(20.0), + right=length(10.0), + top=length(5.0), + bottom=length(15.0), + ), + ), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_max_content(), length(40.0)]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 150.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 40.0, 70.0, 40.0, 40.0, 70.0, 40.0] + let expected_h = [40.0, 20.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 60.0, 110.0, 0.0, 40.0, 110.0, 0.0, 40.0, 110.0] + let expected_y = [0.0, 5.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_margin_percent" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_margin_percent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ), + ), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_max_content(), length(40.0)]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 28.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [40.0, 32.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 48.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0] + let expected_y = [0.0, 2.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_span_2" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_span_2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=span(2), end=place_auto())), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + grid_max_content(), + grid_max_content(), + ]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 80.0) + assert_eq(root_layout.size.height, 120.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 20.0, 20.0, 40.0, 20.0, 20.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 0.0] + let expected_x = [0.0, 40.0, 0.0, 40.0, 60.0, 0.0, 40.0, 60.0, 0.0] + let expected_y = [0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0, 120.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_span_2_gap_fixed" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_span_2_gap_fixed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=span(2), end=place_auto())), + { text_content: "HH\u{200B}HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_gap(Size(width=length(20.0), height=length(0.0))) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + grid_max_content(), + grid_max_content(), + ]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 60.0, 40.0, 20.0, 20.0, 40.0, 20.0, 20.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 0.0] + let expected_x = [0.0, 60.0, 0.0, 60.0, 100.0, 0.0, 60.0, 100.0, 0.0] + let expected_y = [0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0, 120.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_span_2_gap_percent_definite" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_definite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=span(2), end=place_auto())), + { text_content: "HH\u{200B}HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_gap(Size(width=percent(0.2), height=length(0.0))) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + grid_max_content(), + grid_max_content(), + ]) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 120.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 60.0, 40.0, 20.0, 20.0, 40.0, 20.0, 20.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 0.0] + let expected_x = [0.0, 60.0, 0.0, 60.0, 100.0, 0.0, 60.0, 100.0, 0.0] + let expected_y = [0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0, 120.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part37_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part37_test.mbt new file mode 100644 index 0000000..7706c40 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part37_test.mbt @@ -0,0 +1,811 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/grid/grid_max_content_single_item_span_2_gap_percent_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=span(2), end=place_auto())), + { text_content: "HH\u{200B}HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_gap(Size(width=percent(0.2), height=length(0.0))) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + grid_max_content(), + grid_max_content(), + ]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 120.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 60.0, 40.0, 20.0, 20.0, 40.0, 20.0, 20.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 0.0] + let expected_x = [0.0, 60.0, 0.0, 60.0, 100.0, 0.0, 60.0, 100.0, 0.0] + let expected_y = [0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0, 120.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_width_greater_than_max_content" { + // Ported from taffy-reference/tests/generated/grid/grid_max_width_greater_than_max_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([auto(), auto()]) + .with_max_size(Size(width=length(400.0), height=auto())), + [node00, node01], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_max_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 160.0, 10.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 160.0, 10.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 80.0, 10.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 80.0, 10.0, 80.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_max_width_less_than_max_content_with_min_content" { + // Ported from taffy-reference/tests/generated/grid/grid_max_width_less_than_max_content_with_min_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([auto(), auto()]) + .with_max_size(Size(width=length(80.0), height=auto())), + [node00, node01], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_min_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 20.0, 40.0, 20.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_max_width_smaller_than_max_content" { + // Ported from taffy-reference/tests/generated/grid/grid_max_width_smaller_than_max_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([auto(), auto()]) + .with_max_size(Size(width=length(80.0), height=auto())), + [node00, node01], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_max_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 80.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 80.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 40.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 40.0, 20.0, 40.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_max_width_smaller_than_min_content" { + // Ported from taffy-reference/tests/generated/grid/grid_max_width_smaller_than_min_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([auto(), auto()]) + .with_max_size(Size(width=length(60.0), height=auto())), + [node00, node01], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_max_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 60.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 60.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 40.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 40.0, 20.0, 40.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_column" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node02 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()), + [node00, node01, node02], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 20.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 20.0, 20.0, 0.0, 20.0) + assert_layout_xywh(taffy, node02, 20.0, 20.0, 0.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_row" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node02 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default().with_display(display_flex()), + [node00, node01, node02], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 20.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node02, 20.0, 40.0, 40.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_single_item" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_single_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf( + Style::default().with_min_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=span(2), end=place_auto())), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_min_content(), fr(1.0)]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 80.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 10.0, 30.0, 40.0, 40.0, 40.0, 10.0, 30.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 50.0, 0.0, 40.0, 0.0, 40.0, 50.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_single_item_margin_auto" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_single_item_margin_auto.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let all_auto_margin : Rect[Dimension] = Rect( + left=auto(), + right=auto(), + top=auto(), + bottom=auto(), + ) + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(10.0), height=auto())) + .with_margin(all_auto_margin), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf_with_context( + Style::default() + .with_grid_column(Line(start=span(2), end=place_auto())) + .with_margin(all_auto_margin), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_min_content(), fr(1.0)]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 80.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 10.0, 30.0, 40.0, 40.0, 40.0, 10.0, 30.0], + [40.0, 0.0, 40.0, 40.0, 10.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 50.0, 0.0, 40.0, 0.0, 40.0, 50.0], + [0.0, 20.0, 0.0, 40.0, 55.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_single_item_margin_fixed" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_single_item_margin_fixed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let fixed_margin : Rect[Dimension] = Rect( + left=length(20.0), + right=length(10.0), + top=length(5.0), + bottom=length(15.0), + ) + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(10.0), height=auto())) + .with_margin(fixed_margin), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf_with_context( + Style::default() + .with_grid_column(Line(start=span(2), end=place_auto())) + .with_margin(fixed_margin), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_min_content(), fr(1.0)]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 110.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 10.0, 30.0, 40.0, 40.0, 40.0, 40.0, 30.0], + [40.0, 20.0, 40.0, 40.0, 20.0, 40.0, 40.0, 40.0], + [0.0, 60.0, 80.0, 0.0, 60.0, 0.0, 40.0, 80.0], + [0.0, 5.0, 0.0, 40.0, 45.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_single_item_margin_percent" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_single_item_margin_percent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let percent_margin : Rect[Dimension] = Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ) + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(10.0), height=auto())) + .with_margin(percent_margin), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf_with_context( + Style::default() + .with_grid_column(Line(start=span(2), end=place_auto())) + .with_margin(percent_margin), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_min_content(), fr(1.0)]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 80.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 10.0, 30.0, 40.0, 28.0, 40.0, 10.0, 30.0], + [40.0, 38.0, 40.0, 40.0, 32.0, 40.0, 40.0, 40.0], + [0.0, 42.0, 50.0, 0.0, 48.0, 0.0, 40.0, 50.0], + [0.0, 1.0, 0.0, 40.0, 42.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_min_content_maximum_single_item" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_maximum_single_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(0.0), grid_min_content()), + length(40.0), + ]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 20.0, 40.0, 40.0, 20.0, 40.0, 40.0, 20.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 60.0, 0.0, 40.0, 60.0, 0.0, 40.0, 60.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_min_content_single_item" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_single_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_min_content(), length(40.0)]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 20.0, 40.0, 40.0, 20.0, 40.0, 40.0, 20.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 60.0, 0.0, 40.0, 60.0, 0.0, 40.0, 60.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_minmax_auto_fixed_10px" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_auto_fixed_10px.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(auto(), length(10.0))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 10.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 10.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_auto_max_content" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_auto_max_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(auto(), grid_max_content())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_auto_min_content" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_auto_min_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(auto(), grid_min_content())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_auto_percent_definite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_auto_percent_definite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(auto(), percent(0.2))]) + .with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_auto_percent_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_auto_percent_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(auto(), percent(0.2))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 8.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_column_fixed_width_above_range" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_fixed_width_above_range.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(20.0), length(40.0)), + length(40.0), + ]) + .with_size(Size(width=length(140.0), height=auto())), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + assert_layout_xywh(taffy, root, 140.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_minmax_column_fixed_width_below_range" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_fixed_width_below_range.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(20.0), length(40.0)), + length(40.0), + ]) + .with_size(Size(width=length(90.0), height=auto())), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + assert_layout_xywh(taffy, root, 90.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 20.0, 40.0, 40.0, 20.0, 40.0, 40.0, 20.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 60.0, 0.0, 40.0, 60.0, 0.0, 40.0, 60.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_minmax_column_fixed_width_within_range" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_fixed_width_within_range.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(20.0), length(40.0)), + length(40.0), + ]) + .with_size(Size(width=length(110.0), height=auto())), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 110.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + // Spot-check a representative item in the second column (should be 30px wide). + let item = nodes[1] + let l = taffy.layout(item) + assert_eq(l.size.width, 30.0) + assert_eq(l.size.height, 40.0) + assert_eq(l.location.x, 40.0) + assert_eq(l.location.y, 0.0) + // Spot-check a representative item in the third column (fixed 40px). + let item2 = nodes[2] + let l2 = taffy.layout(item2) + assert_eq(l2.size.width, 40.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 70.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_column_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_indefinite.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(20.0), length(40.0)), + length(40.0), + ]), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + assert_layout_xywh(taffy, root, 120.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_minmax_column_with_auto_fixed" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_with_auto_fixed.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(length(20.0), length(40.0)), auto()]) + .with_size(Size(width=length(60.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + assert_layout_xywh(taffy, root, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 40.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_column_with_fr_fixed" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_with_fr_fixed.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(length(20.0), length(40.0)), fr(1.0)]) + .with_size(Size(width=length(60.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + assert_layout_xywh(taffy, root, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 40.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_max_content_1fr" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_1fr.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), fr(1.0))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part38_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part38_test.mbt new file mode 100644 index 0000000..a524fbb --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part38_test.mbt @@ -0,0 +1,631 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/grid/grid_minmax_max_content_auto" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_auto.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), auto())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_max_content_fixed_10px" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_fixed_10px.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), length(10.0))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_max_content_min_content" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_min_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), grid_min_content())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_max_content_percent_definite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_percent_definite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), percent(0.2))]) + .with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_max_content_percent_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_percent_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), percent(0.2))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_1fr" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_1fr.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), fr(1.0))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_auto" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_auto.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), auto())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_fixed_10px" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_fixed_10px.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), length(10.0))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_max_content" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_max_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), grid_max_content())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_percent_definite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_percent_definite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), percent(0.2))]) + .with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_percent_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_percent_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), percent(0.2))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_out_of_order_items" { + // Ported from taffy-reference/tests/generated/grid/grid_out_of_order_items.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf( + Style::default() + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(35.0), height=length(35.0))), + ) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_grid_auto_flow(grid_auto_flow_row_dense()) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 80.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 40.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 35.0) + assert_eq(l2.size.height, 35.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 80.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 40.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 40.0) + assert_eq(l3.location.y, 40.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 40.0) + assert_eq(l4.size.height, 40.0) + assert_eq(l4.location.x, 80.0) + assert_eq(l4.location.y, 40.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 0.0) + assert_eq(l5.location.y, 0.0) + let l6 = taffy.layout(node6) + assert_eq(l6.size.width, 40.0) + assert_eq(l6.size.height, 40.0) + assert_eq(l6.location.x, 40.0) + assert_eq(l6.location.y, 80.0) + let l7 = taffy.layout(node7) + assert_eq(l7.size.width, 10.0) + assert_eq(l7.size.height, 10.0) + assert_eq(l7.location.x, 40.0) + assert_eq(l7.location.y, 0.0) + let l8 = taffy.layout(node8) + assert_eq(l8.size.width, 40.0) + assert_eq(l8.size.height, 40.0) + assert_eq(l8.location.x, 80.0) + assert_eq(l8.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_overflow_inline_axis_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_inline_axis_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 50.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_inline_axis_scroll" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_inline_axis_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 50.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_inline_axis_visible" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_inline_axis_visible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHHHHHH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_rows" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_rows.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=line(1), end=span(4))), + { + text_content: "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH", + writing_mode: Horizontal, + }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + length(10.0), + percent(0.2), + ]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 320.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 320.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 43.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 203.0, 40.0, 43.0, 40.0) + assert_layout_xywh(taffy, node3, 10.0, 40.0, 246.0, 40.0) + assert_layout_xywh(taffy, node4, 64.0, 40.0, 256.0, 40.0) + assert_layout_xywh(taffy, node5, 43.0, 0.0, 0.0, 80.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_overridden_by_available_space" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_overridden_by_available_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_overridden_by_max_size" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_overridden_by_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_max_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_overridden_by_size" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_overridden_by_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_take_up_space_both_axis" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_take_up_space_both_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 35.0, 35.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_take_up_space_x_axis" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_take_up_space_x_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 50.0, 35.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_take_up_space_y_axis" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_take_up_space_y_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 35.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_padding_border_overrides_container_max_size" { + // Ported from taffy-reference/tests/generated/grid/grid_padding_border_overrides_container_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 22.0, 14.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 15.0, 3.0) +} + +///| +test "upstream/generated/grid/grid_padding_border_overrides_container_size" { + // Ported from taffy-reference/tests/generated/grid/grid_padding_border_overrides_container_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 22.0, 14.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 15.0, 3.0) +} + +///| +test "upstream/generated/grid/grid_padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/grid/grid_padding_border_overrides_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 22.0, 14.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 22.0, 14.0, 0.0, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part39_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part39_test.mbt new file mode 100644 index 0000000..039b844 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part39_test.mbt @@ -0,0 +1,981 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/grid/grid_padding_border_overrides_min_size" { + // Ported from taffy-reference/tests/generated/grid/grid_padding_border_overrides_min_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(0.0), height=length(0.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 22.0, 14.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 22.0, 14.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/grid/grid_padding_border_overrides_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 22.0, 14.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 22.0, 14.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_item_inside_stretch_item" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_item_inside_stretch_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=percent(0.5), height=auto())), + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 50.0, 100.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_items_nested_inside_stretch_alignment" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_nested_inside_stretch_alignment.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_grid()) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.2), + bottom=length(0.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 200.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 200.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 200.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_items_nested_moderate" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_nested_moderate.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=percent(0.03), + right=percent(0.03), + top=percent(0.03), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=auto())) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) +} + +///| +test "upstream/generated/grid/grid_percent_items_nested_with_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_nested_with_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=percent(0.5), height=auto())), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + let l00 = taffy.layout(node00) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) + assert_eq(l00.size.width, 45.0) + assert_eq(l00.size.height, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 10.0, 0.0, 0.0) + assert_layout_xywh(taffy, root, 200.0, 10.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_items_nested_with_padding_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_nested_with_padding_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=percent(0.03), + right=percent(0.03), + top=percent(0.03), + bottom=percent(0.03), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_min_size(Size(width=percent(0.6), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + [node00], + ) + let node1 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([fr(1.0), fr(4.0)]) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node0, 190.0, 41.0, 5.0, 5.0) + assert_layout_xywh(taffy, node00, 92.0, 25.0, 8.0, 8.0) + assert_layout_xywh(taffy, node000, 36.0, 6.0, 10.0, 10.0) + assert_layout_xywh(taffy, node1, 200.0, 149.0, 0.0, 51.0) + assert_layout_xywh(taffy, root, 200.0, 200.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_items_width_and_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_width_and_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=auto())) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 200.0, 31.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 87.0, 6.0, 13.0, 13.0) +} + +///| +test "upstream/generated/grid/grid_percent_items_width_and_padding" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_width_and_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.5), height=auto())) + .with_padding( + Rect( + left=percent(0.03), + right=percent(0.03), + top=percent(0.03), + bottom=percent(0.03), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 200.0, 12.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 12.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_tracks_definite_overflow" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_tracks_definite_overflow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.5), percent(0.8)]) + .with_grid_template_columns([percent(0.4), percent(0.4), percent(0.4)]) + .with_size(Size(width=length(120.0), height=length(60.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 60.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 48.0, 30.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 48.0, 30.0, 48.0, 0.0) + assert_layout_xywh(taffy, node2, 48.0, 30.0, 96.0, 0.0) + assert_layout_xywh(taffy, node3, 48.0, 48.0, 0.0, 30.0) + assert_layout_xywh(taffy, node4, 48.0, 48.0, 48.0, 30.0) + assert_layout_xywh(taffy, node5, 48.0, 48.0, 96.0, 30.0) +} + +///| +test "upstream/generated/grid/grid_percent_tracks_definite_underflow" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_tracks_definite_underflow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.3), percent(0.6)]) + .with_grid_template_columns([percent(0.1), percent(0.2), percent(0.3)]) + .with_size(Size(width=length(120.0), height=length(60.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 60.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 12.0, 18.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 24.0, 18.0, 12.0, 0.0) + assert_layout_xywh(taffy, node2, 36.0, 18.0, 36.0, 0.0) + assert_layout_xywh(taffy, node3, 12.0, 36.0, 0.0, 18.0) + assert_layout_xywh(taffy, node4, 24.0, 36.0, 12.0, 18.0) + assert_layout_xywh(taffy, node5, 36.0, 36.0, 36.0, 18.0) +} + +///| +test "upstream/generated/grid/grid_percent_tracks_indefinite_only" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_tracks_indefinite_only.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.3), percent(0.6)]) + .with_grid_template_columns([percent(0.1), percent(0.2), percent(0.3)]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node2, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node3, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node4, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node5, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_tracks_indefinite_with_content_overflow" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_tracks_indefinite_with_content_overflow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.5), percent(0.8)]) + .with_grid_template_columns([percent(0.4), percent(0.4), percent(0.4)]), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node2, 40.0, 50.0, 40.0, 0.0) + assert_layout_xywh(taffy, node3, 40.0, 50.0, 80.0, 0.0) + assert_layout_xywh(taffy, node4, 40.0, 80.0, 0.0, 50.0) + assert_layout_xywh(taffy, node5, 40.0, 80.0, 40.0, 50.0) + assert_layout_xywh(taffy, node6, 40.0, 80.0, 80.0, 50.0) +} + +///| +test "upstream/generated/grid/grid_percent_tracks_indefinite_with_content_underflow" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_tracks_indefinite_with_content_underflow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.3), percent(0.6)]) + .with_grid_template_columns([percent(0.1), percent(0.2), percent(0.3)]), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 10.0, 30.0, 0.0, 0.0) + assert_layout_xywh(taffy, node2, 20.0, 30.0, 10.0, 0.0) + assert_layout_xywh(taffy, node3, 30.0, 30.0, 30.0, 0.0) + assert_layout_xywh(taffy, node4, 10.0, 60.0, 0.0, 30.0) + assert_layout_xywh(taffy, node5, 20.0, 60.0, 10.0, 30.0) + assert_layout_xywh(taffy, node6, 30.0, 60.0, 30.0, 30.0) +} + +///| +test "upstream/generated/grid/grid_placement_auto_negative" { + // Ported from taffy-reference/tests/generated/grid/grid_placement_auto_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(-5), end=place_auto())), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf( + Style::default().with_grid_row(Line(start=line(2), end=place_auto())), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 120.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 20.0, 40.0, 0.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_placement_definite_in_secondary_axis_with_fully_definite_negative" { + // Ported from taffy-reference/tests/generated/grid/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_grid_row(Line(start=line(2), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(2), end=place_auto())) + .with_grid_column(Line(start=line(-4), end=place_auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_grid_row(Line(start=line(1), end=place_auto())), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 120.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 40.0, 40.0) + assert_layout_xywh(taffy, node1, 40.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_relative_all_sides" { + // Ported from taffy-reference/tests/generated/grid/grid_relative_all_sides.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 100.0, 10.0, 10.0) +} + +///| +test "upstream/generated/grid/grid_relayout_vertical_text" { + // Ported from taffy-reference/tests/generated/grid/grid_relayout_vertical_text.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Vertical, + }) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content()]), + [node0, node1], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 60.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 20.0, 0.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_repeat_integer" { + // Ported from taffy-reference/tests/generated/grid/grid_repeat_integer.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([repeat(repeat_count(3), [length(40.0)])]) + .with_grid_template_columns([repeat(repeat_count(3), [length(40.0)])]) + .with_size(Size(width=length(120.0), height=length(120.0))), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + let l8 = taffy.layout(nodes[8]) + assert_eq(l8.location.x, 80.0) + assert_eq(l8.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_repeat_mixed" { + // Ported from taffy-reference/tests/generated/grid/grid_repeat_mixed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([ + length(40.0), + repeat(repeat_count(1), [length(40.0)]), + repeat(repeat_auto_fill(), [length(40.0)]), + ]) + .with_grid_template_columns([ + length(40.0), + repeat(repeat_count(1), [length(40.0)]), + repeat(repeat_auto_fill(), [length(40.0)]), + ]) + .with_size(Size(width=length(120.0), height=length(120.0))), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_size_child_fixed_tracks" { + // Ported from taffy-reference/tests/generated/grid/grid_size_child_fixed_tracks.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()), + { text_content: "HHH\u{200b}HHH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()), + { text_content: "HH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node3 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=auto())), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node4 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_max_size(Size(width=length(30.0), height=auto())), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 120.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 20.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 40.0, 20.0, 80.0, 0.0) + assert_layout_xywh(taffy, node3, 20.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node4, 30.0, 40.0, 40.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=line(1), end=span(13))), + { + text_content: "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH", + writing_mode: Horizontal, + }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let node9 = taffy.new_leaf(Style::default()) + let node10 = taffy.new_leaf(Style::default()) + let node11 = taffy.new_leaf(Style::default()) + let node12 = taffy.new_leaf(Style::default()) + let node13 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + fit_content(length(20.0)), + auto(), + length(10.0), + percent(0.2), + minmax(length(2.0), auto()), + minmax(length(2.0), length(4.0)), + minmax(length(2.0), grid_min_content()), + minmax(length(2.0), grid_max_content()), + minmax(grid_min_content(), grid_max_content()), + minmax(grid_min_content(), auto()), + minmax(grid_max_content(), auto()), + ]), + [ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, + node11, node12, node13, + ], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 322.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 322.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 11.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 91.0, 40.0, 11.0, 40.0) + assert_layout_xywh(taffy, node3, 11.0, 40.0, 102.0, 40.0) + assert_layout_xywh(taffy, node4, 11.0, 40.0, 113.0, 40.0) + assert_layout_xywh(taffy, node5, 10.0, 40.0, 124.0, 40.0) + assert_layout_xywh(taffy, node6, 65.0, 40.0, 134.0, 40.0) + assert_layout_xywh(taffy, node7, 2.0, 40.0, 199.0, 40.0) + assert_layout_xywh(taffy, node8, 4.0, 40.0, 201.0, 40.0) + assert_layout_xywh(taffy, node9, 2.0, 40.0, 205.0, 40.0) + assert_layout_xywh(taffy, node10, 2.0, 40.0, 207.0, 40.0) + assert_layout_xywh(taffy, node11, 11.0, 40.0, 209.0, 40.0) + assert_layout_xywh(taffy, node12, 11.0, 40.0, 220.0, 40.0) + assert_layout_xywh(taffy, node13, 91.0, 40.0, 231.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_column(Line(start=line(1), end=span(13))), + { + text_content: "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH", + writing_mode: Horizontal, + }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let node9 = taffy.new_leaf(Style::default()) + let node10 = taffy.new_leaf(Style::default()) + let node11 = taffy.new_leaf(Style::default()) + let node12 = taffy.new_leaf(Style::default()) + let node13 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + fit_content(length(20.0)), + auto(), + length(10.0), + percent(0.2), + minmax(length(2.0), auto()), + minmax(length(2.0), length(4.0)), + minmax(length(2.0), grid_min_content()), + minmax(length(2.0), grid_max_content()), + minmax(grid_min_content(), grid_max_content()), + minmax(grid_min_content(), auto()), + minmax(grid_max_content(), auto()), + ]), + [ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, + node11, node12, node13, + ], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 322.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 322.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 16.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 95.0, 40.0, 16.0, 40.0) + assert_layout_xywh(taffy, node3, 0.0, 40.0, 111.0, 40.0) + assert_layout_xywh(taffy, node4, 0.0, 40.0, 111.0, 40.0) + assert_layout_xywh(taffy, node5, 10.0, 40.0, 111.0, 40.0) + assert_layout_xywh(taffy, node6, 64.0, 40.0, 121.0, 40.0) + assert_layout_xywh(taffy, node7, 2.0, 40.0, 185.0, 40.0) + assert_layout_xywh(taffy, node8, 4.0, 40.0, 187.0, 40.0) + assert_layout_xywh(taffy, node9, 2.0, 40.0, 191.0, 40.0) + assert_layout_xywh(taffy, node10, 2.0, 40.0, 193.0, 40.0) + assert_layout_xywh(taffy, node11, 16.0, 40.0, 195.0, 40.0) + assert_layout_xywh(taffy, node12, 15.0, 40.0, 211.0, 40.0) + assert_layout_xywh(taffy, node13, 96.0, 40.0, 226.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_auto_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_auto_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), auto()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 60.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_auto_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_auto_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), auto()]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 0.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 0.0, 40.0, 0.0, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part40_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part40_test.mbt new file mode 100644 index 0000000..95bc25e --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part40_test.mbt @@ -0,0 +1,997 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), fit_content(length(10.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 60.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), fit_content(length(10.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 0.0, 40.0, 80.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), fit_content(length(80.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 60.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), fit_content(length(80.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 0.0, 40.0, 80.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_max_content_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_max_content_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), grid_max_content()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 40.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_auto_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_auto_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), auto()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 60.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 10.0, 0.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_auto_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_auto_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), auto()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 40.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 10.0, 0.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(10.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(10.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 10.0, 40.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 50.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(30.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 30.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 50.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(30.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 70.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 30.0, 40.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 70.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(80.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 60.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(80.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 40.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_max_content_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_max_content_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), grid_max_content()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 60.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_min_content_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_min_content_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), grid_min_content()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_6_all_non_flex_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_6_all_non_flex_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=line(1), end=span(6))), + { text_content: "HHHHHHHH\u{200b}HHHHHHHH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + fit_content(length(20.0)), + auto(), + length(10.0), + percent(0.2), + ]), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 160.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 160.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 10.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 89.0, 40.0, 10.0, 40.0) + assert_layout_xywh(taffy, node3, 10.0, 40.0, 99.0, 40.0) + assert_layout_xywh(taffy, node4, 9.0, 40.0, 109.0, 40.0) + assert_layout_xywh(taffy, node5, 10.0, 40.0, 118.0, 40.0) + assert_layout_xywh(taffy, node6, 32.0, 40.0, 128.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_6_all_non_flex_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_6_all_non_flex_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_column(Line(start=line(1), end=span(6))), + { text_content: "HHHHHHHH\u{200b}HHHHHHHH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + fit_content(length(20.0)), + auto(), + length(10.0), + percent(0.2), + ]), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 160.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 160.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 19.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 99.0, 40.0, 19.0, 40.0) + assert_layout_xywh(taffy, node3, 0.0, 40.0, 118.0, 40.0) + assert_layout_xywh(taffy, node4, 0.0, 40.0, 118.0, 40.0) + assert_layout_xywh(taffy, node5, 10.0, 40.0, 118.0, 40.0) + assert_layout_xywh(taffy, node6, 32.0, 40.0, 128.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_8_all_track_types_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_8_all_track_types_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=line(1), end=span(8))), + { text_content: "HHHHHHHH\u{200b}HHHHHHHH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + fit_content(length(20.0)), + auto(), + length(10.0), + percent(0.2), + fr(1.0), + fr(2.0), + ]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 160.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 160.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 0.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 0.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node3, 0.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node4, 0.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node5, 10.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node6, 32.0, 40.0, 10.0, 40.0) + assert_layout_xywh(taffy, node7, 39.0, 40.0, 42.0, 40.0) + assert_layout_xywh(taffy, node8, 79.0, 40.0, 81.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_taffy_issue_624" { + // Ported from taffy-reference/tests/generated/grid/grid_taffy_issue_624.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=span(2))) + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(100.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=span(2))) + .with_grid_column(Line(start=line(2), end=span(2))) + .with_size(Size(width=length(40.0), height=length(30.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(3), end=span(1))) + .with_grid_column(Line(start=line(1), end=span(2))) + .with_size(Size(width=length(120.0), height=length(20.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_start()) + .with_justify_content(justify_content_start()) + .with_grid_template_rows([auto(), auto(), auto(), fr(1.0)]) + .with_grid_template_columns([auto(), auto(), fr(1.0)]) + .with_size(Size(width=length(320.0), height=length(640.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 320.0, 640.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 30.0, 100.0, 0.0) + assert_layout_xywh(taffy, node2, 120.0, 20.0, 0.0, 50.0) +} + +///| +test "upstream/generated/grid/mod" { + // Ported from taffy-reference/tests/generated/grid/mod.rs + () +} + +///| +test "upstream/generated/gridflex/gridflex_column_integration" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_column_integration.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node02 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node03 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([fr(1.0), fr(1.0)]) + .with_grid_template_columns([fr(1.0), fr(1.0)]), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 40.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 20.0) + assert_eq(l01.size.height, 10.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 0.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 20.0) + assert_eq(l02.size.height, 10.0) + assert_eq(l02.location.x, 0.0) + assert_eq(l02.location.y, 10.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 20.0) + assert_eq(l03.size.height, 10.0) + assert_eq(l03.location.x, 20.0) + assert_eq(l03.location.y, 10.0) +} + +///| +test "upstream/generated/gridflex/gridflex_kitchen_sink" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_kitchen_sink.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node00100 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node00101 = taffy.new_leaf(Style::default()) + let node00102 = taffy.new_leaf(Style::default()) + let node00103 = taffy.new_leaf(Style::default()) + let node0010 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.3), percent(0.1)]) + .with_grid_template_columns([auto(), percent(0.1)]), + [node00100, node00101, node00102, node00103], + ) + let node001 = taffy.new_with_children( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(50.0), height=auto())), + [node0010], + ) + let node00 = taffy.new_with_children(Style::default(), [node000, node001]) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node02 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node03 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([fr(1.0), fr(1.0)]) + .with_grid_template_columns([fr(1.0), fr(1.0)]), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 140.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 140.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + let l001 = taffy.layout(node001) + assert_eq(l000.size.width, 20.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + assert_eq(l001.size.width, 50.0) + assert_eq(l001.size.height, 10.0) + assert_eq(l001.location.x, 20.0) + assert_eq(l001.location.y, 0.0) + let l0010 = taffy.layout(node0010) + assert_eq(l0010.size.width, 20.0) + assert_eq(l0010.size.height, 10.0) + assert_eq(l0010.location.x, 0.0) + assert_eq(l0010.location.y, 0.0) + let l00100 = taffy.layout(node00100) + assert_eq(l00100.size.width, 20.0) + assert_eq(l00100.size.height, 3.0) + assert_eq(l00100.location.x, 0.0) + assert_eq(l00100.location.y, 0.0) + let l00101 = taffy.layout(node00101) + assert_eq(l00101.size.width, 2.0) + assert_eq(l00101.size.height, 3.0) + assert_eq(l00101.location.x, 20.0) + assert_eq(l00101.location.y, 0.0) + let l00102 = taffy.layout(node00102) + assert_eq(l00102.size.width, 20.0) + assert_eq(l00102.size.height, 1.0) + assert_eq(l00102.location.x, 0.0) + assert_eq(l00102.location.y, 3.0) + let l00103 = taffy.layout(node00103) + assert_eq(l00103.size.width, 2.0) + assert_eq(l00103.size.height, 1.0) + assert_eq(l00103.location.x, 20.0) + assert_eq(l00103.location.y, 3.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 70.0) + assert_eq(l01.size.height, 10.0) + assert_eq(l01.location.x, 70.0) + assert_eq(l01.location.y, 0.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 70.0) + assert_eq(l02.size.height, 10.0) + assert_eq(l02.location.x, 0.0) + assert_eq(l02.location.y, 10.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 70.0) + assert_eq(l03.size.height, 10.0) + assert_eq(l03.location.x, 70.0) + assert_eq(l03.location.y, 10.0) +} + +///| +test "upstream/generated/gridflex/gridflex_kitchen_sink_minimise" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_kitchen_sink_minimise.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node01 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(20.0)]) + .with_grid_template_columns([fr(1.0), fr(1.0)]), + [node00, node01], + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 50.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 50.0) + assert_eq(l01.location.y, 0.0) +} + +///| +test "upstream/generated/gridflex/gridflex_kitchen_sink_minimise2" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_kitchen_sink_minimise2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([auto()]) + .with_grid_template_columns([auto()]), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/gridflex/gridflex_kitchen_sink_minimise3" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_kitchen_sink_minimise3.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node01 = taffy.new_leaf(Style::default()) + let node02 = taffy.new_leaf(Style::default()) + let node03 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.3), percent(0.1)]) + .with_grid_template_columns([auto(), percent(0.1)]), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 2.0) + assert_eq(l01.size.height, 6.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 0.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 20.0) + assert_eq(l02.size.height, 2.0) + assert_eq(l02.location.x, 0.0) + assert_eq(l02.location.y, 6.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 2.0) + assert_eq(l03.size.height, 2.0) + assert_eq(l03.location.x, 20.0) + assert_eq(l03.location.y, 6.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part41_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part41_test.mbt new file mode 100644 index 0000000..f979c95 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part41_test.mbt @@ -0,0 +1,421 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +test "upstream/generated/gridflex/gridflex_row_integration" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_row_integration.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node02 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node03 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([fr(1.0), fr(1.0)]) + .with_grid_template_columns([fr(1.0), fr(1.0)]), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 40.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 20.0) + assert_eq(l01.size.height, 10.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 0.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 20.0) + assert_eq(l02.size.height, 10.0) + assert_eq(l02.location.x, 0.0) + assert_eq(l02.location.y, 10.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 20.0) + assert_eq(l03.size.height, 10.0) + assert_eq(l03.location.x, 20.0) + assert_eq(l03.location.y, 10.0) +} + +///| +test "upstream/generated/gridflex/mod" { + // Upstream mod.rs only declares submodules; no standalone runnable vector. + () +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_affect_available_space_x_axis" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_x_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(45.0), height=length(45.0))), + { text_content: "HHHHHHHHHHHHHHHHHHHHH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 45.0) + assert_eq(l_node.size.height, 45.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_affect_available_space_y_axis" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_y_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(45.0), height=length(45.0))), + { text_content: "HHHHHHHHHHHHHHHHHHHHH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 45.0) + assert_eq(l_node.size.height, 45.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_overridden_by_available_space" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_available_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_flex_grow(1.0), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 2.0) + assert_eq(l0.size.height, 4.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_overridden_by_max_size" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_max_size(Size(width=length(2.0), height=length(4.0))), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_overridden_by_size" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(2.0), height=length(4.0))), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_take_up_space_both_axis" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_both_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0), + { text_content: "HH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 35.0) + assert_eq(l_node.size.height, 25.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_take_up_space_x_axis" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_x_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0), + { text_content: "HH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 25.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_take_up_space_y_axis" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_y_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0), + { text_content: "HH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 35.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/leaf/leaf_padding_border_overrides_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_padding_border_overrides_min_size" { + // Ported from taffy-reference/tests/generated/leaf/leaf_padding_border_overrides_min_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(0.0), height=length(0.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/leaf/leaf_padding_border_overrides_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_with_content_and_border" { + // Ported from taffy-reference/tests/generated/leaf/leaf_with_content_and_border.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default().with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + { text_content: "HHHH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 52.0) + assert_eq(l_node.size.height, 18.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_with_content_and_padding" { + // Ported from taffy-reference/tests/generated/leaf/leaf_with_content_and_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default().with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + { text_content: "HHHH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 52.0) + assert_eq(l_node.size.height, 18.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_with_content_and_padding_border" { + // Ported from taffy-reference/tests/generated/leaf/leaf_with_content_and_padding_border.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + { text_content: "HHHH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 62.0) + assert_eq(l_node.size.height, 24.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/mod" { + // Upstream mod.rs only declares submodules; no standalone runnable vector. + () +} + +///| +test "upstream/generated/./mod" { + // Upstream mod.rs only declares submodules; no standalone runnable vector. + () +} diff --git a/conformance/chicle/upstream/upstream_misc_stub_test.mbt b/conformance/chicle/upstream/upstream_misc_stub_test.mbt new file mode 100644 index 0000000..e371e92 --- /dev/null +++ b/conformance/chicle/upstream/upstream_misc_stub_test.mbt @@ -0,0 +1,827 @@ +// Copyright 2025 International Digital Economy Academy +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +///| +struct MiscFixedMeasure { + width : Double + height : Double +} + +///| +struct MiscAspectRatioMeasure { + width : Double + height_ratio : Double +} + +///| +fn[T] misc_unwrap_or(value : T?, fallback : T) -> T { + match value { + Some(v) => v + None => fallback + } +} + +///| +fn misc_fixed_measure( + known_dimensions : Size[Double?], + _available_space : Size[AvailableSpace], + _node_id : NodeId, + node_context : MiscFixedMeasure?, + _style : Style, +) -> Size[Double] { + let ctx = match node_context { + Some(v) => v + None => { width: 0.0, height: 0.0 } + } + Size( + width=misc_unwrap_or(known_dimensions.width, ctx.width), + height=misc_unwrap_or(known_dimensions.height, ctx.height), + ) +} + +///| +fn misc_aspect_ratio_measure( + known_dimensions : Size[Double?], + _available_space : Size[AvailableSpace], + _node_id : NodeId, + node_context : MiscAspectRatioMeasure?, + _style : Style, +) -> Size[Double] { + let ctx = match node_context { + Some(v) => v + None => return Size::zero() + } + let width = misc_unwrap_or(known_dimensions.width, ctx.width) + let height = misc_unwrap_or(known_dimensions.height, width * ctx.height_ratio) + Size(width~, height~) +} + +///| +fn misc_square_measure( + known_dimensions : Size[Double?], + _available_space : Size[AvailableSpace], + _node_id : NodeId, + _node_context : Unit?, + _style : Style, +) -> Size[Double] { + let height = misc_unwrap_or(known_dimensions.height, 50.0) + let width = misc_unwrap_or(known_dimensions.width, height) + Size(width~, height~) +} + +///| +fn misc_count_measure( + known_dimensions : Size[Double?], + _available_space : Size[AvailableSpace], + _node_id : NodeId, + node_context : Array[Int]?, + _style : Style, +) -> Size[Double] { + match node_context { + Some(ctx) => ctx[0] = ctx[0] + 1 + None => () + } + Size( + width=misc_unwrap_or(known_dimensions.width, 50.0), + height=misc_unwrap_or(known_dimensions.height, 50.0), + ) +} + +///| +fn[C] misc_assert_layout_xywh( + taffy : ChicleTree[C], + node : NodeId, + x : Double, + y : Double, + width : Double, + height : Double, +) -> Unit raise Error { + let layout = taffy.layout(node) + assert_eq(layout.location.x, x) + assert_eq(layout.location.y, y) + assert_eq(layout.size.width, width) + assert_eq(layout.size.height, height) +} + +///| +test "upstream/caching/measure_count_flexbox" { + let taffy : ChicleTree[Array[Int]] = ChicleTree() + let leaf_counter = [0] + let leaf = taffy.new_leaf_with_context(Style::default(), leaf_counter) + let mut node = taffy.new_with_children(Style::default(), [leaf]) + for _ in 0..<100 { + node = taffy.new_with_children(Style::default(), [node]) + } + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_count_measure, + ) + match taffy.node_context(leaf) { + Some(ctx) => assert_eq(ctx[0], 4) + None => panic() + } +} + +///| +test "upstream/caching/measure_count_grid" { + let taffy : ChicleTree[Array[Int]] = ChicleTree() + let leaf_counter = [0] + let leaf = taffy.new_leaf_with_context( + Style::default().with_display(display_grid()), + leaf_counter, + ) + let mut node = taffy.new_with_children(Style::default(), [leaf]) + for _ in 0..<100 { + node = taffy.new_with_children(Style::default(), [node]) + } + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_count_measure, + ) + match taffy.node_context(leaf) { + Some(ctx) => assert_eq(ctx[0], 4) + None => panic() + } +} + +///| +test "upstream/measure/measure_root" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height: 100.0, + }) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(node).size.width, 100.0) + assert_eq(taffy.layout(node).size.height, 100.0) +} + +///| +test "upstream/measure/measure_child" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height: 100.0, + }) + let node = taffy.new_with_children(Style::default(), [child]) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(node).size.width, 100.0) + assert_eq(taffy.layout(node).size.height, 100.0) + assert_eq(taffy.layout(child).size.width, 100.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/measure/measure_child_constraint" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height: 100.0, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=auto())), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(node).size.width, 50.0) + assert_eq(taffy.layout(node).size.height, 100.0) + assert_eq(taffy.layout(child).size.width, 100.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/measure/measure_child_constraint_padding_parent" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height: 100.0, + }) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 50.0, 120.0) + misc_assert_layout_xywh(taffy, child, 10.0, 10.0, 100.0, 100.0) +} + +///| +test "upstream/measure/measure_child_with_flex_grow" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let child1 = taffy.new_leaf_with_context( + Style::default().with_flex_grow(1.0), + { width: 10.0, height: 50.0 }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [child0, child1], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child1).size.width, 50.0) + assert_eq(taffy.layout(child1).size.height, 50.0) +} + +///| +test "upstream/measure/measure_child_with_flex_shrink" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_flex_shrink(0.0), + ) + let child1 = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height: 50.0, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [child0, child1], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child1).size.width, 100.0) + assert_eq(taffy.layout(child1).size.height, 50.0) +} + +///| +test "upstream/measure/remeasure_child_after_growing" { + let taffy : ChicleTree[MiscAspectRatioMeasure] = ChicleTree() + let child0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let child1 = taffy.new_leaf_with_context( + Style::default().with_flex_grow(1.0), + { width: 10.0, height_ratio: 2.0 }, + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=auto())) + .with_align_items(align_items_start()), + [child0, child1], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_aspect_ratio_measure, + ) + assert_eq(taffy.layout(child1).size.width, 50.0) + assert_eq(taffy.layout(child1).size.height, 100.0) +} + +///| +test "upstream/measure/remeasure_child_after_shrinking" { + let taffy : ChicleTree[MiscAspectRatioMeasure] = ChicleTree() + let child0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_flex_shrink(0.0), + ) + let child1 = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height_ratio: 2.0, + }) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=auto())) + .with_align_items(align_items_start()), + [child0, child1], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_aspect_ratio_measure, + ) + assert_eq(taffy.layout(child1).size.width, 100.0) + assert_eq(taffy.layout(child1).size.height, 200.0) +} + +///| +test "upstream/measure/remeasure_child_after_stretching" { + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf_with_context(Style::default(), ()) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_square_measure, + ) + assert_eq(taffy.layout(child).size.width, 100.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/measure/width_overrides_measure" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(50.0), height=auto())), + { width: 100.0, height: 100.0 }, + ) + let node = taffy.new_with_children(Style::default(), [child]) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child).size.width, 50.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/measure/height_overrides_measure" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + { width: 100.0, height: 100.0 }, + ) + let node = taffy.new_with_children(Style::default(), [child]) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child).size.width, 100.0) + assert_eq(taffy.layout(child).size.height, 50.0) +} + +///| +test "upstream/measure/flex_basis_overrides_measure" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child0 = taffy.new_leaf( + Style::default().with_flex_basis(length(50.0)).with_flex_grow(1.0), + ) + let child1 = taffy.new_leaf_with_context( + Style::default().with_flex_basis(length(50.0)).with_flex_grow(1.0), + { width: 100.0, height: 100.0 }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(100.0))), + [child0, child1], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child0).size.width, 100.0) + assert_eq(taffy.layout(child0).size.height, 100.0) + assert_eq(taffy.layout(child1).size.width, 100.0) + assert_eq(taffy.layout(child1).size.height, 100.0) +} + +///| +test "upstream/measure/stretch_overrides_measure" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context(Style::default(), { + width: 50.0, + height: 50.0, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child).size.width, 50.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/measure/measure_absolute_child" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context( + Style::default().with_position(position_absolute()), + { width: 50.0, height: 50.0 }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child).size.width, 50.0) + assert_eq(taffy.layout(child).size.height, 50.0) +} + +///| +test "upstream/measure/ignore_invalid_measure" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child).size.width, 100.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/min_max_overrides/min_overrides_max" { + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_min_size(Size(width=length(100.0), height=length(100.0))) + .with_max_size(Size(width=length(10.0), height=length(10.0))), + ) + taffy.compute_layout( + child, + Size( + width=available_space_definite(100.0), + height=available_space_definite(100.0), + ), + ) + let layout = taffy.layout(child) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) +} + +///| +test "upstream/min_max_overrides/max_overrides_size" { + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_max_size(Size(width=length(10.0), height=length(10.0))), + ) + taffy.compute_layout( + child, + Size( + width=available_space_definite(100.0), + height=available_space_definite(100.0), + ), + ) + let layout = taffy.layout(child) + assert_eq(layout.size.width, 10.0) + assert_eq(layout.size.height, 10.0) +} + +///| +test "upstream/min_max_overrides/min_overrides_size" { + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_min_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout( + child, + Size( + width=available_space_definite(100.0), + height=available_space_definite(100.0), + ), + ) + let layout = taffy.layout(child) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) +} + +///| +test "upstream/relayout/relayout" { + let taffy : ChicleTree[Unit] = ChicleTree() + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(8.0), height=length(80.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_align_self(align_items_center()) + .with_size(Size(width=auto(), height=auto())), + [node1], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + [node0], + ) + let available : Size[AvailableSpace] = Size( + width=available_space_definite(100.0), + height=available_space_definite(100.0), + ) + taffy.compute_layout(node, available) + let initial = taffy.layout(node).location + let initial0 = taffy.layout(node0).location + let initial1 = taffy.layout(node1).location + for _ in 1..<10 { + taffy.compute_layout(node, available) + let l = taffy.layout(node).location + let l0 = taffy.layout(node0).location + let l1 = taffy.layout(node1).location + assert_eq(l.x, initial.x) + assert_eq(l.y, initial.y) + assert_eq(l0.x, initial0.x) + assert_eq(l0.y, initial0.y) + assert_eq(l1.x, initial1.x) + assert_eq(l1.y, initial1.y) + } +} + +///| +test "upstream/relayout/toggle_flex_child_display_none" { + let hidden_style = Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let flex_style = Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let taffy : ChicleTree[Unit] = ChicleTree() + let node = taffy.new_leaf(hidden_style) + let root = taffy.new_with_children(flex_style, [node]) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 0.0, 0.0) + taffy.set_style( + node, + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 100.0, 100.0) + taffy.set_style( + node, + Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/relayout/toggle_flex_container_display_none" { + let hidden_style = Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let flex_style = Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let taffy : ChicleTree[Unit] = ChicleTree() + let node = taffy.new_leaf(hidden_style) + let root = taffy.new_with_children(hidden_style, [node]) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 0.0, 0.0) + taffy.set_style(root, flex_style) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 100.0, 100.0) + taffy.set_style(root, hidden_style) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/relayout/toggle_grid_child_display_none" { + let hidden_style = Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let grid_style = Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let taffy : ChicleTree[Unit] = ChicleTree() + let node = taffy.new_leaf(hidden_style) + let root = taffy.new_with_children(grid_style, [node]) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 0.0, 0.0) + taffy.set_style( + node, + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 100.0, 100.0) + taffy.set_style( + node, + Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/relayout/toggle_grid_container_display_none" { + let hidden_style = Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let grid_style = Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let taffy : ChicleTree[Unit] = ChicleTree() + let node = taffy.new_leaf(hidden_style) + let root = taffy.new_with_children(hidden_style, [node]) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 0.0, 0.0) + taffy.set_style(root, grid_style) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 100.0, 100.0) + taffy.set_style(root, hidden_style) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/relayout/relayout_is_stable_with_rounding" { + let taffy : ChicleTree[Unit] = ChicleTree() + let inner = taffy.new_leaf( + Style::default().with_min_size(Size(width=length(300.0), height=auto())), + ) + let wrapper = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(150.0), height=auto())) + .with_justify_content(justify_content_end()), + [inner], + ) + let outer = taffy.new_with_children( + Style::default() + .with_size(Size(width=percent(1.0), height=auto())) + .with_inset(Rect(left=length(1.5), right=auto(), top=auto(), bottom=auto())), + [wrapper], + ) + let root = taffy.new_with_children( + Style::default().with_size( + Size(width=length(1920.0), height=length(1080.0)), + ), + [outer], + ) + taffy.mark_dirty(root) + taffy.compute_layout(root, Size::max_content()) + let root0 = taffy.layout(root) + let outer0 = taffy.layout(outer) + let wrapper0 = taffy.layout(wrapper) + let inner0 = taffy.layout(inner) + for _ in 0..<5 { + taffy.mark_dirty(root) + taffy.compute_layout(root, Size::max_content()) + let r = taffy.layout(root) + let o = taffy.layout(outer) + let w = taffy.layout(wrapper) + let i = taffy.layout(inner) + assert_eq(r.location.x, root0.location.x) + assert_eq(r.location.y, root0.location.y) + assert_eq(r.size.width, root0.size.width) + assert_eq(r.size.height, root0.size.height) + assert_eq(o.location.x, outer0.location.x) + assert_eq(o.location.y, outer0.location.y) + assert_eq(o.size.width, outer0.size.width) + assert_eq(o.size.height, outer0.size.height) + assert_eq(w.location.x, wrapper0.location.x) + assert_eq(w.location.y, wrapper0.location.y) + assert_eq(w.size.width, wrapper0.size.width) + assert_eq(w.size.height, wrapper0.size.height) + assert_eq(i.location.x, inner0.location.x) + assert_eq(i.location.y, inner0.location.y) + assert_eq(i.size.width, inner0.size.width) + assert_eq(i.size.height, inner0.size.height) + } +} + +///| +test "upstream/serde/serde_can_serialize" { + let style = Style::default() + let _ = style.to_json().stringify() +} + +///| +test "upstream/serde/serde_can_deserialize_partial_values" { + let json_str = + #|{ + #| "inset": { + #| "left": { "Length": 22 }, + #| "right": "Auto" + #| }, + #| "size": { + #| "width": { "Percent": 50 } + #| }, + #| "min_size": { + #| "height": { "Length": 10 } + #| }, + #| "max_size": { + #| "width": "Auto" + #| }, + #| "margin": { + #| "right": { "Length": 99.0 }, + #| "bottom": { "Length": 99.0 } + #| }, + #| "padding": { + #| "left": { "Length": 99.0 } + #| }, + #| "border": { + #| "bottom": { "Length": 99.0 } + #| }, + #| "gap": { + #| "width": { "Length": 99.0 } + #| }, + #| "grid_row": { "start": "Auto" }, + #| "grid_column": { "end": "Auto" } + #|} + let json = @json.parse(json_str) + let style : Style = @json.from_json(json) + match style.inset.left { + DimLength(v) => assert_eq(v, 22.0) + _ => panic() + } + match style.inset.right { + DimAuto => () + _ => panic() + } + match style.size.width { + DimPercent(v) => assert_eq(v, 50.0) + _ => panic() + } + match style.min_size.height { + DimLength(v) => assert_eq(v, 10.0) + _ => panic() + } + match style.max_size.width { + DimAuto => () + _ => panic() + } + match style.margin.right { + DimLength(v) => assert_eq(v, 99.0) + _ => panic() + } + match style.margin.bottom { + DimLength(v) => assert_eq(v, 99.0) + _ => panic() + } + match style.padding.left { + DimLength(v) => assert_eq(v, 99.0) + _ => panic() + } + match style.border.bottom { + DimLength(v) => assert_eq(v, 99.0) + _ => panic() + } + match style.gap.width { + DimLength(v) => assert_eq(v, 99.0) + _ => panic() + } + match style.grid_row.start { + PlaceAuto => () + _ => panic() + } + match style.grid_column.end { + PlaceAuto => () + _ => panic() + } +} diff --git a/docs/PORTING.md b/docs/PORTING.md index 0253eea..bd4cfca 100644 --- a/docs/PORTING.md +++ b/docs/PORTING.md @@ -132,7 +132,7 @@ stays isolated. | `scene` | `scene.rs`, `bounds_tree.rs`, `AtlasTile` (platform.rs) | pure | **done** (see deviations) | | `font` | `Font`, `FontWeight`, `FontStyle`, `FontFeatures`, `FontFallbacks` (text_system.rs) | pure | **done** (descriptors only) | | `style` | `style.rs`, `styled.rs`, Refineable, gpui_macros style helpers | pure | **done** (generated by `tools/gen_style.py`) | -| `layout` | `taffy.rs` (+ a taffy port) | pure | next | +| `layout` | `taffy.rs` (engine on `Milky2018/chicle`, a taffy port) | pure | **done** (no cross-frame node cache yet) | | `keymap` | `keymap.rs`, `keymap/*`, `platform/keystroke.rs` | pure | planned | | `action` | `action.rs` | pure | planned | | `app` | `app.rs`, `app/*`, `subscription.rs`, `global.rs`, `gpui.rs` traits | pure | planned | @@ -209,6 +209,7 @@ records what I verified with toolchain `moon 0.1.20261119`. | Need | Package | Backends | Notes | | --- | --- | --- | --- | | Flexbox/grid layout | `Milky2018/moon_taffy@0.5.3` | all (pure) | Port of taffy 0.5.2 (GPUI uses 0.15). **Does not compile on the current toolchain**: 32 errors in `style/style_json.mbt` from the new explicit trait-method `extend` rule. Needs an upstream fix or a vendored patch. | +| Flexbox/grid layout (used) | `Milky2018/chicle@0.6.3` | all (pure) | Successor of `moon_taffy` from the same upstream repository; builds on the current toolchain. **All 1,038 of `moon_taffy`'s taffy fixtures pass against it on all four backends** (`conformance/chicle`). | | Flexbox (alt.) | `NoahLiu/yoga-mbt@0.1.1` | pure | Yoga-style flexbox only, with no grid. | | Text shaping/layout | `Milky2018/moon_cosmic@0.3.9` | all (pure) | Port of cosmic-text on `moon_swash`, `moon_skrifa`, and `moon_zeno`. **Checks on js and native.** It is what `gpui_web`/`gpui_wgpu` use upstream (cosmic-text), so it fits well. | | Font parsing | `Milky2018/moon_skrifa`, `mizchi/font`, `bikallem/freetype` | pure | | @@ -221,7 +222,7 @@ records what I verified with toolchain `moon 0.1.20261119`. | Taffy-free layout ref | `Frank-III/onebit-tui` | native | Uses Yoga through FFI. Not useful here. | Recommendation: depend on `moon_cosmic` for text when that milestone -arrives. For layout, **fork/vendor `moon_taffy`** (Apache-2.0) and fix it for +arrives. For layout, the original plan was to **fork/vendor `moon_taffy`** (Apache-2.0) and fix it for the toolchain, or send the fix upstream. Writing flexbox from scratch would be the costlier path. @@ -342,13 +343,15 @@ gantt `rounded_md`, `shadow_lg`, ...). - Tests: refinement cascade semantics, and helper values matching GPUI's (for example `p_2 == rems(0.5)`). -- **M2: layout.** - - Vendor and fix `moon_taffy`, or port the taffy flexbox, block, and grid - algorithms needed. +- **M2: layout (done).** + - Depends on `Milky2018/chicle` (see decision 3). - `LayoutEngine` with `request_layout`, `request_measured_layout`, - `compute_layout`, and `layout_bounds`, plus `Style` → taffy conversion - with rem and scale resolution. - - Tests: a corpus of flexbox cases (taffy's generated tests). + `compute_layout`, `layout_bounds`, and `stretch_auto_size_to_fill`. + - `Style` → engine conversion with rem resolution and device-pixel + snapping. + - Tests: GPUI's rounding and stroke-snapping tests, plus layout + scenarios. The engine is checked separately by the 1,038-fixture + conformance suite in `conformance/chicle`. - **M3: app model.** - `App`, `Entity[T]`/`WeakEntity[T]`, and `Context[T]`. - `notify`, `observe`, `subscribe`/`emit` with typed event keys, globals, @@ -444,6 +447,19 @@ gantt - The refinement `Cascade` and `Style::paint` (which needs `Window`) wait for M6. The conversion to taffy styles waits for M2. +### Deviations taken in M2 (layout) +- There is no cross-frame node cache yet. GPUI reuses taffy nodes keyed by + element path, and reuses measure closures by key. That cache depends on + element ids from the Window, so it comes in M6. Until then the engine is + rebuilt on `clear()`, as older GPUI versions did. +- `compute_layout` takes the scale factor instead of `&mut Window`. +- Measure functions are `(known, available) -> Size[Pixels]` closures. They + do not receive GPUI's `final_layout` flag, because chicle's measure + callback does not report the run mode. +- The engine keeps its own parent/child maps, because chicle has no + `parent`/`children` queries. Misuse fails loudly: an unknown or stale + `LayoutId`, or a child given two parents, aborts. + ## 7. Design decisions Decided on 2026-11-24, following the recommendations below. @@ -454,8 +470,12 @@ Decided on 2026-11-24, following the recommendations below. 2. **Text shaping on the web.** Shape with `moon_cosmic`, which is pure, the same on every backend, and matches upstream `gpui_web`, using bundled fonts. Canvas text is used only as an emoji/CJK fallback, as upstream does. -3. **Layout engine.** Vendor `moon_taffy`, fix it for the current toolchain, - and send the fixes upstream. +3. **Layout engine.** The decision was to vendor `moon_taffy`, fix it, and + upstream the fixes. Revised in M2: upstream had already moved on and + published the fixed successor `Milky2018/chicle` 0.6.3. We depend on it + instead of forking. `moon_taffy`'s 1,038 taffy fixtures, which chicle no + longer ships, all pass against it. They are kept in `conformance/chicle` + and must be rerun before any chicle upgrade. 4. **First renderer.** Canvas2D on js first, then WebGPU reusing GPUI's WGSL shaders. 5. **API surface naming.** Keep GPUI names verbatim (`div()`, `px()`, diff --git a/moon.mod b/moon.mod index a8ca10a..37e9207 100644 --- a/moon.mod +++ b/moon.mod @@ -16,3 +16,7 @@ description = "A MoonBit port of GPUI, Zed's GPU-accelerated UI framework" source = "src" preferred_target = "js" + +import { + "Milky2018/chicle@0.6.3", +} diff --git a/src/examples/card/main.mbt b/src/examples/card/main.mbt index 930fd88..d03d339 100644 --- a/src/examples/card/main.mbt +++ b/src/examples/card/main.mbt @@ -1,7 +1,7 @@ -// A headless example of what exists so far (M0 + M1): describe a "card" with -// GPUI's fluent style API, resolve it, and paint it into a Scene by hand. -// There is no layout engine or renderer yet, so bounds are fixed and the -// output is a text report of the scene's draw batches. +// A headless example of what exists so far (M0-M2): describe a "card" with +// GPUI's fluent style API, lay it out with the layout engine (text is a fake +// fixed-width measure until the text system lands), and paint it into a +// Scene. There is no renderer yet, so the output is a text report. // // Run with: moon run src/examples/card --target js @@ -78,6 +78,33 @@ fn paint_card( ) } +///| +/// A stand-in for text measurement (M9): `char_width` per character, wrapping +/// at the available width, one `line_height` per line. +fn fake_text( + chars : Int32, + char_width : Double, + line_height : Double, +) -> @layout.MeasureFn { + fn(known, available) { + let natural = chars.to_double() * char_width + let wrap = match (known.width, available.width) { + (Some(width), _) => width.to_double() + (None, Definite(width)) => width.to_double() + (None, _) => natural + } + let width = if natural < wrap { natural } else { wrap } + let per_line = (wrap / char_width).floor() + let lines = (chars.to_double() / per_line).ceil() + @geometry.size(@geometry.px(width), @geometry.px(lines * line_height)) + } +} + +///| +fn show_bounds(bounds : @geometry.Bounds[@geometry.Pixels]) -> String { + "(\{bounds.origin.x}, \{bounds.origin.y}) \{bounds.size.width} x \{bounds.size.height}" +} + ///| /// Builds the report printed by `main`. fn report() -> String { @@ -85,21 +112,48 @@ fn report() -> String { let scale_factor = 2.0 let style = (Default::default() : @style.Style).refined(card_style()) let text = (Default::default() : @style.TextStyle).refined(style.text) - let bounds : @geometry.Bounds[@geometry.Pixels] = { - origin: @geometry.point(@geometry.px(40.0), @geometry.px(40.0)), - size: @geometry.size(@geometry.px(320.0), @geometry.px(120.0)), - } + let line_height = text.line_height_in_pixels(rem_size).to_double() + // Layout: window root > card > (title, body). + let engine = @layout.LayoutEngine::new() + let leaf_style : @style.Style = Default::default() + let title = engine.request_measured_layout( + leaf_style, + rem_size, + scale_factor, + fake_text(16, 9.0, line_height), + ) + let body = engine.request_measured_layout( + leaf_style, + rem_size, + scale_factor, + fake_text(90, 7.0, line_height), + ) + let card = engine.request_layout(style, rem_size, scale_factor, [title, body]) + let root_style = (Default::default() : @style.Style).refined( + @style.StyleRefinement::new().flex().items_start().p(@geometry.px(40.0)), + ) + let root = engine.request_layout(root_style, rem_size, scale_factor, [card]) + let window_size = @geometry.size(@geometry.px(480.0), @geometry.px(320.0)) + engine.stretch_auto_size_to_fill(root, window_size, scale_factor) + engine.compute_layout( + root, + @layout.AvailableSpace::from_size(window_size), + scale_factor, + ) + let card_bounds = engine.layout_bounds(card, scale_factor) + let title_bounds = engine.layout_bounds(title, scale_factor) + let body_bounds = engine.layout_bounds(body, scale_factor) + // Paint. let scene = @scene.Scene::new() - paint_card(scene, style, bounds, rem_size, scale_factor) - // A title underline, overlapping the card. + paint_card(scene, style, card_bounds, rem_size, scale_factor) scene.insert_primitive( Underline({ order: 0, bounds: @geometry.bounds( - @geometry.point(@geometry.px(56.0), @geometry.px(76.0)), - @geometry.size(@geometry.px(120.0), @geometry.px(1.0)), + title_bounds.bottom_left(), + @geometry.size(title_bounds.size.width, @geometry.px(1.0)), ).scale(scale_factor), - content_mask: { bounds: bounds.scale(scale_factor), }, + content_mask: { bounds: card_bounds.scale(scale_factor), }, color: text.color, thickness: @geometry.ScaledPixels(2.0), wavy: false, @@ -112,7 +166,12 @@ fn report() -> String { " width: \{style.size.width}, padding: \{style.padding.top}, gap: \{style.gap.width}", " radius: \{style.corner_radii.top_left} = \{style.corner_radii.top_left.to_pixels(rem_size)}", " shadows: \{style.box_shadow.length()}", - " text: \{text.font_size.to_pixels(rem_size)} \{text.font_family}, color \{text.color.to_rgb()}", + " text: \{text.font_size.to_pixels(rem_size)} \{text.font_family}, line height \{line_height}px, color \{text.color.to_rgb()}", + "layout (logical px)", + " window \{show_bounds(engine.layout_bounds(root, scale_factor))}", + " card \{show_bounds(card_bounds)}", + " title \{show_bounds(title_bounds)}", + " body \{show_bounds(body_bounds)}", "scene at \{scale_factor}x", ] for batch in scene.batches() { diff --git a/src/examples/card/main_wbtest.mbt b/src/examples/card/main_wbtest.mbt index 63b61b6..a406beb 100644 --- a/src/examples/card/main_wbtest.mbt +++ b/src/examples/card/main_wbtest.mbt @@ -8,12 +8,17 @@ test "card report" { #| width: 320px, padding: 1rem, gap: 0.5rem #| radius: 0.5rem = 8px #| shadows: 2 - #| text: 14px .SystemUIFont, color #1f2328ff + #| text: 14px .SystemUIFont, line height 23px, color #1f2328ff + #|layout (logical px) + #| window (0px, 0px) 480px x 320px + #| card (40px, 40px) 320px x 134px + #| title (57px, 57px) 286px x 23px + #| body (57px, 88px) 286px x 69px #|scene at 2x #| shadows (2) #| quads (1) #| underlines (1) - #| quad order 1: 640 x 240 device px + #| quad order 1: 640 x 268 device px ), ) } diff --git a/src/examples/card/moon.pkg b/src/examples/card/moon.pkg index e3e94a1..01530c0 100644 --- a/src/examples/card/moon.pkg +++ b/src/examples/card/moon.pkg @@ -3,6 +3,7 @@ import { "experiments/gpui/color", "experiments/gpui/scene", "experiments/gpui/style", + "experiments/gpui/layout", "moonbitlang/core/debug", } diff --git a/src/layout/convert.mbt b/src/layout/convert.mbt new file mode 100644 index 0000000..5c73ae8 --- /dev/null +++ b/src/layout/convert.mbt @@ -0,0 +1,309 @@ +// Conversion from GPUI styles to the layout engine's styles, ported from +// gpui/src/taffy.rs (`LayoutStyle::to_taffy`, `ToTaffy`) and the rounding +// helpers in gpui/src/util.rs. +// +// GPUI lays out in *device* pixels: absolute lengths are resolved against the +// rem size, multiplied by the scale factor and rounded, so that layout results +// land on the pixel grid. `layout_bounds` divides back into logical pixels. + +///| +/// Rounds to the nearest integer, with ties going toward zero +/// (GPUI: `round_half_toward_zero`). +pub fn round_half_toward_zero(value : Double) -> Double { + let magnitude = (value.abs() - 0.5).ceil() + // `ceil(-0.5)` is -0.0; normalize so ties at ±0.5 give +0.0. + let magnitude = if magnitude == 0.0 { 0.0 } else { magnitude } + if value < 0.0 { + -magnitude + } else { + magnitude + } +} + +///| +/// Logical pixels to device pixels, rounded (GPUI: `round_to_device_pixel`). +pub fn round_to_device_pixel(logical : Double, scale_factor : Double) -> Double { + round_half_toward_zero(logical * scale_factor) +} + +///| +/// Like `round_to_device_pixel`, but a non-zero stroke is at least one device +/// pixel wide (GPUI: `round_stroke_to_device_pixel`). +pub fn round_stroke_to_device_pixel( + logical : Double, + scale_factor : Double, +) -> Double { + if logical == 0.0 { + 0.0 + } else { + let rounded = round_to_device_pixel( + if logical > 0.0 { + logical + } else { + 0.0 + }, + scale_factor, + ) + if rounded < 1.0 { + 1.0 + } else { + rounded + } + } +} + +///| +/// Logical pixels to device pixels, rounded up (GPUI: `ceil_to_device_pixel`). +pub fn ceil_to_device_pixel(logical : Double, scale_factor : Double) -> Double { + (logical * scale_factor).ceil() +} + +///| +fn absolute_to_device( + length : @geometry.AbsoluteLength, + rem_size : @geometry.Pixels, + scale_factor : Double, +) -> Double { + round_to_device_pixel(length.to_pixels(rem_size).to_double(), scale_factor) +} + +///| +fn definite_to_dimension( + length : @geometry.DefiniteLength, + rem_size : @geometry.Pixels, + scale_factor : Double, +) -> @cstyle.Dimension { + match length { + Absolute(absolute) => + DimLength(absolute_to_device(absolute, rem_size, scale_factor)) + Fraction(fraction) => DimPercent(fraction) + } +} + +///| +fn length_to_dimension( + length : @geometry.Length, + rem_size : @geometry.Pixels, + scale_factor : Double, +) -> @cstyle.Dimension { + match length { + Definite(definite) => + definite_to_dimension(definite, rem_size, scale_factor) + Auto => DimAuto + } +} + +///| +fn edges_to_rect( + edges : @geometry.Edges[@cstyle.Dimension], +) -> @cgeometry.Rect[@cstyle.Dimension] { + @cgeometry.Rect( + left=edges.left, + right=edges.right, + top=edges.top, + bottom=edges.bottom, + ) +} + +///| +fn size_to_engine( + size : @geometry.Size[@cstyle.Dimension], +) -> @cgeometry.Size[@cstyle.Dimension] { + @cgeometry.Size(width=size.width, height=size.height) +} + +///| +/// Border widths are snapped like strokes, so a hairline border stays +/// visible (GPUI: `border_widths_to_taffy`). +pub fn border_widths_to_engine( + widths : @geometry.Edges[@geometry.AbsoluteLength], + rem_size : @geometry.Pixels, + scale_factor : Double, +) -> @cgeometry.Rect[@cstyle.Dimension] { + edges_to_rect( + widths.map(fn(width) { + DimLength( + round_stroke_to_device_pixel( + width.to_pixels(rem_size).to_double(), + scale_factor, + ), + ) + }), + ) +} + +///| +fn display_to_engine(display : @style.Display) -> @cstyle.Display { + match display { + Block => DisplayBlock + Flex => DisplayFlex + Grid => DisplayGrid + @style.Display::None => DisplayNone + } +} + +///| +fn overflow_to_engine(overflow : @style.Overflow) -> @cstyle.Overflow { + match overflow { + Visible => OverflowVisible + Clip => OverflowClip + Hidden => OverflowHidden + Scroll => OverflowScroll + } +} + +///| +fn position_to_engine(position : @style.Position) -> @cstyle.Position { + match position { + Relative => PosRelative + Absolute => PosAbsolute + } +} + +///| +fn align_items_to_engine(align : @style.AlignItems) -> @cstyle.AlignItems { + match align { + Start => ItemsStart + End => ItemsEnd + FlexStart => ItemsFlexStart + FlexEnd => ItemsFlexEnd + Center => ItemsCenter + Baseline => ItemsBaseline + Stretch => ItemsStretch + } +} + +///| +fn align_content_to_engine(align : @style.AlignContent) -> @cstyle.AlignContent { + match align { + Start => AlignStart + End => AlignEnd + FlexStart => AlignFlexStart + FlexEnd => AlignFlexEnd + Center => AlignCenter + Stretch => AlignStretch + SpaceBetween => AlignSpaceBetween + SpaceEvenly => AlignSpaceEvenly + SpaceAround => AlignSpaceAround + } +} + +///| +fn flex_direction_to_engine( + direction : @style.FlexDirection, +) -> @cstyle.FlexDirection { + match direction { + Row => FlexRow + Column => FlexColumn + RowReverse => FlexRowReverse + ColumnReverse => FlexColumnReverse + } +} + +///| +fn flex_wrap_to_engine(wrap : @style.FlexWrap) -> @cstyle.FlexWrap { + match wrap { + NoWrap => FlexNoWrap + Wrap => @cstyle.FlexWrap::FlexWrap + WrapReverse => FlexWrapReverse + } +} + +///| +fn grid_placement_to_engine( + placement : @geometry.GridPlacement, +) -> @cstyle.GridPlacement { + match placement { + Line(line) => PlaceLine(line) + Span(span) => PlaceSpan(span) + Auto => PlaceAuto + } +} + +///| +fn grid_range_to_engine( + range : @geometry.GridRange, +) -> @cgeometry.Line[@cstyle.GridPlacement] { + @cgeometry.Line( + start=grid_placement_to_engine(range.start), + end=grid_placement_to_engine(range.end), + ) +} + +///| +/// `repeat(n, minmax(..))` tracks for GPUI's `grid_cols`/`grid_rows`. +fn grid_template_to_engine( + template : @style.GridTemplate?, +) -> Array[@cstyle.Dimension] { + match template { + Option::None => [] + Some(template) => { + let track : @cstyle.Dimension = match template.min_size { + Zero => DimMinMax(DimLength(0.0), DimFr(1.0)) + MinContent => DimMinMax(DimMinContent, DimFr(1.0)) + MaxContent => DimMinMax(DimLength(0.0), DimMaxContent) + } + [DimRepeat(RepeatCount(template.repeat), [track])] + } + } +} + +///| +/// Converts a resolved GPUI `Style` to the layout engine's style, resolving +/// rems and snapping absolute lengths to device pixels +/// (GPUI: `LayoutStyle::to_taffy`). +pub fn style_to_engine( + style : @style.Style, + rem_size : @geometry.Pixels, + scale_factor : Double, +) -> @cstyle.Style { + let length = fn(l : @geometry.Length) { + length_to_dimension(l, rem_size, scale_factor) + } + let definite = fn(l : @geometry.DefiniteLength) { + definite_to_dimension(l, rem_size, scale_factor) + } + let grid_location = style.grid_location + { + ..@cstyle.Style::default(), + display: display_to_engine(style.display), + overflow: @cgeometry.Point( + x=overflow_to_engine(style.overflow.x), + y=overflow_to_engine(style.overflow.y), + ), + scrollbar_width: absolute_to_device( + style.scrollbar_width, + rem_size, + scale_factor, + ), + position: position_to_engine(style.position), + inset: edges_to_rect(style.inset.map(length)), + size: size_to_engine(style.size.map(length)), + min_size: size_to_engine(style.min_size.map(length)), + max_size: size_to_engine(style.max_size.map(length)), + aspect_ratio: style.aspect_ratio, + margin: edges_to_rect(style.margin.map(length)), + padding: edges_to_rect(style.padding.map(definite)), + border: border_widths_to_engine(style.border_widths, rem_size, scale_factor), + align_items: style.align_items.map(align_items_to_engine), + align_self: style.align_self.map(align_items_to_engine), + align_content: style.align_content.map(align_content_to_engine), + justify_content: style.justify_content.map(align_content_to_engine), + gap: size_to_engine(style.gap.map(definite)), + flex_direction: flex_direction_to_engine(style.flex_direction), + flex_wrap: flex_wrap_to_engine(style.flex_wrap), + flex_basis: length(style.flex_basis), + flex_grow: style.flex_grow, + flex_shrink: style.flex_shrink, + grid_template_rows: grid_template_to_engine(style.grid_rows), + grid_template_columns: grid_template_to_engine(style.grid_cols), + grid_row: match grid_location { + Some(location) => grid_range_to_engine(location.row) + Option::None => @cgeometry.Line(start=PlaceAuto, end=PlaceAuto) + }, + grid_column: match grid_location { + Some(location) => grid_range_to_engine(location.column) + Option::None => @cgeometry.Line(start=PlaceAuto, end=PlaceAuto) + }, + } +} diff --git a/src/layout/engine.mbt b/src/layout/engine.mbt new file mode 100644 index 0000000..6e9215a --- /dev/null +++ b/src/layout/engine.mbt @@ -0,0 +1,335 @@ +// The layout engine, ported from `TaffyLayoutEngine` in gpui/src/taffy.rs, +// on top of `Milky2018/chicle` (a MoonBit port of taffy). +// +// Deviation from GPUI: there is no cross-frame node cache yet (GPUI reuses +// nodes keyed by element path and keeps measure closures alive across +// frames). The engine is rebuilt on `clear()`, as older GPUI versions did. +// The cache depends on element ids and arrives with the Window (M6). + +///| +/// Space available to a node along one axis (GPUI: `AvailableSpace`). +#derive(Eq, Hash, Debug) +pub(all) enum AvailableSpace { + /// A definite amount of space, in logical pixels. + Definite(@geometry.Pixels) + /// Size to the smallest size that fits the content. + MinContent + /// Size to the largest size the content wants. + MaxContent +} + +///| +pub impl Default for AvailableSpace with fn default() { + MinContent +} + +///| +pub fn AvailableSpace::min_size() -> @geometry.Size[AvailableSpace] { + { width: MinContent, height: MinContent, } +} + +///| +/// Definite space in both dimensions. +pub fn AvailableSpace::from_size( + size : @geometry.Size[@geometry.Pixels], +) -> @geometry.Size[AvailableSpace] { + { width: Definite(size.width), height: Definite(size.height), } +} + +///| +/// Identifies a node requested from the `LayoutEngine` during this frame. +#derive(Eq, Hash, Compare, Debug) +pub(all) struct LayoutId(Int32) + +///| +/// Measures a leaf (e.g. text): given the dimensions already known and the +/// available space, in logical pixels, returns the content size. +pub type MeasureFn = ( + @geometry.Size[@geometry.Pixels?], + @geometry.Size[AvailableSpace], +) -> @geometry.Size[@geometry.Pixels] + +///| +/// Computes flexbox/grid/block layout for a frame's element tree. +pub struct LayoutEngine { + priv mut tree : @ctree.ChicleTree[MeasureFn] + /// The engine style of each node (needed by `stretch_auto_size_to_fill`). + priv styles : Map[Int32, @cstyle.Style] + priv children : Map[Int32, Array[Int32]] + priv parents : Map[Int32, Int32] + priv absolute_layout_bounds : Map[Int32, @geometry.Bounds[@geometry.Pixels]] + /// Absolute outer origins in device pixels, unrounded. + priv absolute_outer_origins : Map[Int32, @geometry.Point[Double]] + priv computed_layouts : @hashset.HashSet[Int32] +} + +///| +fn new_tree() -> @ctree.ChicleTree[MeasureFn] { + let tree : @ctree.ChicleTree[MeasureFn] = @ctree.ChicleTree() + // GPUI snaps to device pixels itself; the engine must not round. + tree.disable_rounding() + tree +} + +///| +pub fn LayoutEngine::new() -> LayoutEngine { + { + tree: new_tree(), + styles: {}, + children: {}, + parents: {}, + absolute_layout_bounds: {}, + absolute_outer_origins: {}, + computed_layouts: @hashset.HashSet([]), + } +} + +///| +/// Forgets every node. Call between frames; `LayoutId`s from earlier frames +/// become invalid. +pub fn LayoutEngine::clear(self : LayoutEngine) -> Unit { + self.tree = new_tree() + self.styles.clear() + self.children.clear() + self.parents.clear() + self.absolute_layout_bounds.clear() + self.absolute_outer_origins.clear() + self.computed_layouts.clear() +} + +///| +/// Number of nodes requested since the last `clear`. +pub fn LayoutEngine::node_count(self : LayoutEngine) -> Int32 { + self.styles.length() +} + +///| +/// GPUI expects layout errors to be impossible by construction; fail loudly +/// if one happens anyway. +fn engine_failure(operation : String, error : @ctree.ChicleError) -> Unit { + ignore(error) + abort("layout engine: \{operation} failed (invalid LayoutId?)") +} + +///| +fn LayoutEngine::check_id( + self : LayoutEngine, + id : LayoutId, + operation : String, +) -> Unit { + guard self.styles.contains(id.0) else { + abort( + "layout engine: \{operation}: unknown LayoutId(\{id.0}) (requested in an earlier frame?)", + ) + } +} + +///| +/// Requests a node with the given children (GPUI: `request_layout`). +pub fn LayoutEngine::request_layout( + self : LayoutEngine, + style : @style.Style, + rem_size : @geometry.Pixels, + scale_factor : Double, + children : Array[LayoutId], +) -> LayoutId { + let engine_style = style_to_engine(style, rem_size, scale_factor) + let child_ids = children.map(fn(child) { + self.check_id(child, "request_layout") + guard !self.parents.contains(child.0) else { + abort("layout engine: LayoutId(\{child.0}) already has a parent") + } + child.0 + }) + let id = if child_ids.is_empty() { + self.tree.new_leaf(engine_style) + } else { + self.tree.new_with_children(engine_style, child_ids) + } + self.styles[id] = engine_style + self.children[id] = child_ids + for child in child_ids { + self.parents[child] = id + } + LayoutId(id) +} + +///| +/// Requests a leaf whose content size comes from `measure`, called during +/// `compute_layout` (GPUI: `request_measured_layout`). +pub fn LayoutEngine::request_measured_layout( + self : LayoutEngine, + style : @style.Style, + rem_size : @geometry.Pixels, + scale_factor : Double, + measure : MeasureFn, +) -> LayoutId { + let engine_style = style_to_engine(style, rem_size, scale_factor) + let id = self.tree.new_leaf_with_context(engine_style, measure) + self.styles[id] = engine_style + self.children[id] = [] + LayoutId(id) +} + +///| +/// Makes an `auto`-sized root fill `size` (GPUI: `stretch_auto_size_to_fill`, +/// used for the window's root element). +pub fn LayoutEngine::stretch_auto_size_to_fill( + self : LayoutEngine, + id : LayoutId, + size : @geometry.Size[@geometry.Pixels], + scale_factor : Double, +) -> Unit { + self.check_id(id, "stretch_auto_size_to_fill") + let style = self.styles[id.0] + let stretch_width = style.size.width is DimAuto + let stretch_height = style.size.height is DimAuto + if !stretch_width && !stretch_height { + return + } + let width : @cstyle.Dimension = if stretch_width { + DimLength(round_to_device_pixel(size.width.to_double(), scale_factor)) + } else { + style.size.width + } + let height : @cstyle.Dimension = if stretch_height { + DimLength(round_to_device_pixel(size.height.to_double(), scale_factor)) + } else { + style.size.height + } + let stretched = { ..style, size: @cgeometry.Size(width~, height~), } + self.styles[id.0] = stretched + self.tree.set_style(id.0, stretched) catch { + e => engine_failure("set_style", e) + } +} + +///| +fn available_to_engine( + space : AvailableSpace, + scale_factor : Double, +) -> @cgeometry.AvailableSpace { + match space { + Definite(pixels) => AvailDefinite(pixels.to_double() * scale_factor) + MinContent => AvailMinContent + MaxContent => AvailMaxContent + } +} + +///| +fn available_from_engine( + space : @cgeometry.AvailableSpace, + scale_factor : Double, +) -> AvailableSpace { + match space { + AvailDefinite(value) => Definite(@geometry.px(value / scale_factor)) + AvailMinContent => MinContent + AvailMaxContent => MaxContent + } +} + +///| +/// Computes the layout of the subtree rooted at `id` (GPUI: +/// `compute_layout`). Measure functions receive and return logical pixels; +/// measured sizes are rounded up to whole device pixels. +pub fn LayoutEngine::compute_layout( + self : LayoutEngine, + id : LayoutId, + available_space : @geometry.Size[AvailableSpace], + scale_factor : Double, +) -> Unit { + self.check_id(id, "compute_layout") + // Recomputing invalidates cached bounds of the whole subtree. + if self.computed_layouts.contains(id.0) { + let stack = [id.0] + while stack.pop() is Some(node) { + self.absolute_layout_bounds.remove(node) + self.absolute_outer_origins.remove(node) + for child in self.children.get(node).unwrap_or([]) { + stack.push(child) + } + } + } else { + self.computed_layouts.add(id.0) + } + let available = @cgeometry.Size( + width=available_to_engine(available_space.width, scale_factor), + height=available_to_engine(available_space.height, scale_factor), + ) + let measure_leaf = fn( + known : @cgeometry.Size[Double?], + available : @cgeometry.Size[@cgeometry.AvailableSpace], + _node : Int32, + context : MeasureFn?, + _style : @cstyle.Style, + ) -> @cgeometry.Size[Double] { + match context { + Option::None => @cgeometry.Size(width=0.0, height=0.0) + Some(measure) => { + let to_logical = fn(value : Double?) { + value.map(fn(v) { @geometry.px(v / scale_factor) }) + } + let measured = measure( + { width: to_logical(known.width), height: to_logical(known.height), }, + { + width: available_from_engine(available.width, scale_factor), + height: available_from_engine(available.height, scale_factor), + }, + ) + let snap = fn(d : @geometry.Pixels) { + let d = d.to_double() + ceil_to_device_pixel(if d > 0.0 { d } else { 0.0 }, scale_factor) + } + @cgeometry.Size( + width=snap(measured.width), + height=snap(measured.height), + ) + } + } + } + self.tree.compute_layout_with_measure(id.0, available, measure_leaf) catch { + e => engine_failure("compute_layout", e) + } +} + +///| +/// The bounds of a computed node, in logical pixels relative to the root's +/// origin (GPUI: `layout_bounds`). Corners are snapped to device pixels. +pub fn LayoutEngine::layout_bounds( + self : LayoutEngine, + id : LayoutId, + scale_factor : Double, +) -> @geometry.Bounds[@geometry.Pixels] { + self.check_id(id, "layout_bounds") + if self.absolute_layout_bounds.get(id.0) is Some(bounds) { + return bounds + } + let layout = self.tree.layout(id.0) catch { + e => { + engine_failure("layout", e) + panic() + } + } + let location : @geometry.Point[Double] = { + x: layout.location.x, + y: layout.location.y, + } + let origin = match self.parents.get(id.0) { + Some(parent) => { + ignore(self.layout_bounds(LayoutId(parent), scale_factor)) + guard self.absolute_outer_origins.get(parent) is Some(parent_origin) else { + abort("layout engine: parent origin should be cached") + } + parent_origin + location + } + Option::None => location + } + self.absolute_outer_origins[id.0] = origin + let far = origin + { x: layout.size.width, y: layout.size.height, } + let snap = fn(p : @geometry.Point[Double]) { + p.map(fn(v) { @geometry.px(round_half_toward_zero(v) / scale_factor) }) + } + let bounds = @geometry.Bounds::from_corners(snap(origin), snap(far)) + self.absolute_layout_bounds[id.0] = bounds + bounds +} diff --git a/src/layout/layout_test.mbt b/src/layout/layout_test.mbt new file mode 100644 index 0000000..9da9e8c --- /dev/null +++ b/src/layout/layout_test.mbt @@ -0,0 +1,359 @@ +///| +fn st(refinement : @style.StyleRefinement) -> @style.Style { + (Default::default() : @style.Style).refined(refinement) +} + +///| +fn r() -> @style.StyleRefinement { + @style.StyleRefinement::new() +} + +///| +let rem : @geometry.Pixels = @geometry.px(16.0) + +///| +fn bounds( + x : Double, + y : Double, + w : Double, + h : Double, +) -> @geometry.Bounds[@geometry.Pixels] { + @geometry.bounds( + @geometry.point(@geometry.px(x), @geometry.px(y)), + @geometry.size(@geometry.px(w), @geometry.px(h)), + ) +} + +///| +fn definite(w : Double, h : Double) -> @geometry.Size[@layout.AvailableSpace] { + @layout.AvailableSpace::from_size( + @geometry.size(@geometry.px(w), @geometry.px(h)), + ) +} + +///| +/// Port of GPUI's `test_round_half_toward_zero` (util.rs). +test "round half toward zero" { + let cases : Array[(Double, Double)] = [ + (0.5, 0.0), + (1.5, 1.0), + (2.5, 2.0), + (-0.5, 0.0), + (-1.5, -1.0), + (-2.5, -2.0), + (1.5001, 2.0), + (1.4999, 1.0), + (-1.5001, -2.0), + (-1.4999, -1.0), + (0.0, 0.0), + (3.0, 3.0), + (-3.0, -3.0), + (2.5001, 3.0), + ] + for case in cases { + let (input, expected) = case + assert_eq(@layout.round_half_toward_zero(input), expected) + } +} + +///| +/// Port of GPUI's `border_widths_to_taffy_use_stroke_snapping` (taffy.rs). +test "border widths use stroke snapping" { + let widths = @geometry.Edges::new( + top=@geometry.px(0.0).to_absolute(), + right=@geometry.px(0.4).to_absolute(), + bottom=@geometry.px(0.5).to_absolute(), + left=@geometry.px(1.6).to_absolute(), + ) + let border = @layout.border_widths_to_engine(widths, rem, 1.0) + assert_true(border.top is DimLength(0.0)) + assert_true(border.right is DimLength(1.0)) + assert_true(border.bottom is DimLength(1.0)) + assert_true(border.left is DimLength(2.0)) +} + +///| +test "flex row distributes free space" { + let engine = @layout.LayoutEngine::new() + let a = engine.request_layout( + st(r().w(@geometry.px(50.0)).h_full()), + rem, + 1.0, + [], + ) + let b = engine.request_layout(st(r().flex_1()), rem, 1.0, []) + let c = engine.request_layout( + st(r().w(@geometry.px(100.0)).h(@geometry.px(20.0))), + rem, + 1.0, + [], + ) + let root = engine.request_layout( + st(r().flex().w(@geometry.px(300.0)).h(@geometry.px(40.0))), + rem, + 1.0, + [a, b, c], + ) + engine.compute_layout(root, definite(1000.0, 1000.0), 1.0) + assert_eq(engine.layout_bounds(root, 1.0), bounds(0.0, 0.0, 300.0, 40.0)) + assert_eq(engine.layout_bounds(a, 1.0), bounds(0.0, 0.0, 50.0, 40.0)) + // flex_1 takes the remaining 150px; items stretch on the cross axis. + assert_eq(engine.layout_bounds(b, 1.0), bounds(50.0, 0.0, 150.0, 40.0)) + assert_eq(engine.layout_bounds(c, 1.0), bounds(200.0, 0.0, 100.0, 20.0)) + assert_eq(engine.node_count(), 4) +} + +///| +test "rems, padding, gap and percentages resolve" { + let engine = @layout.LayoutEngine::new() + let first = engine.request_layout(st(r().w_1_2().h_4()), rem, 1.0, []) + let second = engine.request_layout(st(r().w_full().h_8()), rem, 1.0, []) + let root = engine.request_layout( + st(r().flex().flex_col().p_4().gap_2().w(@geometry.px(232.0))), + rem, + 1.0, + [first, second], + ) + engine.compute_layout(root, definite(500.0, 500.0), 1.0) + // p_4 = 1rem = 16px, gap_2 = 0.5rem = 8px, h_4 = 16px, h_8 = 32px. + assert_eq(engine.layout_bounds(first, 1.0), bounds(16.0, 16.0, 100.0, 16.0)) + assert_eq(engine.layout_bounds(second, 1.0), bounds(16.0, 40.0, 200.0, 32.0)) + // Auto height: padding + children + gap. + assert_eq(engine.layout_bounds(root, 1.0), bounds(0.0, 0.0, 232.0, 88.0)) +} + +///| +test "borders take space inside the box" { + let engine = @layout.LayoutEngine::new() + let child = engine.request_layout(st(r().size_full()), rem, 1.0, []) + let root = engine.request_layout( + st(r().flex().border_2().size(@geometry.px(50.0))), + rem, + 1.0, + [child], + ) + engine.compute_layout(root, definite(100.0, 100.0), 1.0) + assert_eq(engine.layout_bounds(child, 1.0), bounds(2.0, 2.0, 46.0, 46.0)) +} + +///| +test "layout snaps to device pixels" { + let engine = @layout.LayoutEngine::new() + // 10.3px at 1.5x is 15.45 device px -> 15 -> 10px logical. + let child = engine.request_layout( + st(r().w(@geometry.px(10.3)).h(@geometry.px(10.0))), + rem, + 1.5, + [], + ) + let root = engine.request_layout(st(r().flex()), rem, 1.5, [child]) + engine.compute_layout(root, definite(100.0, 100.0), 1.5) + let b = engine.layout_bounds(child, 1.5) + assert_eq(b.size.width, @geometry.px(10.0)) + assert_eq(b.size.height, @geometry.px(10.0)) + // A 1px border at 0.5x is still one device pixel wide. + assert_eq(@layout.round_stroke_to_device_pixel(1.0, 0.5), 1.0) + assert_eq(@layout.round_stroke_to_device_pixel(0.0, 0.5), 0.0) +} + +///| +test "nested bounds are absolute" { + let engine = @layout.LayoutEngine::new() + let leaf = engine.request_layout(st(r().size(@geometry.px(10.0))), rem, 1.0, []) + let middle = engine.request_layout( + st(r().flex().p(@geometry.px(5.0))), + rem, + 1.0, + [leaf], + ) + let spacer = engine.request_layout(st(r().w(@geometry.px(30.0))), rem, 1.0, []) + let root = engine.request_layout( + st(r().flex().p(@geometry.px(7.0))), + rem, + 1.0, + [spacer, middle], + ) + engine.compute_layout(root, definite(200.0, 200.0), 1.0) + assert_eq(engine.layout_bounds(middle, 1.0), bounds(37.0, 7.0, 20.0, 20.0)) + assert_eq(engine.layout_bounds(leaf, 1.0), bounds(42.0, 12.0, 10.0, 10.0)) + // Recomputing with less space updates cached bounds. + engine.compute_layout(root, definite(20.0, 20.0), 1.0) + assert_eq(engine.layout_bounds(leaf, 1.0).origin.y, @geometry.px(12.0)) +} + +///| +test "measured leaves get logical pixels and are ceiled to device pixels" { + let engine = @layout.LayoutEngine::new() + let calls : Array[(@geometry.Pixels?, @layout.AvailableSpace)] = [] + // A fake paragraph: 7.25px per character, wrapping at the available width, + // 20px per line. + let measure = fn( + known : @geometry.Size[@geometry.Pixels?], + available : @geometry.Size[@layout.AvailableSpace], + ) -> @geometry.Size[@geometry.Pixels] { + calls.push((known.width, available.width)) + let text_width = 40.0 * 7.25 + let wrap = match (known.width, available.width) { + (Some(width), _) => width.to_double() + (None, Definite(width)) => width.to_double() + (None, _) => text_width + } + let width = if text_width < wrap { text_width } else { wrap } + let lines = (text_width / wrap).ceil() + @geometry.size(@geometry.px(width), @geometry.px(lines * 20.0)) + } + let text = engine.request_measured_layout(st(r()), rem, 2.0, measure) + let root = engine.request_layout( + st(r().flex().flex_col().w(@geometry.px(100.0))), + rem, + 2.0, + [text], + ) + engine.compute_layout(root, definite(800.0, 600.0), 2.0) + let b = engine.layout_bounds(text, 2.0) + assert_eq(b.size.width, @geometry.px(100.0)) + // 290px of text in 100px -> 3 lines. + assert_eq(b.size.height, @geometry.px(60.0)) + assert_true(calls.length() > 0) + // The measure function sees logical, not device, pixels. + for call in calls { + match call { + (Some(width), _) => assert_eq(width, @geometry.px(100.0)) + (None, Definite(width)) => assert_true(width.to_double() <= 800.0) + _ => () + } + } +} + +///| +test "measured sizes round up to whole device pixels" { + let engine = @layout.LayoutEngine::new() + let leaf = engine.request_measured_layout(st(r()), rem, 2.0, fn(_, _) { + @geometry.size(@geometry.px(10.2), @geometry.px(-5.0)) + }) + // items_start: keep the measured height instead of stretching. + let root = engine.request_layout(st(r().flex().items_start()), rem, 2.0, [ + leaf, + ]) + engine.compute_layout(root, definite(100.0, 100.0), 2.0) + let b = engine.layout_bounds(leaf, 2.0) + // ceil(10.2 * 2) = 21 device px = 10.5 logical; negative clamps to 0. + assert_eq(b.size.width, @geometry.px(10.5)) + assert_eq(b.size.height, @geometry.px(0.0)) +} + +///| +test "stretch auto size to fill" { + let engine = @layout.LayoutEngine::new() + let child = engine.request_layout(st(r().flex_1()), rem, 1.0, []) + let root = engine.request_layout(st(r().flex()), rem, 1.0, [child]) + engine.stretch_auto_size_to_fill( + root, + @geometry.size(@geometry.px(640.0), @geometry.px(480.0)), + 1.0, + ) + engine.compute_layout(root, @layout.AvailableSpace::min_size(), 1.0) + assert_eq(engine.layout_bounds(root, 1.0), bounds(0.0, 0.0, 640.0, 480.0)) + assert_eq(engine.layout_bounds(child, 1.0), bounds(0.0, 0.0, 640.0, 480.0)) + // A definite size is left alone. + let fixed = engine.request_layout( + st(r().size(@geometry.px(10.0))), + rem, + 1.0, + [], + ) + engine.stretch_auto_size_to_fill( + fixed, + @geometry.size(@geometry.px(640.0), @geometry.px(480.0)), + 1.0, + ) + engine.compute_layout(fixed, @layout.AvailableSpace::min_size(), 1.0) + assert_eq(engine.layout_bounds(fixed, 1.0).size.width, @geometry.px(10.0)) +} + +///| +test "grid columns and placement" { + let engine = @layout.LayoutEngine::new() + let cells = [ + engine.request_layout(st(r().h(@geometry.px(10.0))), rem, 1.0, []), + engine.request_layout(st(r().h(@geometry.px(10.0)).col_span(2)), rem, 1.0, []), + engine.request_layout(st(r().h(@geometry.px(10.0))), rem, 1.0, []), + ] + let root = engine.request_layout( + st(r().grid().grid_cols(3).w(@geometry.px(300.0))), + rem, + 1.0, + cells, + ) + engine.compute_layout(root, definite(1000.0, 1000.0), 1.0) + assert_eq(engine.layout_bounds(cells[0], 1.0), bounds(0.0, 0.0, 100.0, 10.0)) + assert_eq( + engine.layout_bounds(cells[1], 1.0), + bounds(100.0, 0.0, 200.0, 10.0), + ) + assert_eq(engine.layout_bounds(cells[2], 1.0), bounds(0.0, 10.0, 100.0, 10.0)) +} + +///| +test "absolute positioning and display none" { + let engine = @layout.LayoutEngine::new() + let overlay = engine.request_layout( + st( + r() + .absolute() + .top(@geometry.px(5.0)) + .right(@geometry.px(5.0)) + .size(@geometry.px(20.0)), + ), + rem, + 1.0, + [], + ) + let gone = engine.request_layout( + st(r().hidden().size(@geometry.px(50.0))), + rem, + 1.0, + [], + ) + let root = engine.request_layout( + st(r().flex().relative().size(@geometry.px(100.0))), + rem, + 1.0, + [overlay, gone], + ) + engine.compute_layout(root, definite(500.0, 500.0), 1.0) + assert_eq(engine.layout_bounds(overlay, 1.0), bounds(75.0, 5.0, 20.0, 20.0)) + assert_eq(engine.layout_bounds(gone, 1.0).size.width, @geometry.px(0.0)) +} + +///| +test "alignment and justification" { + let engine = @layout.LayoutEngine::new() + let child = engine.request_layout( + st(r().size(@geometry.px(20.0))), + rem, + 1.0, + [], + ) + let root = engine.request_layout( + st(r().flex().items_center().justify_center().size(@geometry.px(100.0))), + rem, + 1.0, + [child], + ) + engine.compute_layout(root, definite(500.0, 500.0), 1.0) + assert_eq(engine.layout_bounds(child, 1.0), bounds(40.0, 40.0, 20.0, 20.0)) +} + +///| +test "clear starts a new frame" { + let engine = @layout.LayoutEngine::new() + let a = engine.request_layout(st(r().size(@geometry.px(5.0))), rem, 1.0, []) + engine.compute_layout(a, @layout.AvailableSpace::min_size(), 1.0) + assert_eq(engine.node_count(), 1) + engine.clear() + assert_eq(engine.node_count(), 0) + let b = engine.request_layout(st(r().size(@geometry.px(7.0))), rem, 1.0, []) + engine.compute_layout(b, @layout.AvailableSpace::min_size(), 1.0) + assert_eq(engine.layout_bounds(b, 1.0).size.width, @geometry.px(7.0)) +} diff --git a/src/layout/moon.pkg b/src/layout/moon.pkg new file mode 100644 index 0000000..6fbde9b --- /dev/null +++ b/src/layout/moon.pkg @@ -0,0 +1,8 @@ +import { + "experiments/gpui/geometry", + "experiments/gpui/style", + "Milky2018/chicle/geometry" @cgeometry, + "Milky2018/chicle/style" @cstyle, + "Milky2018/chicle/tree" @ctree, + "moonbitlang/core/hashset", +} diff --git a/src/layout/pkg.generated.mbti b/src/layout/pkg.generated.mbti new file mode 100644 index 0000000..3395355 --- /dev/null +++ b/src/layout/pkg.generated.mbti @@ -0,0 +1,52 @@ +// Generated using `moon info`, DON'T EDIT IT +package "experiments/gpui/layout" + +import { + "moonbitlang/core/debug", +} + +// Values +pub fn border_widths_to_engine(@experiments/gpui/geometry.Edges[@experiments/gpui/geometry.AbsoluteLength], @experiments/gpui/geometry.Pixels, Double) -> @Milky2018/chicle/geometry.Rect[@Milky2018/chicle/style.Dimension] + +pub fn ceil_to_device_pixel(Double, Double) -> Double + +pub fn round_half_toward_zero(Double) -> Double + +pub fn round_stroke_to_device_pixel(Double, Double) -> Double + +pub fn round_to_device_pixel(Double, Double) -> Double + +pub fn style_to_engine(@experiments/gpui/style.Style, @experiments/gpui/geometry.Pixels, Double) -> @Milky2018/chicle/style.Style + +// Errors + +// Types and methods +#derive(Eq, Hash, @debug.Debug) +pub(all) enum AvailableSpace { + Definite(@experiments/gpui/geometry.Pixels) + MinContent + MaxContent +} +pub fn AvailableSpace::from_size(@experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels]) -> @experiments/gpui/geometry.Size[Self] +pub fn AvailableSpace::min_size() -> @experiments/gpui/geometry.Size[Self] +pub impl Default for AvailableSpace + +pub struct LayoutEngine { + // private fields +} +pub fn LayoutEngine::clear(Self) -> Unit +pub fn LayoutEngine::compute_layout(Self, LayoutId, @experiments/gpui/geometry.Size[AvailableSpace], Double) -> Unit +pub fn LayoutEngine::layout_bounds(Self, LayoutId, Double) -> @experiments/gpui/geometry.Bounds[@experiments/gpui/geometry.Pixels] +pub fn LayoutEngine::new() -> Self +pub fn LayoutEngine::node_count(Self) -> Int32 +pub fn LayoutEngine::request_layout(Self, @experiments/gpui/style.Style, @experiments/gpui/geometry.Pixels, Double, Array[LayoutId]) -> LayoutId +pub fn LayoutEngine::request_measured_layout(Self, @experiments/gpui/style.Style, @experiments/gpui/geometry.Pixels, Double, (@experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels?], @experiments/gpui/geometry.Size[AvailableSpace]) -> @experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels]) -> LayoutId +pub fn LayoutEngine::stretch_auto_size_to_fill(Self, LayoutId, @experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels], Double) -> Unit + +#derive(Compare, Eq, Hash, @debug.Debug) +pub(all) struct LayoutId(Int32) + +// Type aliases +pub type MeasureFn = (@experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels?], @experiments/gpui/geometry.Size[AvailableSpace]) -> @experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels] + +// Traits